From 41fc15a7e81de1e54665c39c40afafe4e3394158 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 6 Feb 2022 23:14:08 +0100 Subject: [PATCH] Remove picocms\Pico\ namespace This reverts commit 812ae5c21548905e308f002bc6d97a042ea09aad --- .build/deploy-branch.sh | 2 +- .build/install.sh | 2 +- .build/release.sh | 2 +- .travis.yml | 2 +- composer.json | 2 +- index.php | 2 +- index.php.dist | 2 +- ...tractPlugin.php => AbstractPicoPlugin.php} | 34 ++++++++-------- lib/Pico.php | 40 +++++++++---------- ...nInterface.php => PicoPluginInterface.php} | 12 +++--- ...wigExtension.php => PicoTwigExtension.php} | 6 +-- plugins/DummyPlugin.php | 8 ++-- 12 files changed, 53 insertions(+), 61 deletions(-) rename lib/{AbstractPlugin.php => AbstractPicoPlugin.php} (92%) rename lib/{PluginInterface.php => PicoPluginInterface.php} (93%) rename lib/{TwigExtension.php => PicoTwigExtension.php} (99%) diff --git a/.build/deploy-branch.sh b/.build/deploy-branch.sh index ca0fda7..d8284a7 100755 --- a/.build/deploy-branch.sh +++ b/.build/deploy-branch.sh @@ -4,7 +4,7 @@ set -e [ -n "$PICO_BUILD_ENV" ] || { echo "No Pico build environment specified" >&2; exit 1; } # get current Pico milestone -VERSION="$(php -r "require_once('$PICO_PROJECT_DIR/lib/Pico.php'); echo picocms\Pico\Pico::VERSION;")" +VERSION="$(php -r "require_once('$PICO_PROJECT_DIR/lib/Pico.php'); echo Pico::VERSION;")" MILESTONE="Pico$([[ "$VERSION" =~ ^([0-9]+\.[0-9]+)\. ]] && echo " ${BASH_REMATCH[1]}")" echo "Deploying $PROJECT_REPO_BRANCH branch ($MILESTONE)..." diff --git a/.build/install.sh b/.build/install.sh index c64bf80..01d772d 100755 --- a/.build/install.sh +++ b/.build/install.sh @@ -24,7 +24,7 @@ if [ -z "$COMPOSER_ROOT_VERSION" ] && [ -n "$PROJECT_REPO_BRANCH" ]; then if [ -z "$PICO_VERSION_PATTERN" ]; then PICO_VERSION_PATTERN="$(php -r " require_once('$PICO_PROJECT_DIR/lib/Pico.php'); - echo preg_replace('/\.[0-9]+-dev$/', '.x-dev', picocms\Pico\Pico::VERSION); + echo preg_replace('/\.[0-9]+-dev$/', '.x-dev', Pico::VERSION); ")" fi diff --git a/.build/release.sh b/.build/release.sh index b8fb653..7a2cc1d 100755 --- a/.build/release.sh +++ b/.build/release.sh @@ -16,7 +16,7 @@ echo if [ -z "$VERSION" ]; then PICO_VERSION="$(php -r " require_once('$PICO_PROJECT_DIR/lib/Pico.php'); - echo preg_replace('/-(?:dev|n|nightly)(?:[.-]?[0-9]+)?(?:[.-]dev)?$/', '', picocms\Pico\Pico::VERSION); + echo preg_replace('/-(?:dev|n|nightly)(?:[.-]?[0-9]+)?(?:[.-]dev)?$/', '', Pico::VERSION); ")" VERSION="v$PICO_VERSION-dev+${PROJECT_REPO_BRANCH:-master}" diff --git a/.travis.yml b/.travis.yml index ee54509..5d7ee4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ jobs: install: - install.sh --deploy script: - - '[ "$PROJECT_REPO_TAG" == "v$(php -r "require_once(\"lib/Pico.php\"); echo picocms\Pico\Pico::VERSION;")" ]' + - '[ "$PROJECT_REPO_TAG" == "v$(php -r "require_once(\"lib/Pico.php\"); echo Pico::VERSION;")" ]' - deploy-release.sh before_deploy: - release.sh "$PROJECT_REPO_TAG" diff --git a/composer.json b/composer.json index 8be85c6..e37b54d 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ }, "autoload": { "psr-4": { - "picocms\\Pico\\": "lib/" + "": "lib/" } }, "extra": { diff --git a/index.php b/index.php index 83d112f..fedc544 100644 --- a/index.php +++ b/index.php @@ -26,7 +26,7 @@ if (is_file(__DIR__ . '/vendor/autoload.php')) { } // instance Pico -$pico = new \picocms\Pico\Pico( +$pico = new Pico( __DIR__, // root dir 'config/', // config dir 'plugins/', // plugins dir diff --git a/index.php.dist b/index.php.dist index 9550c59..36fcdbc 100644 --- a/index.php.dist +++ b/index.php.dist @@ -25,7 +25,7 @@ if (!extension_loaded('mbstring')) { require_once(__DIR__ . '/vendor/autoload.php'); // instance Pico -$pico = new \picocms\Pico\Pico( +$pico = new Pico( __DIR__, // root dir 'config/', // config dir 'plugins/', // plugins dir diff --git a/lib/AbstractPlugin.php b/lib/AbstractPicoPlugin.php similarity index 92% rename from lib/AbstractPlugin.php rename to lib/AbstractPicoPlugin.php index 1176bba..144170f 100644 --- a/lib/AbstractPlugin.php +++ b/lib/AbstractPicoPlugin.php @@ -10,27 +10,25 @@ * License-Filename: LICENSE */ -namespace picocms\Pico; - /** * Abstract class to extend from when implementing a Pico plugin * - * Please refer to {@see PluginInterface} for more information about how to + * Please refer to {@see PicoPluginInterface} for more information about how to * develop a plugin for Pico. * - * @see PluginInterface + * @see PicoPluginInterface * * @author Daniel Rudolf * @link http://picocms.org * @license http://opensource.org/licenses/MIT The MIT License * @version 3.0 */ -abstract class AbstractPlugin implements PluginInterface +abstract class AbstractPicoPlugin implements PicoPluginInterface { /** * Current instance of Pico * - * @see PluginInterface::getPico() + * @see PicoPluginInterface::getPico() * @var Pico */ protected $pico; @@ -38,8 +36,8 @@ abstract class AbstractPlugin implements PluginInterface /** * Boolean indicating if this plugin is enabled (TRUE) or disabled (FALSE) * - * @see PluginInterface::isEnabled() - * @see PluginInterface::setEnabled() + * @see PicoPluginInterface::isEnabled() + * @see PicoPluginInterface::setEnabled() * @var bool|null */ protected $enabled; @@ -47,7 +45,7 @@ abstract class AbstractPlugin implements PluginInterface /** * Boolean indicating if this plugin was ever enabled/disabled manually * - * @see PluginInterface::isStatusChanged() + * @see PicoPluginInterface::isStatusChanged() * @var bool */ protected $statusChanged = false; @@ -55,7 +53,7 @@ abstract class AbstractPlugin implements PluginInterface /** * Boolean indicating whether this plugin matches Pico's API version * - * @see AbstractPlugin::checkCompatibility() + * @see AbstractPicoPlugin::checkCompatibility() * @var bool|null */ protected $nativePlugin; @@ -63,8 +61,8 @@ abstract class AbstractPlugin implements PluginInterface /** * List of plugins which this plugin depends on * - * @see AbstractPlugin::checkDependencies() - * @see PluginInterface::getDependencies() + * @see AbstractPicoPlugin::checkDependencies() + * @see PicoPluginInterface::getDependencies() * @var string[] */ protected $dependsOn = []; @@ -72,8 +70,8 @@ abstract class AbstractPlugin implements PluginInterface /** * List of plugin which depend on this plugin * - * @see AbstractPlugin::checkDependants() - * @see PluginInterface::getDependants() + * @see AbstractPicoPlugin::checkDependants() + * @see PicoPluginInterface::getDependants() * @var object[]|null */ protected $dependants; @@ -198,7 +196,7 @@ abstract class AbstractPlugin implements PluginInterface /** * Enables all plugins which this plugin depends on * - * @see PluginInterface::getDependencies() + * @see PicoPluginInterface::getDependencies() * * @param bool $recursive enable required plugins automatically * @@ -217,7 +215,7 @@ abstract class AbstractPlugin implements PluginInterface } // plugins which don't implement PicoPluginInterface are always enabled - if (($plugin instanceof PluginInterface) && !$plugin->isEnabled()) { + if (($plugin instanceof PicoPluginInterface) && !$plugin->isEnabled()) { if ($recursive) { if (!$plugin->isStatusChanged()) { $plugin->setEnabled(true, true, true); @@ -248,7 +246,7 @@ abstract class AbstractPlugin implements PluginInterface /** * Disables all plugins which depend on this plugin * - * @see PluginInterface::getDependants() + * @see PicoPluginInterface::getDependants() * * @param bool $recursive disabled dependant plugins automatically * @@ -291,7 +289,7 @@ abstract class AbstractPlugin implements PluginInterface $this->dependants = []; foreach ($this->getPico()->getPlugins() as $pluginName => $plugin) { // only plugins which implement PicoPluginInterface support dependencies - if ($plugin instanceof PluginInterface) { + if ($plugin instanceof PicoPluginInterface) { $dependencies = $plugin->getDependencies(); if (in_array(get_called_class(), $dependencies)) { $this->dependants[$pluginName] = $plugin; diff --git a/lib/Pico.php b/lib/Pico.php index 07d0a83..663a413 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -16,8 +16,6 @@ * License-Filename: LICENSE */ -namespace picocms\Pico; - use Symfony\Component\Yaml\Parser as YamlParser; use Twig\Environment as TwigEnvironment; use Twig\Extension\DebugExtension as TwigDebugExtension; @@ -156,7 +154,7 @@ class Pico /** * List of loaded plugins using the current API version * - * @var PluginInterface[] + * @var PicoPluginInterface[] */ protected $nativePlugins = []; @@ -607,7 +605,7 @@ class Pico continue; } - if (!($plugin instanceof PluginInterface)) { + if (!($plugin instanceof PicoPluginInterface)) { throw new \RuntimeException( "Unable to load plugin '" . $className . "' via 'vendor/pico-plugin.php': " . "Plugins installed by composer must implement 'PicoPluginInterface'" @@ -698,7 +696,7 @@ class Pico $this->plugins[$className] = $plugin; - if ($plugin instanceof PluginInterface) { + if ($plugin instanceof PicoPluginInterface) { if (defined($className . '::API_VERSION') && ($className::API_VERSION >= static::API_VERSION)) { $this->nativePlugins[$className] = $plugin; } @@ -714,11 +712,11 @@ class Pico /** * Manually loads a plugin * - * Manually loaded plugins MUST implement {@see PluginInterface}. They are - * simply appended to the plugins array without any additional checks, so - * you might get unexpected results, depending on *when* you're loading a - * plugin. You SHOULD NOT load plugins after a event has been triggered by - * Pico. In-depth knowledge of Pico's inner workings is strongly advised + * Manually loaded plugins MUST implement {@see PicoPluginInterface}. They + * are simply appended to the plugins array without any additional checks, + * so you might get unexpected results, depending on *when* you're loading + * a plugin. You SHOULD NOT load plugins after a event has been triggered + * by Pico. In-depth knowledge of Pico's inner workings is strongly advised * otherwise, and you MUST NOT rely on {@see PicoDeprecated} to maintain * backward compatibility in such cases. * @@ -736,10 +734,10 @@ class Pico * @see Pico::getPlugin() * @see Pico::getPlugins() * - * @param PluginInterface|string $plugin either the class name of a plugin - * to instantiate or a plugin instance + * @param PicoPluginInterface|string $plugin either the class name of a + * plugin to instantiate or a plugin instance * - * @return PluginInterface instance of the loaded plugin + * @return PicoPluginInterface instance of the loaded plugin * * @throws \RuntimeException thrown when the plugin couldn't be loaded */ @@ -756,7 +754,7 @@ class Pico $className = get_class($plugin); - if (!($plugin instanceof PluginInterface)) { + if (!($plugin instanceof PicoPluginInterface)) { throw new \RuntimeException( "Unable to load plugin '" . $className . "': " . "Manually loaded plugins must implement 'PicoPluginInterface'" @@ -826,7 +824,7 @@ class Pico $visitedPlugins[$pluginName] = true; $dependencies = []; - if ($plugin instanceof PluginInterface) { + if ($plugin instanceof PicoPluginInterface) { $dependencies = $plugin->getDependencies(); } if (!isset($nativePlugins[$pluginName])) { @@ -863,8 +861,8 @@ class Pico /** * Returns the instance of a named plugin * - * Plugins SHOULD implement {@see PluginInterface}, but you MUST NOT rely - * on it. For more information see {@see PluginInterface}. + * Plugins SHOULD implement {@see PicoPluginInterface}, but you MUST NOT + * rely on it. For more information see {@see PicoPluginInterface}. * * @see Pico::loadPlugins() * @see Pico::getPlugins() @@ -2106,7 +2104,7 @@ class Pico * This method triggers the `onTwigRegistered` event when the Twig template * engine wasn't initiated yet. When initiating Twig, this method also * registers Pico's core Twig filter `content` as well as Pico's - * {@see TwigExtension} Twig extension. + * {@see PicoTwigExtension} Twig extension. * * @see Pico::getTwig() * @see http://twig.sensiolabs.org/ Twig website @@ -2121,7 +2119,7 @@ class Pico $twigLoader = new TwigFilesystemLoader($this->getThemesDir() . $this->getTheme()); $this->twig = new TwigEnvironment($twigLoader, $twigConfig); - $this->twig->addExtension(new TwigExtension($this)); + $this->twig->addExtension(new PicoTwigExtension($this)); if (!empty($twigConfig['debug'])) { $this->twig->addExtension(new TwigDebugExtension()); @@ -2778,8 +2776,8 @@ class Pico * * You MUST NOT trigger events of Pico's core with a plugin! * - * @see PluginInterface - * @see AbstractPlugin + * @see PicoPluginInterface + * @see AbstractPicoPlugin * @see DummyPlugin * * @param string $eventName name of the event to trigger diff --git a/lib/PluginInterface.php b/lib/PicoPluginInterface.php similarity index 93% rename from lib/PluginInterface.php rename to lib/PicoPluginInterface.php index ec69745..d89ea3a 100644 --- a/lib/PluginInterface.php +++ b/lib/PicoPluginInterface.php @@ -10,8 +10,6 @@ * License-Filename: LICENSE */ -namespace picocms\Pico; - /** * Common interface for Pico plugins * @@ -30,7 +28,7 @@ namespace picocms\Pico; * @license http://opensource.org/licenses/MIT The MIT License * @version 3.0 */ -interface PluginInterface +interface PicoPluginInterface { /** * Handles a event that was triggered by Pico @@ -43,8 +41,8 @@ interface PluginInterface /** * Enables or disables this plugin * - * @see PluginInterface::isEnabled() - * @see PluginInterface::isStatusChanged() + * @see PicoPluginInterface::isEnabled() + * @see PicoPluginInterface::isStatusChanged() * * @param bool $enabled enable (TRUE) or disable (FALSE) this plugin * @param bool $recursive when TRUE, enable or disable recursively. @@ -67,7 +65,7 @@ interface PluginInterface * wasn't triggered on all plugins yet. This method might even return NULL * then. The plugin's status might change later. * - * @see PluginInterface::setEnabled() + * @see PicoPluginInterface::setEnabled() * * @return bool|null plugin is enabled (TRUE) or disabled (FALSE) */ @@ -76,7 +74,7 @@ interface PluginInterface /** * Returns TRUE if the plugin was ever enabled/disabled manually * - * @see PluginInterface::setEnabled() + * @see PicoPluginInterface::setEnabled() * * @return bool plugin is in its default state (TRUE), FALSE otherwise */ diff --git a/lib/TwigExtension.php b/lib/PicoTwigExtension.php similarity index 99% rename from lib/TwigExtension.php rename to lib/PicoTwigExtension.php index 2b76b66..1a4491a 100644 --- a/lib/TwigExtension.php +++ b/lib/PicoTwigExtension.php @@ -10,8 +10,6 @@ * License-Filename: LICENSE */ -namespace picocms\Pico; - use Twig\Error\RuntimeError as TwigRuntimeError; use Twig\Extension\AbstractExtension as AbstractTwigExtension; use Twig\Extension\ExtensionInterface as TwigExtensionInterface; @@ -26,12 +24,12 @@ use Twig\TwigFunction; * @license http://opensource.org/licenses/MIT The MIT License * @version 3.0 */ -class TwigExtension extends AbstractTwigExtension +class PicoTwigExtension extends AbstractTwigExtension { /** * Current instance of Pico * - * @see TwigExtension::getPico() + * @see PicoTwigExtension::getPico() * @var Pico */ private $pico; diff --git a/plugins/DummyPlugin.php b/plugins/DummyPlugin.php index 4a066e7..2a28133 100644 --- a/plugins/DummyPlugin.php +++ b/plugins/DummyPlugin.php @@ -10,7 +10,7 @@ * License-Filename: LICENSE */ -use picocms\Pico\AbstractPlugin; +use picocms\Pico\AbstractPicoPlugin; use picocms\Pico\Pico; use Twig\Environment as TwigEnvironment; @@ -25,7 +25,7 @@ use Twig\Environment as TwigEnvironment; * @license http://opensource.org/licenses/MIT The MIT License * @version 3.0 */ -class DummyPlugin extends AbstractPlugin +class DummyPlugin extends AbstractPicoPlugin { /** * API version used by this plugin @@ -56,7 +56,7 @@ class DummyPlugin extends AbstractPlugin * No matter what, the user can always explicitly enable or disable this * plugin in Pico's config. * - * @see AbstractPlugin::$enabled + * @see AbstractPicoPlugin::$enabled * @var bool|null */ protected $enabled = false; @@ -67,7 +67,7 @@ class DummyPlugin extends AbstractPlugin * If your plugin doesn't depend on any other plugin, remove this class * property. * - * @see AbstractPlugin::$dependsOn + * @see AbstractPicoPlugin::$dependsOn * @var string[] */ protected $dependsOn = array();