From 718b790b1987fb4a74079af2a289225165a855ba Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 29 Mar 2020 14:37:35 +0200 Subject: [PATCH 01/75] Kick-start development of Pico 3.0 --- composer.json | 3 ++- lib/AbstractPicoPlugin.php | 2 +- lib/Pico.php | 2 +- lib/PicoPluginInterface.php | 2 +- lib/PicoTwigExtension.php | 2 +- plugins/DummyPlugin.php | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 260467a5c..02b45aa72 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.1.x-dev" + "dev-master": "2.1.x-dev", + "dev-pico-3.0": "3.0.x-dev" } } } diff --git a/lib/AbstractPicoPlugin.php b/lib/AbstractPicoPlugin.php index b732ac224..4cc318bdf 100644 --- a/lib/AbstractPicoPlugin.php +++ b/lib/AbstractPicoPlugin.php @@ -21,7 +21,7 @@ * @author Daniel Rudolf * @link http://picocms.org * @license http://opensource.org/licenses/MIT The MIT License - * @version 2.1 + * @version 3.0 */ abstract class AbstractPicoPlugin implements PicoPluginInterface { diff --git a/lib/Pico.php b/lib/Pico.php index e19cbb3bd..387de4079 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -40,7 +40,7 @@ * @author Daniel Rudolf * @link http://picocms.org * @license http://opensource.org/licenses/MIT The MIT License - * @version 2.1 + * @version 3.0 */ class Pico { diff --git a/lib/PicoPluginInterface.php b/lib/PicoPluginInterface.php index 85f9dfbd5..323be862c 100644 --- a/lib/PicoPluginInterface.php +++ b/lib/PicoPluginInterface.php @@ -26,7 +26,7 @@ * @author Daniel Rudolf * @link http://picocms.org * @license http://opensource.org/licenses/MIT The MIT License - * @version 2.1 + * @version 3.0 */ interface PicoPluginInterface { diff --git a/lib/PicoTwigExtension.php b/lib/PicoTwigExtension.php index 098811024..d87a6e11a 100644 --- a/lib/PicoTwigExtension.php +++ b/lib/PicoTwigExtension.php @@ -16,7 +16,7 @@ * @author Daniel Rudolf * @link http://picocms.org * @license http://opensource.org/licenses/MIT The MIT License - * @version 2.1 + * @version 3.0 */ class PicoTwigExtension extends Twig_Extension { diff --git a/plugins/DummyPlugin.php b/plugins/DummyPlugin.php index 415103bdc..6541f4e7a 100644 --- a/plugins/DummyPlugin.php +++ b/plugins/DummyPlugin.php @@ -19,7 +19,7 @@ * @author Daniel Rudolf * @link http://picocms.org * @license http://opensource.org/licenses/MIT The MIT License - * @version 2.1 + * @version 3.0 */ class DummyPlugin extends AbstractPicoPlugin { From a053a72a12388e1ef7cfcddd4ac3a5bf7cade7bd Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 29 Mar 2020 14:39:02 +0200 Subject: [PATCH 02/75] Update dependencies, Pico now requires PHP 7.0.8+ Pico now depends on Twig 2.12, Symfony YAML 3.4, Parsedown 1.7.4 and Parsedown Extra 0.8.1. --- composer.json | 10 +++++----- index.php.dist | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 02b45aa72..6e56b5c8d 100644 --- a/composer.json +++ b/composer.json @@ -31,11 +31,11 @@ "source": "https://github.com/picocms/Pico" }, "require": { - "php": ">=5.3.6", - "twig/twig": "^1.36", - "symfony/yaml" : "^2.8", - "erusev/parsedown": "1.8.0-beta-7", - "erusev/parsedown-extra": "0.8.0-beta-1" + "php": "^7.0.8", + "twig/twig": "^2.12", + "symfony/yaml" : "^3.4", + "erusev/parsedown": "1.7.4", + "erusev/parsedown-extra": "0.8.1" }, "suggest": { "picocms/pico-theme": "Pico requires a theme to actually display the contents of your website. This is Pico's official default theme.", diff --git a/index.php.dist b/index.php.dist index a1f981dd5..46c6ddb76 100644 --- a/index.php.dist +++ b/index.php.dist @@ -11,8 +11,8 @@ */ // check PHP platform requirements -if (PHP_VERSION_ID < 50306) { - die('Pico requires PHP 5.3.6 or above to run'); +if (PHP_VERSION_ID < 70008) { + die('Pico requires PHP 7.0.8 or above to run'); } if (!extension_loaded('dom')) { die("Pico requires the PHP extension 'dom' to run"); From 2ee41e9a8d29756e338c6533e2b9ece010869ebc Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 29 Mar 2020 14:57:08 +0200 Subject: [PATCH 03/75] Update Pico::VERSION and Pico::VERSION_ID --- lib/Pico.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Pico.php b/lib/Pico.php index 387de4079..6455659aa 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -49,14 +49,14 @@ class Pico * * @var string */ - const VERSION = '2.1.1'; + const VERSION = '3.0.0-alpha.1'; /** * Pico version ID * * @var int */ - const VERSION_ID = 20101; + const VERSION_ID = 30000; /** * Pico API version From 727d8a12c0b372b1f101686f0d68d0d6bc760fb3 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 29 Mar 2020 14:58:00 +0200 Subject: [PATCH 04/75] Fix Travis CI trying to build Pico 3.0 on PHP 5.x --- .travis.yml | 17 ++++------------- composer.json | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 12bd14954..8aa14fc84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,14 +10,6 @@ cache: jobs: include: # Test stage - - php: 5.3 - dist: precise - - php: 5.4 - dist: trusty - - php: 5.5 - dist: trusty - - php: 5.6 - dist: xenial - php: 7.0 dist: xenial - php: 7.1 @@ -25,15 +17,14 @@ jobs: - php: 7.3 - php: 7.4 - php: nightly - - php: hhvm-3.24 # until Dec 2018 - php: hhvm-3.27 # until Sep 2019 - php: hhvm-3.30 # until Nov 2019 # Branch deployment stage - stage: deploy-branch if: type == "push" && tag IS blank - php: 5.3 - dist: precise + php: 7.0 + dist: xenial install: - '[[ ",$DEPLOY_PHPDOC_BRANCHES," == *,"$TRAVIS_BRANCH",* ]] || travis_terminate 0' - install.sh --deploy @@ -43,8 +34,8 @@ jobs: # Release deployment stage - stage: deploy-release if: tag IS present - php: 5.3 - dist: precise + php: 7.0 + dist: xenial install: - install.sh --deploy script: diff --git a/composer.json b/composer.json index 6e56b5c8d..de1bcfbe0 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "source": "https://github.com/picocms/Pico" }, "require": { - "php": "^7.0.8", + "php": ">=7.0.8", "twig/twig": "^2.12", "symfony/yaml" : "^3.4", "erusev/parsedown": "1.7.4", From b6a03431182aaefe6a84c5fd93260ca3880ee586 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 29 Mar 2020 15:07:32 +0200 Subject: [PATCH 05/75] Update CHANGELOG.md --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96784d87f..46768b090 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,17 @@ Pico Changelog `PicoDeprecated`'s changelog. Please note that BC-breaking changes are only possible with a new major version. +### Version 3.0.0-alpha.1 +Released: 2020-03-29 + +``` +* [New] Kick-start development of Pico 3.0 +* [Changed] Require PHP 7.0.8+ +* [Changed] Update dependencies: Twig 2.12, Symfony YAML 3.4, Parsedown 1.7.4 + and Parsedown Extra 0.8.1; this is just an interim step, we'll + update to Twig 3.0+ and Symfony YAML 5.0+ later +``` + ### Version 2.1.1 Released: 2019-12-31 From 039dd4edb21386289ce1903a376e6a44b6a0d558 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 29 Mar 2020 15:33:14 +0200 Subject: [PATCH 06/75] Version 3.0.0-alpha.1 ``` * [New] Kick-start development of Pico 3.0 * [Changed] Require PHP 7.0.8+ * [Changed] Update dependencies: Twig 2.12, Symfony YAML 3.4, Parsedown 1.7.4 and Parsedown Extra 0.8.1; this is just an interim step, we'll update to Twig 3.0+ and Symfony YAML 5.0+ later ``` From 812ae5c21548905e308f002bc6d97a042ea09aad Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 10 Apr 2020 21:09:00 +0200 Subject: [PATCH 07/75] Move Pico to picocms\Pico\ namespace --- composer.json | 6 +- index.php | 2 +- index.php.dist | 2 +- ...tractPicoPlugin.php => AbstractPlugin.php} | 62 +++++----- lib/Pico.php | 108 +++++++++--------- ...luginInterface.php => PluginInterface.php} | 14 ++- ...icoTwigExtension.php => TwigExtension.php} | 68 +++++------ plugins/DummyPlugin.php | 9 +- 8 files changed, 140 insertions(+), 131 deletions(-) rename lib/{AbstractPicoPlugin.php => AbstractPlugin.php} (86%) rename lib/{PicoPluginInterface.php => PluginInterface.php} (91%) rename lib/{PicoTwigExtension.php => TwigExtension.php} (88%) diff --git a/composer.json b/composer.json index de1bcfbe0..2dfe2a4ec 100644 --- a/composer.json +++ b/composer.json @@ -43,10 +43,8 @@ "picocms/composer-installer": "This Composer plugin is responsible for installing Pico plugins and themes using the Composer package manager." }, "autoload": { - "psr-0": { - "Pico": "lib/", - "PicoPluginInterface": "lib/", - "AbstractPicoPlugin": "lib/" + "psr-4": { + "picocms\\Pico\\": "lib/" } }, "extra": { diff --git a/index.php b/index.php index 0d13d6d3a..149ffb62a 100644 --- a/index.php +++ b/index.php @@ -26,7 +26,7 @@ } // instance Pico -$pico = new Pico( +$pico = new \picocms\Pico\Pico( __DIR__, // root dir 'config/', // config dir 'plugins/', // plugins dir diff --git a/index.php.dist b/index.php.dist index 46c6ddb76..766153015 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 Pico( +$pico = new \picocms\Pico\Pico( __DIR__, // root dir 'config/', // config dir 'plugins/', // plugins dir diff --git a/lib/AbstractPicoPlugin.php b/lib/AbstractPlugin.php similarity index 86% rename from lib/AbstractPicoPlugin.php rename to lib/AbstractPlugin.php index 4cc318bdf..67b632bf4 100644 --- a/lib/AbstractPicoPlugin.php +++ b/lib/AbstractPlugin.php @@ -10,25 +10,27 @@ * License-Filename: LICENSE */ +namespace picocms\Pico; + /** * Abstract class to extend from when implementing a Pico plugin * - * Please refer to {@see PicoPluginInterface} for more information about how - * to develop a plugin for Pico. + * Please refer to {@see PluginInterface} for more information about how to + * develop a plugin for Pico. * - * @see PicoPluginInterface + * @see PluginInterface * * @author Daniel Rudolf * @link http://picocms.org * @license http://opensource.org/licenses/MIT The MIT License * @version 3.0 */ -abstract class AbstractPicoPlugin implements PicoPluginInterface +abstract class AbstractPlugin implements PluginInterface { /** * Current instance of Pico * - * @see PicoPluginInterface::getPico() + * @see PluginInterface::getPico() * @var Pico */ protected $pico; @@ -36,8 +38,8 @@ abstract class AbstractPicoPlugin implements PicoPluginInterface /** * Boolean indicating if this plugin is enabled (TRUE) or disabled (FALSE) * - * @see PicoPluginInterface::isEnabled() - * @see PicoPluginInterface::setEnabled() + * @see PluginInterface::isEnabled() + * @see PluginInterface::setEnabled() * @var bool|null */ protected $enabled; @@ -45,7 +47,7 @@ abstract class AbstractPicoPlugin implements PicoPluginInterface /** * Boolean indicating if this plugin was ever enabled/disabled manually * - * @see PicoPluginInterface::isStatusChanged() + * @see PluginInterface::isStatusChanged() * @var bool */ protected $statusChanged = false; @@ -53,7 +55,7 @@ abstract class AbstractPicoPlugin implements PicoPluginInterface /** * Boolean indicating whether this plugin matches Pico's API version * - * @see AbstractPicoPlugin::checkCompatibility() + * @see AbstractPlugin::checkCompatibility() * @var bool|null */ protected $nativePlugin; @@ -61,8 +63,8 @@ abstract class AbstractPicoPlugin implements PicoPluginInterface /** * List of plugins which this plugin depends on * - * @see AbstractPicoPlugin::checkDependencies() - * @see PicoPluginInterface::getDependencies() + * @see AbstractPlugin::checkDependencies() + * @see PluginInterface::getDependencies() * @var string[] */ protected $dependsOn = array(); @@ -70,8 +72,8 @@ abstract class AbstractPicoPlugin implements PicoPluginInterface /** * List of plugin which depend on this plugin * - * @see AbstractPicoPlugin::checkDependants() - * @see PicoPluginInterface::getDependants() + * @see AbstractPlugin::checkDependants() + * @see PluginInterface::getDependants() * @var object[]|null */ protected $dependants; @@ -122,7 +124,7 @@ protected function configEnabled() // otherwise the plugin needs to be enabled manually try { $this->setEnabled(true, false, true); - } catch (RuntimeException $e) { + } catch (\RuntimeException $e) { $this->enabled = false; } } @@ -196,7 +198,7 @@ public function getPluginConfig($configName = null, $default = null) /** * Passes all not satisfiable method calls to Pico * - * @see PicoPluginInterface::getPico() + * @see PluginInterface::getPico() * * @deprecated 2.1.0 * @@ -211,7 +213,7 @@ public function __call($methodName, array $params) return call_user_func_array(array($this->getPico(), $methodName), $params); } - throw new BadMethodCallException( + throw new \BadMethodCallException( 'Call to undefined method ' . get_class($this->getPico()) . '::' . $methodName . '() ' . 'through ' . get_called_class() . '::__call()' ); @@ -220,37 +222,37 @@ public function __call($methodName, array $params) /** * Enables all plugins which this plugin depends on * - * @see PicoPluginInterface::getDependencies() + * @see PluginInterface::getDependencies() * * @param bool $recursive enable required plugins automatically * - * @throws RuntimeException thrown when a dependency fails + * @throws \RuntimeException thrown when a dependency fails */ protected function checkDependencies($recursive) { foreach ($this->getDependencies() as $pluginName) { try { $plugin = $this->getPico()->getPlugin($pluginName); - } catch (RuntimeException $e) { - throw new RuntimeException( + } catch (\RuntimeException $e) { + throw new \RuntimeException( "Unable to enable plugin '" . get_called_class() . "': " . "Required plugin '" . $pluginName . "' not found" ); } // plugins which don't implement PicoPluginInterface are always enabled - if (($plugin instanceof PicoPluginInterface) && !$plugin->isEnabled()) { + if (($plugin instanceof PluginInterface) && !$plugin->isEnabled()) { if ($recursive) { if (!$plugin->isStatusChanged()) { $plugin->setEnabled(true, true, true); } else { - throw new RuntimeException( + throw new \RuntimeException( "Unable to enable plugin '" . get_called_class() . "': " . "Required plugin '" . $pluginName . "' was disabled manually" ); } } else { - throw new RuntimeException( + throw new \RuntimeException( "Unable to enable plugin '" . get_called_class() . "': " . "Required plugin '" . $pluginName . "' is disabled" ); @@ -270,11 +272,11 @@ public function getDependencies() /** * Disables all plugins which depend on this plugin * - * @see PicoPluginInterface::getDependants() + * @see PluginInterface::getDependants() * * @param bool $recursive disabled dependant plugins automatically * - * @throws RuntimeException thrown when a dependency fails + * @throws \RuntimeException thrown when a dependency fails */ protected function checkDependants($recursive) { @@ -286,7 +288,7 @@ protected function checkDependants($recursive) if (!$plugin->isStatusChanged()) { $plugin->setEnabled(false, true, true); } else { - throw new RuntimeException( + throw new \RuntimeException( "Unable to disable plugin '" . get_called_class() . "': " . "Required by manually enabled plugin '" . $pluginName . "'" ); @@ -296,7 +298,7 @@ protected function checkDependants($recursive) } else { $dependantsList = 'plugin' . ((count($dependants) > 1) ? 's' : '') . ' ' . "'" . implode("', '", array_keys($dependants)) . "'"; - throw new RuntimeException( + throw new \RuntimeException( "Unable to disable plugin '" . get_called_class() . "': " . "Required by " . $dependantsList ); @@ -313,7 +315,7 @@ public function getDependants() $this->dependants = array(); foreach ($this->getPico()->getPlugins() as $pluginName => $plugin) { // only plugins which implement PicoPluginInterface support dependencies - if ($plugin instanceof PicoPluginInterface) { + if ($plugin instanceof PluginInterface) { $dependencies = $plugin->getDependencies(); if (in_array(get_called_class(), $dependencies)) { $this->dependants[$pluginName] = $plugin; @@ -335,7 +337,7 @@ public function getDependants() * newer API versions, what requires some special (version specific) * precaution and is therefore usually not the case. * - * @throws RuntimeException thrown when the plugin's and Pico's API aren't + * @throws \RuntimeException thrown when the plugin's and Pico's API aren't * compatible */ protected function checkCompatibility() @@ -348,7 +350,7 @@ protected function checkCompatibility() $this->nativePlugin = ($pluginApiVersion === $picoApiVersion); if (!$this->nativePlugin && ($pluginApiVersion > $picoApiVersion)) { - throw new RuntimeException( + throw new \RuntimeException( "Unable to enable plugin '" . get_called_class() . "': The plugin's API (version " . $pluginApiVersion . ") isn't compatible with Pico's API (version " . $picoApiVersion . ")" ); diff --git a/lib/Pico.php b/lib/Pico.php index 6455659aa..4d8201569 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -16,6 +16,8 @@ * License-Filename: LICENSE */ +namespace picocms\Pico; + /** * Pico * @@ -147,7 +149,7 @@ class Pico /** * List of loaded plugins using the current API version * - * @var PicoPluginInterface[] + * @var PluginInterface[] */ protected $nativePlugins = array(); @@ -251,7 +253,7 @@ class Pico * Parsedown Extra instance used for markdown parsing * * @see Pico::getParsedown() - * @var Parsedown|null + * @var \Parsedown|null */ protected $parsedown; @@ -307,7 +309,7 @@ class Pico * Twig instance used for template parsing * * @see Pico::getTwig() - * @var Twig_Environment|null + * @var \Twig_Environment|null */ protected $twig; @@ -408,13 +410,13 @@ public function getThemesDir() * * @return string rendered Pico contents * - * @throws Exception thrown when a irrecoverable error occurs + * @throws \Exception thrown when a irrecoverable error occurs */ public function run() { // check lock if ($this->locked) { - throw new LogicException('You cannot run the same Pico instance multiple times'); + throw new \LogicException('You cannot run the same Pico instance multiple times'); } // lock Pico @@ -431,7 +433,7 @@ public function run() // check content dir if (!is_dir($this->getConfig('content_dir'))) { - throw new RuntimeException('Invalid content directory "' . $this->getConfig('content_dir') . '"'); + throw new \RuntimeException('Invalid content directory "' . $this->getConfig('content_dir') . '"'); } // load theme @@ -542,7 +544,7 @@ public function run() * @see Pico::getPlugin() * @see Pico::getPlugins() * - * @throws RuntimeException thrown when a plugin couldn't be loaded + * @throws \RuntimeException thrown when a plugin couldn't be loaded */ protected function loadPlugins() { @@ -553,7 +555,7 @@ protected function loadPlugins() } if (!isset($this->plugins['PicoDeprecated']) && (count($this->plugins) !== count($this->nativePlugins))) { - throw new RuntimeException( + throw new \RuntimeException( "Plugins using an older API than version " . static::API_VERSION . " found, " . "but PicoDeprecated isn't loaded" ); @@ -574,7 +576,7 @@ protected function loadPlugins() * * @return string[] installer names of the loaded plugins * - * @throws RuntimeException thrown when a plugin couldn't be loaded + * @throws \RuntimeException thrown when a plugin couldn't be loaded */ protected function loadComposerPlugins(array $pluginBlacklist = array()) { @@ -601,8 +603,8 @@ protected function loadComposerPlugins(array $pluginBlacklist = array()) continue; } - if (!($plugin instanceof PicoPluginInterface)) { - throw new RuntimeException( + if (!($plugin instanceof PluginInterface)) { + throw new \RuntimeException( "Unable to load plugin '" . $className . "' via 'vendor/pico-plugin.php': " . "Plugins installed by composer must implement 'PicoPluginInterface'" ); @@ -642,7 +644,7 @@ protected function loadComposerPlugins(array $pluginBlacklist = array()) * * @param string[] $pluginBlacklist class names of plugins not to load * - * @throws RuntimeException thrown when a plugin couldn't be loaded + * @throws \RuntimeException thrown when a plugin couldn't be loaded */ protected function loadLocalPlugins(array $pluginBlacklist = array()) { @@ -668,7 +670,7 @@ protected function loadLocalPlugins(array $pluginBlacklist = array()) $pluginFile = $file . '/' . $className . '.php'; if (!is_file($this->getPluginsDir() . $pluginFile)) { - throw new RuntimeException( + throw new \RuntimeException( "Unable to load plugin '" . $className . "' from '" . $pluginFile . "': File not found" ); } @@ -676,7 +678,7 @@ protected function loadLocalPlugins(array $pluginBlacklist = array()) $className = preg_replace('/^[0-9]+-/', '', substr($file, 0, -4)); $pluginFile = $file; } else { - throw new RuntimeException("Unable to load plugin from '" . $file . "': Not a valid plugin file"); + throw new \RuntimeException("Unable to load plugin from '" . $file . "': Not a valid plugin file"); } if (isset($this->plugins[$className]) || isset($pluginBlacklist[$className])) { @@ -692,13 +694,13 @@ protected function loadLocalPlugins(array $pluginBlacklist = array()) $this->plugins[$className] = $plugin; - if ($plugin instanceof PicoPluginInterface) { + if ($plugin instanceof PluginInterface) { if (defined($className . '::API_VERSION') && ($className::API_VERSION >= static::API_VERSION)) { $this->nativePlugins[$className] = $plugin; } } } else { - throw new RuntimeException( + throw new \RuntimeException( "Unable to load plugin '" . $className . "' from '" . $pluginFile . "': Plugin class not found" ); } @@ -708,11 +710,11 @@ protected function loadLocalPlugins(array $pluginBlacklist = array()) /** * Manually loads a plugin * - * 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 + * 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 * otherwise, and you MUST NOT rely on {@see PicoDeprecated} to maintain * backward compatibility in such cases. * @@ -730,12 +732,12 @@ protected function loadLocalPlugins(array $pluginBlacklist = array()) * @see Pico::getPlugin() * @see Pico::getPlugins() * - * @param PicoPluginInterface|string $plugin either the class name of a - * plugin to instantiate or a plugin instance + * @param PluginInterface|string $plugin either the class name of a plugin + * to instantiate or a plugin instance * - * @return PicoPluginInterface instance of the loaded plugin + * @return PluginInterface instance of the loaded plugin * - * @throws RuntimeException thrown when the plugin couldn't be loaded + * @throws \RuntimeException thrown when the plugin couldn't be loaded */ public function loadPlugin($plugin) { @@ -744,14 +746,14 @@ public function loadPlugin($plugin) if (class_exists($className)) { $plugin = new $className($this); } else { - throw new RuntimeException("Unable to load plugin '" . $className . "': Class not found"); + throw new \RuntimeException("Unable to load plugin '" . $className . "': Class not found"); } } $className = get_class($plugin); - if (!($plugin instanceof PicoPluginInterface)) { - throw new RuntimeException( + if (!($plugin instanceof PluginInterface)) { + throw new \RuntimeException( "Unable to load plugin '" . $className . "': " . "Manually loaded plugins must implement 'PicoPluginInterface'" ); @@ -820,7 +822,7 @@ protected function sortPlugins() $visitedPlugins[$pluginName] = true; $dependencies = array(); - if ($plugin instanceof PicoPluginInterface) { + if ($plugin instanceof PluginInterface) { $dependencies = $plugin->getDependencies(); } if (!isset($nativePlugins[$pluginName])) { @@ -857,8 +859,8 @@ protected function sortPlugins() /** * Returns the instance of a named plugin * - * Plugins SHOULD implement {@see PicoPluginInterface}, but you MUST NOT - * rely on it. For more information see {@see PicoPluginInterface}. + * Plugins SHOULD implement {@see PluginInterface}, but you MUST NOT rely + * on it. For more information see {@see PluginInterface}. * * @see Pico::loadPlugins() * @see Pico::getPlugins() @@ -867,7 +869,7 @@ protected function sortPlugins() * * @return object instance of the plugin * - * @throws RuntimeException thrown when the plugin wasn't found + * @throws \RuntimeException thrown when the plugin wasn't found */ public function getPlugin($pluginName) { @@ -875,7 +877,7 @@ public function getPlugin($pluginName) return $this->plugins[$pluginName]; } - throw new RuntimeException("Missing plugin '" . $pluginName . "'"); + throw new \RuntimeException("Missing plugin '" . $pluginName . "'"); } /** @@ -1035,12 +1037,12 @@ protected function loadConfig() * * @param array $config array with config variables * - * @throws LogicException thrown if Pico already started processing + * @throws \LogicException thrown if Pico already started processing */ public function setConfig(array $config) { if ($this->locked) { - throw new LogicException("You cannot modify Pico's config after processing has started"); + throw new \LogicException("You cannot modify Pico's config after processing has started"); } $this->config = $config; @@ -1141,7 +1143,7 @@ protected function loadTheme() // check for theme compatibility if (!isset($this->plugins['PicoDeprecated']) && ($this->themeApiVersion < static::API_VERSION)) { - throw new RuntimeException( + throw new \RuntimeException( 'Current theme "' . $this->theme . '" uses API version ' . $this->themeApiVersion . ', but Pico ' . 'provides API version ' . static::API_VERSION . ' and PicoDeprecated isn\'t loaded' ); @@ -1542,12 +1544,12 @@ public function getFileMeta() * This method triggers the `onParsedownRegistered` event when the * Parsedown markdown parser wasn't initiated yet. * - * @return Parsedown Parsedown markdown parser + * @return \Parsedown Parsedown markdown parser */ public function getParsedown() { if ($this->parsedown === null) { - $className = $this->config['content_config']['extra'] ? 'ParsedownExtra' : 'Parsedown'; + $className = $this->config['content_config']['extra'] ? '\ParsedownExtra' : '\Parsedown'; $this->parsedown = new $className(); $this->parsedown->setBreaksEnabled((bool) $this->config['content_config']['breaks']); @@ -2075,25 +2077,25 @@ public function getPageTree() * 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 PicoTwigExtension} Twig extension. + * {@see TwigExtension} Twig extension. * * @see Pico::getTwig() * @see http://twig.sensiolabs.org/ Twig website * @see https://github.com/twigphp/Twig Twig on GitHub * - * @return Twig_Environment|null Twig template engine + * @return \Twig_Environment|null Twig template engine */ public function getTwig() { if ($this->twig === null) { $twigConfig = $this->getConfig('twig_config'); - $twigLoader = new Twig_Loader_Filesystem($this->getThemesDir() . $this->getTheme()); - $this->twig = new Twig_Environment($twigLoader, $twigConfig); - $this->twig->addExtension(new PicoTwigExtension($this)); + $twigLoader = new \Twig_Loader_Filesystem($this->getThemesDir() . $this->getTheme()); + $this->twig = new \Twig_Environment($twigLoader, $twigConfig); + $this->twig->addExtension(new TwigExtension($this)); if (!empty($twigConfig['debug'])) { - $this->twig->addExtension(new Twig_Extension_Debug()); + $this->twig->addExtension(new \Twig_Extension_Debug()); } // register content filter @@ -2101,7 +2103,7 @@ public function getTwig() // this is the reason why we can't register this filter as part of PicoTwigExtension $pico = $this; $pages = &$this->pages; - $this->twig->addFilter(new Twig_SimpleFilter( + $this->twig->addFilter(new \Twig_SimpleFilter( 'content', function ($page) use ($pico, &$pages) { if (isset($pages[$page])) { @@ -2142,7 +2144,7 @@ protected function getTwigVariables() 'theme_url' => $this->getConfig('themes_url') . $this->getTheme(), 'site_title' => $this->getConfig('site_title'), 'meta' => $this->meta, - 'content' => new Twig_Markup($this->content, 'UTF-8'), + 'content' => new \Twig_Markup($this->content, 'UTF-8'), 'pages' => $this->pages, 'previous_page' => $this->previousPage, 'current_page' => $this->currentPage, @@ -2281,14 +2283,14 @@ public function isDebugModeEnabled() * * @return string URL * - * @throws InvalidArgumentException thrown when invalid arguments got passed + * @throws \InvalidArgumentException thrown when invalid arguments got passed */ public function getPageUrl($page, $queryData = null, $dropIndex = true) { if (is_array($queryData)) { $queryData = http_build_query($queryData, '', '&'); } elseif (($queryData !== null) && !is_string($queryData)) { - throw new InvalidArgumentException( + throw new \InvalidArgumentException( 'Argument 2 passed to ' . __METHOD__ . ' must be of the type array or string, ' . (is_object($queryData) ? get_class($queryData) : gettype($queryData)) . ' given' ); @@ -2682,7 +2684,7 @@ public function getAbsolutePath($path, $basePath = null, $endSlash = true) * * @return string normalized path * - * @throws UnexpectedValueException thrown when a absolute path is passed + * @throws \UnexpectedValueException thrown when a absolute path is passed * although absolute paths aren't allowed */ public function getNormalizedPath($path, $allowAbsolutePath = false, $endSlash = true) @@ -2701,7 +2703,7 @@ public function getNormalizedPath($path, $allowAbsolutePath = false, $endSlash = } if ($absolutePath && !$allowAbsolutePath) { - throw new UnexpectedValueException( + throw new \UnexpectedValueException( 'Argument 1 passed to ' . __METHOD__ . ' must be a relative path, absolute path "' . $path . '" given' ); } @@ -2736,7 +2738,7 @@ public function getNormalizedPath($path, $allowAbsolutePath = false, $endSlash = * @param string $url relative or absolute URL * @param string $baseUrl treat relative URLs relative to the given URL; * defaults to Pico::getBaseUrl() - * @param bool $endSlash whether to add a trailing slash to the absolute + * @param bool $endSlash whether to add a trailing slash to the absolute * URL or not (defaults to TRUE) * * @return string absolute URL @@ -2761,8 +2763,8 @@ public function getAbsoluteUrl($url, $baseUrl = null, $endSlash = true) * * You MUST NOT trigger events of Pico's core with a plugin! * - * @see PicoPluginInterface - * @see AbstractPicoPlugin + * @see PluginInterface + * @see AbstractPlugin * @see DummyPlugin * * @param string $eventName name of the event to trigger diff --git a/lib/PicoPluginInterface.php b/lib/PluginInterface.php similarity index 91% rename from lib/PicoPluginInterface.php rename to lib/PluginInterface.php index 323be862c..ec6974577 100644 --- a/lib/PicoPluginInterface.php +++ b/lib/PluginInterface.php @@ -10,6 +10,8 @@ * License-Filename: LICENSE */ +namespace picocms\Pico; + /** * Common interface for Pico plugins * @@ -28,7 +30,7 @@ * @license http://opensource.org/licenses/MIT The MIT License * @version 3.0 */ -interface PicoPluginInterface +interface PluginInterface { /** * Handles a event that was triggered by Pico @@ -41,8 +43,8 @@ public function handleEvent($eventName, array $params); /** * Enables or disables this plugin * - * @see PicoPluginInterface::isEnabled() - * @see PicoPluginInterface::isStatusChanged() + * @see PluginInterface::isEnabled() + * @see PluginInterface::isStatusChanged() * * @param bool $enabled enable (TRUE) or disable (FALSE) this plugin * @param bool $recursive when TRUE, enable or disable recursively. @@ -54,7 +56,7 @@ public function handleEvent($eventName, array $params); * @param bool $auto enable or disable to fulfill a dependency. This * parameter is optional and defaults to FALSE. * - * @throws RuntimeException thrown when a dependency fails + * @throws \RuntimeException thrown when a dependency fails */ public function setEnabled($enabled, $recursive = true, $auto = false); @@ -65,7 +67,7 @@ public function setEnabled($enabled, $recursive = true, $auto = false); * wasn't triggered on all plugins yet. This method might even return NULL * then. The plugin's status might change later. * - * @see PicoPluginInterface::setEnabled() + * @see PluginInterface::setEnabled() * * @return bool|null plugin is enabled (TRUE) or disabled (FALSE) */ @@ -74,7 +76,7 @@ public function isEnabled(); /** * Returns TRUE if the plugin was ever enabled/disabled manually * - * @see PicoPluginInterface::setEnabled() + * @see PluginInterface::setEnabled() * * @return bool plugin is in its default state (TRUE), FALSE otherwise */ diff --git a/lib/PicoTwigExtension.php b/lib/TwigExtension.php similarity index 88% rename from lib/PicoTwigExtension.php rename to lib/TwigExtension.php index d87a6e11a..d726191f2 100644 --- a/lib/PicoTwigExtension.php +++ b/lib/TwigExtension.php @@ -10,6 +10,8 @@ * License-Filename: LICENSE */ +namespace picocms\Pico; + /** * Pico's Twig extension to implement additional filters * @@ -18,12 +20,12 @@ * @license http://opensource.org/licenses/MIT The MIT License * @version 3.0 */ -class PicoTwigExtension extends Twig_Extension +class TwigExtension extends \Twig_Extension { /** * Current instance of Pico * - * @see PicoTwigExtension::getPico() + * @see TwigExtension::getPico() * @var Pico */ private $pico; @@ -67,20 +69,20 @@ public function getName() * * @see Twig_ExtensionInterface::getFilters() * - * @return Twig_SimpleFilter[] array of Pico's Twig filters + * @return \Twig_SimpleFilter[] array of Pico's Twig filters */ public function getFilters() { return array( - 'markdown' => new Twig_SimpleFilter( + 'markdown' => new \Twig_SimpleFilter( 'markdown', array($this, 'markdownFilter'), array('is_safe' => array('html')) ), - 'map' => new Twig_SimpleFilter('map', array($this, 'mapFilter')), - 'sort_by' => new Twig_SimpleFilter('sort_by', array($this, 'sortByFilter')), - 'link' => new Twig_SimpleFilter('link', array($this->pico, 'getPageUrl')), - 'url' => new Twig_SimpleFilter('url', array($this->pico, 'substituteUrl')) + 'map' => new \Twig_SimpleFilter('map', array($this, 'mapFilter')), + 'sort_by' => new \Twig_SimpleFilter('sort_by', array($this, 'sortByFilter')), + 'link' => new \Twig_SimpleFilter('link', array($this->pico, 'getPageUrl')), + 'url' => new \Twig_SimpleFilter('url', array($this->pico, 'substituteUrl')) ); } @@ -89,14 +91,14 @@ public function getFilters() * * @see Twig_ExtensionInterface::getFunctions() * - * @return Twig_SimpleFunction[] array of Pico's Twig functions + * @return \Twig_SimpleFunction[] array of Pico's Twig functions */ public function getFunctions() { return array( - 'url_param' => new Twig_SimpleFunction('url_param', array($this, 'urlParamFunction')), - 'form_param' => new Twig_SimpleFunction('form_param', array($this, 'formParamFunction')), - 'pages' => new Twig_SimpleFunction('pages', array($this, 'pagesFunction')) + 'url_param' => new \Twig_SimpleFunction('url_param', array($this, 'urlParamFunction')), + 'form_param' => new \Twig_SimpleFunction('form_param', array($this, 'formParamFunction')), + 'pages' => new \Twig_SimpleFunction('pages', array($this, 'pagesFunction')) ); } @@ -129,19 +131,19 @@ public function markdownFilter($markdown, array $meta = array(), $singleLine = f * This method is registered as the Twig `map` filter. You can use this * filter to e.g. get all page titles (`{{ pages|map("title") }}`). * - * @param array|Traversable $var variable to map - * @param mixed $mapKeyPath key to map; either a scalar or a + * @param array|\Traversable $var variable to map + * @param mixed $mapKeyPath key to map; either a scalar or a * array interpreted as key path (i.e. ['foo', 'bar'] will return all * $item['foo']['bar'] values) * * @return array mapped values * - * @throws Twig_Error_Runtime + * @throws \Twig_Error_Runtime */ public function mapFilter($var, $mapKeyPath) { - if (!is_array($var) && (!is_object($var) || !($var instanceof Traversable))) { - throw new Twig_Error_Runtime(sprintf( + if (!is_array($var) && (!is_object($var) || !($var instanceof \Traversable))) { + throw new \Twig_Error_Runtime(sprintf( 'The map filter only works with arrays or "Traversable", got "%s"', is_object($var) ? get_class($var) : gettype($var) )); @@ -166,11 +168,11 @@ public function mapFilter($var, $mapKeyPath) * always sorted in ascending order, apply Twigs `reverse` filter to * achieve a descending order. * - * @param array|Traversable $var variable to sort - * @param mixed $sortKeyPath key to use for sorting; either + * @param array|\Traversable $var variable to sort + * @param mixed $sortKeyPath key to use for sorting; either * a scalar or a array interpreted as key path (i.e. ['foo', 'bar'] * will sort $var by $item['foo']['bar']) - * @param string $fallback specify what to do with items + * @param string $fallback specify what to do with items * which don't contain the specified sort key; use "bottom" (default) * to move these items to the end of the sorted array, "top" to rank * them first, "keep" to keep the original order, or "remove" to remove @@ -178,20 +180,20 @@ public function mapFilter($var, $mapKeyPath) * * @return array sorted array * - * @throws Twig_Error_Runtime + * @throws \Twig_Error_Runtime */ public function sortByFilter($var, $sortKeyPath, $fallback = 'bottom') { - if (is_object($var) && ($var instanceof Traversable)) { + if (is_object($var) && ($var instanceof \Traversable)) { $var = iterator_to_array($var, true); } elseif (!is_array($var)) { - throw new Twig_Error_Runtime(sprintf( + throw new \Twig_Error_Runtime(sprintf( 'The sort_by filter only works with arrays or "Traversable", got "%s"', is_object($var) ? get_class($var) : gettype($var) )); } if (($fallback !== 'top') && ($fallback !== 'bottom') && ($fallback !== 'keep') && ($fallback !== "remove")) { - throw new Twig_Error_Runtime( + throw new \Twig_Error_Runtime( 'The sort_by filter only supports the "top", "bottom", "keep" and "remove" fallbacks' ); } @@ -243,10 +245,10 @@ public function sortByFilter($var, $sortKeyPath, $fallback = 'bottom') * Returns the value of a variable item specified by a scalar key or a * arbitrary deep sub-key using a key path * - * @param array|Traversable|ArrayAccess|object $var base variable - * @param mixed $keyPath scalar key or a - * array interpreted as key path (when passing e.g. ['foo', 'bar'], - * the method will return $var['foo']['bar']) specifying the value + * @param array|\Traversable|\ArrayAccess|object $var base variable + * @param mixed $keyPath scalar key or a + * array interpreted as key path (when passing e.g. ['foo', 'bar'], the + * method will return $var['foo']['bar']) specifying the value * * @return mixed the requested value or NULL when the given key or key path * didn't match @@ -261,9 +263,9 @@ public static function getKeyOfVar($var, $keyPath) foreach ($keyPath as $key) { if (is_object($var)) { - if ($var instanceof ArrayAccess) { + if ($var instanceof \ArrayAccess) { // use ArrayAccess, see below - } elseif ($var instanceof Traversable) { + } elseif ($var instanceof \Traversable) { $var = iterator_to_array($var); } elseif (isset($var->{$key})) { $var = $var->{$key}; @@ -272,7 +274,7 @@ public static function getKeyOfVar($var, $keyPath) try { $var = call_user_func(array($var, 'get' . ucfirst($key))); continue; - } catch (BadMethodCallException $e) { + } catch (\BadMethodCallException $e) { return null; } } else { @@ -421,7 +423,7 @@ public function formParamFunction($name, $filter = '', $options = null, $flags = * * @return array[] the data of the matched pages * - * @throws Twig_Error_Runtime + * @throws \Twig_Error_Runtime */ public function pagesFunction($start = '', $depth = 0, $depthOffset = 0, $offset = 1) { @@ -443,7 +445,7 @@ public function pagesFunction($start = '', $depth = 0, $depthOffset = 0, $offset $depthOffset = $depthOffset + $offset; if (($depth !== null) && ($depth < 0)) { - throw new Twig_Error_Runtime('The pages function doesn\'t support negative depths'); + throw new \Twig_Error_Runtime('The pages function doesn\'t support negative depths'); } $pageTree = $this->getPico()->getPageTree(); diff --git a/plugins/DummyPlugin.php b/plugins/DummyPlugin.php index 6541f4e7a..99bf72e65 100644 --- a/plugins/DummyPlugin.php +++ b/plugins/DummyPlugin.php @@ -10,6 +10,9 @@ * License-Filename: LICENSE */ +use picocms\Pico\AbstractPlugin; +use picocms\Pico\Pico; + /** * Pico dummy plugin - a template for plugins * @@ -21,7 +24,7 @@ * @license http://opensource.org/licenses/MIT The MIT License * @version 3.0 */ -class DummyPlugin extends AbstractPicoPlugin +class DummyPlugin extends AbstractPlugin { /** * API version used by this plugin @@ -52,7 +55,7 @@ class DummyPlugin extends AbstractPicoPlugin * No matter what, the user can always explicitly enable or disable this * plugin in Pico's config. * - * @see AbstractPicoPlugin::$enabled + * @see AbstractPlugin::$enabled * @var bool|null */ protected $enabled = false; @@ -63,7 +66,7 @@ class DummyPlugin extends AbstractPicoPlugin * If your plugin doesn't depend on any other plugin, remove this class * property. * - * @see AbstractPicoPlugin::$dependsOn + * @see AbstractPlugin::$dependsOn * @var string[] */ protected $dependsOn = array(); From b1a58b9300a7d3f972dec25c6c35374ea2d235e8 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 10 Apr 2020 21:28:48 +0200 Subject: [PATCH 08/75] Update code styling to PHP 7.0+ This commit includes no functional changes. --- index.php | 2 +- index.php.dist | 2 +- lib/AbstractPlugin.php | 10 +-- lib/Pico.php | 189 ++++++++++++++++++++--------------------- lib/TwigExtension.php | 48 +++++------ 5 files changed, 124 insertions(+), 127 deletions(-) diff --git a/index.php b/index.php index 149ffb62a..83d112f57 100644 --- a/index.php +++ b/index.php @@ -34,7 +34,7 @@ ); // override configuration? -//$pico->setConfig(array()); +//$pico->setConfig([]); // run application echo $pico->run(); diff --git a/index.php.dist b/index.php.dist index 766153015..3dc407027 100644 --- a/index.php.dist +++ b/index.php.dist @@ -33,7 +33,7 @@ $pico = new \picocms\Pico\Pico( ); // override configuration? -//$pico->setConfig(array()); +//$pico->setConfig([]); // run application echo $pico->run(); diff --git a/lib/AbstractPlugin.php b/lib/AbstractPlugin.php index 67b632bf4..a8c6725e1 100644 --- a/lib/AbstractPlugin.php +++ b/lib/AbstractPlugin.php @@ -67,7 +67,7 @@ abstract class AbstractPlugin implements PluginInterface * @see PluginInterface::getDependencies() * @var string[] */ - protected $dependsOn = array(); + protected $dependsOn = []; /** * List of plugin which depend on this plugin @@ -100,7 +100,7 @@ public function handleEvent($eventName, array $params) if ($this->isEnabled() || ($eventName === 'onPluginsLoaded')) { if (method_exists($this, $eventName)) { - call_user_func_array(array($this, $eventName), $params); + call_user_func_array([ $this, $eventName ], $params); } } } @@ -186,7 +186,7 @@ public function getPico() */ public function getPluginConfig($configName = null, $default = null) { - $pluginConfig = $this->getPico()->getConfig(get_called_class(), array()); + $pluginConfig = $this->getPico()->getConfig(get_called_class(), []); if ($configName === null) { return $pluginConfig; @@ -210,7 +210,7 @@ public function getPluginConfig($configName = null, $default = null) public function __call($methodName, array $params) { if (method_exists($this->getPico(), $methodName)) { - return call_user_func_array(array($this->getPico(), $methodName), $params); + return call_user_func_array([ $this->getPico(), $methodName ], $params); } throw new \BadMethodCallException( @@ -312,7 +312,7 @@ protected function checkDependants($recursive) public function getDependants() { if ($this->dependants === null) { - $this->dependants = array(); + $this->dependants = []; foreach ($this->getPico()->getPlugins() as $pluginName => $plugin) { // only plugins which implement PicoPluginInterface support dependencies if ($plugin instanceof PluginInterface) { diff --git a/lib/Pico.php b/lib/Pico.php index 4d8201569..e3e54ded2 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -51,21 +51,21 @@ class Pico * * @var string */ - const VERSION = '3.0.0-alpha.1'; + public const VERSION = '3.0.0-alpha.1'; /** * Pico version ID * * @var int */ - const VERSION_ID = 30000; + public const VERSION_ID = 30000; /** * Pico API version * * @var int */ - const API_VERSION = 3; + public const API_VERSION = 3; /** * Sort files in alphabetical ascending order @@ -73,7 +73,7 @@ class Pico * @see Pico::getFiles() * @var int */ - const SORT_ASC = 0; + public const SORT_ASC = 0; /** * Sort files in alphabetical descending order @@ -81,7 +81,7 @@ class Pico * @see Pico::getFiles() * @var int */ - const SORT_DESC = 1; + public const SORT_DESC = 1; /** * Don't sort files @@ -89,7 +89,7 @@ class Pico * @see Pico::getFiles() * @var int */ - const SORT_NONE = 2; + public const SORT_NONE = 2; /** * Root directory of this Pico instance @@ -144,14 +144,14 @@ class Pico * @see Pico::getPlugins() * @var object[] */ - protected $plugins = array(); + protected $plugins = []; /** * List of loaded plugins using the current API version * * @var PluginInterface[] */ - protected $nativePlugins = array(); + protected $nativePlugins = []; /** * Boolean indicating whether Pico loads plugins from the filesystem @@ -425,11 +425,11 @@ public function run() // load plugins $this->loadPlugins(); $this->sortPlugins(); - $this->triggerEvent('onPluginsLoaded', array($this->plugins)); + $this->triggerEvent('onPluginsLoaded', [ $this->plugins ]); // load config $this->loadConfig(); - $this->triggerEvent('onConfigLoaded', array(&$this->config)); + $this->triggerEvent('onConfigLoaded', [ &$this->config ]); // check content dir if (!is_dir($this->getConfig('content_dir'))) { @@ -438,21 +438,18 @@ public function run() // load theme $this->theme = $this->config['theme']; - $this->triggerEvent('onThemeLoading', array(&$this->theme)); + $this->triggerEvent('onThemeLoading', [ &$this->theme ]); $this->loadTheme(); - $this->triggerEvent( - 'onThemeLoaded', - array($this->theme, $this->themeApiVersion, &$this->config['theme_config']) - ); + $this->triggerEvent('onThemeLoaded', [ $this->theme, $this->themeApiVersion, &$this->config['theme_config'] ]); // evaluate request url $this->evaluateRequestUrl(); - $this->triggerEvent('onRequestUrl', array(&$this->requestUrl)); + $this->triggerEvent('onRequestUrl', [ &$this->requestUrl ]); // discover requested file $this->requestFile = $this->resolveFilePath($this->requestUrl); - $this->triggerEvent('onRequestFile', array(&$this->requestFile)); + $this->triggerEvent('onRequestFile', [ &$this->requestFile ]); // load raw file content $this->triggerEvent('onContentLoading'); @@ -470,51 +467,51 @@ public function run() $this->rawContent = $this->load404Content($this->requestFile); $this->is404Content = true; - $this->triggerEvent('on404ContentLoaded', array(&$this->rawContent)); + $this->triggerEvent('on404ContentLoaded', [ &$this->rawContent ]); } - $this->triggerEvent('onContentLoaded', array(&$this->rawContent)); + $this->triggerEvent('onContentLoaded', [ &$this->rawContent ]); // parse file meta $this->triggerEvent('onMetaParsing'); $this->meta = $this->parseFileMeta($this->rawContent, $this->getMetaHeaders()); - $this->triggerEvent('onMetaParsed', array(&$this->meta)); + $this->triggerEvent('onMetaParsed', [ &$this->meta ]); // parse file content $this->triggerEvent('onContentParsing'); $markdown = $this->prepareFileContent($this->rawContent, $this->meta); - $this->triggerEvent('onContentPrepared', array(&$markdown)); + $this->triggerEvent('onContentPrepared', [ &$markdown ]); $this->content = $this->parseFileContent($markdown); - $this->triggerEvent('onContentParsed', array(&$this->content)); + $this->triggerEvent('onContentParsed', [ &$this->content ]); // read pages $this->triggerEvent('onPagesLoading'); $this->readPages(); - $this->triggerEvent('onPagesDiscovered', array(&$this->pages)); + $this->triggerEvent('onPagesDiscovered', [ &$this->pages ]); $this->sortPages(); - $this->triggerEvent('onPagesLoaded', array(&$this->pages)); + $this->triggerEvent('onPagesLoaded', [ &$this->pages ]); $this->discoverPageSiblings(); $this->discoverCurrentPage(); $this->triggerEvent( 'onCurrentPageDiscovered', - array(&$this->currentPage, &$this->previousPage, &$this->nextPage) + [ &$this->currentPage, &$this->previousPage, &$this->nextPage ] ); $this->buildPageTree(); - $this->triggerEvent('onPageTreeBuilt', array(&$this->pageTree)); + $this->triggerEvent('onPageTreeBuilt', [ &$this->pageTree ]); // render template $this->twigVariables = $this->getTwigVariables(); $this->twigTemplate = $this->getTwigTemplate(); - $this->triggerEvent('onPageRendering', array(&$this->twigTemplate, &$this->twigVariables)); + $this->triggerEvent('onPageRendering', [ &$this->twigTemplate, &$this->twigVariables ]); $output = $this->getTwig()->render($this->twigTemplate, $this->twigVariables); - $this->triggerEvent('onPageRendered', array(&$output)); + $this->triggerEvent('onPageRendered', [ &$output ]); return $output; } @@ -578,20 +575,20 @@ protected function loadPlugins() * * @throws \RuntimeException thrown when a plugin couldn't be loaded */ - protected function loadComposerPlugins(array $pluginBlacklist = array()) + protected function loadComposerPlugins(array $pluginBlacklist = []) { - $composerPlugins = array(); + $composerPlugins = []; if (is_file($this->getVendorDir() . 'vendor/pico-plugin.php')) { // composer root package - $composerPlugins = require($this->getVendorDir() . 'vendor/pico-plugin.php') ?: array(); + $composerPlugins = require($this->getVendorDir() . 'vendor/pico-plugin.php') ?: []; } elseif (is_file($this->getVendorDir() . '../../../vendor/pico-plugin.php')) { // composer dependency package - $composerPlugins = require($this->getVendorDir() . '../../../vendor/pico-plugin.php') ?: array(); + $composerPlugins = require($this->getVendorDir() . '../../../vendor/pico-plugin.php') ?: []; } $pluginBlacklist = array_fill_keys($pluginBlacklist, true); - $loadedPlugins = array(); + $loadedPlugins = []; foreach ($composerPlugins as $package => $pluginData) { $loadedPlugins[] = $pluginData['installerName']; @@ -646,7 +643,7 @@ protected function loadComposerPlugins(array $pluginBlacklist = array()) * * @throws \RuntimeException thrown when a plugin couldn't be loaded */ - protected function loadLocalPlugins(array $pluginBlacklist = array()) + protected function loadLocalPlugins(array $pluginBlacklist = []) { // scope isolated require() $includeClosure = function ($pluginFile) { @@ -658,7 +655,7 @@ protected function loadLocalPlugins(array $pluginBlacklist = array()) $pluginBlacklist = array_fill_keys($pluginBlacklist, true); - $files = scandir($this->getPluginsDir()) ?: array(); + $files = scandir($this->getPluginsDir()) ?: []; foreach ($files as $file) { if ($file[0] === '.') { continue; @@ -767,7 +764,7 @@ public function loadPlugin($plugin) // trigger onPluginManuallyLoaded event // the event is also triggered on the newly loaded plugin, allowing you to distinguish manual and auto loading - $this->triggerEvent('onPluginManuallyLoaded', array($plugin)); + $this->triggerEvent('onPluginManuallyLoaded', [ $plugin ]); return $plugin; } @@ -803,9 +800,9 @@ protected function sortPlugins() { $plugins = $this->plugins; $nativePlugins = $this->nativePlugins; - $sortedPlugins = array(); - $sortedNativePlugins = array(); - $visitedPlugins = array(); + $sortedPlugins = []; + $sortedNativePlugins = []; + $visitedPlugins = []; $visitPlugin = function ($plugin) use ( $plugins, @@ -821,7 +818,7 @@ protected function sortPlugins() if (!isset($visitedPlugins[$pluginName])) { $visitedPlugins[$pluginName] = true; - $dependencies = array(); + $dependencies = []; if ($plugin instanceof PluginInterface) { $dependencies = $plugin->getDependencies(); } @@ -914,11 +911,11 @@ protected function loadConfig() $loadConfigClosure = function ($configFile) use ($yamlParser) { $yaml = file_get_contents($configFile); $config = $yamlParser->parse($yaml); - return is_array($config) ? $config : array(); + return is_array($config) ? $config : []; }; // load main config file (config/config.yml) - $this->config = is_array($this->config) ? $this->config : array(); + $this->config = is_array($this->config) ? $this->config : []; if (is_file($this->getConfigDir() . 'config.yml')) { $this->config += $loadConfigClosure($this->getConfigDir() . 'config.yml'); } @@ -932,7 +929,7 @@ protected function loadConfig() } // merge default config - $this->config += array( + $this->config += [ 'site_title' => 'Pico', 'base_url' => null, 'rewrite_url' => null, @@ -952,8 +949,8 @@ protected function loadConfig() 'content_config' => null, 'assets_dir' => 'assets/', 'assets_url' => null, - 'plugins_url' => null - ); + 'plugins_url' => null, + ]; if (!$this->config['base_url']) { $this->config['base_url'] = $this->getBaseUrl(); @@ -1001,7 +998,7 @@ protected function loadConfig() $this->config['content_dir'] = $this->getAbsolutePath($this->config['content_dir']); } - $defaultContentConfig = array('extra' => true, 'breaks' => false, 'escape' => false, 'auto_urls' => true); + $defaultContentConfig = [ 'extra' => true, 'breaks' => false, 'escape' => false, 'auto_urls' => true ]; if (!is_array($this->config['content_config'])) { $this->config['content_config'] = $defaultContentConfig; } else { @@ -1081,21 +1078,21 @@ public function getConfig($configName = null, $default = null) */ protected function loadTheme() { - $themeConfig = array(); + $themeConfig = []; // load theme config from pico-theme.yml $themeConfigFile = $this->getThemesDir() . $this->getTheme() . '/pico-theme.yml'; if (is_file($themeConfigFile)) { $themeConfigYaml = file_get_contents($themeConfigFile); $themeConfig = $this->getYamlParser()->parse($themeConfigYaml); - $themeConfig = is_array($themeConfig) ? $themeConfig : array(); + $themeConfig = is_array($themeConfig) ? $themeConfig : []; } - $themeConfig += array( + $themeConfig += [ 'api_version' => null, - 'meta' => array(), - 'twig_config' => array() - ); + 'meta' => [], + 'twig_config' => [], + ]; // theme API version if (is_int($themeConfig['api_version']) || preg_match('/^[0-9]+$/', $themeConfig['api_version'])) { @@ -1107,7 +1104,7 @@ protected function loadTheme() unset($themeConfig['api_version']); // twig config - $themeTwigConfig = array('autoescape' => 'html', 'strict_variables' => false, 'charset' => 'utf-8'); + $themeTwigConfig = [ 'autoescape' => 'html', 'strict_variables' => false, 'charset' => 'utf-8' ]; foreach ($themeTwigConfig as $key => $_) { if (isset($themeConfig['twig_config'][$key])) { $themeTwigConfig[$key] = $themeConfig['twig_config'][$key]; @@ -1116,8 +1113,8 @@ protected function loadTheme() unset($themeConfig['twig_config']); - $defaultTwigConfig = array('debug' => null, 'cache' => false, 'auto_reload' => null); - $this->config['twig_config'] = is_array($this->config['twig_config']) ? $this->config['twig_config'] : array(); + $defaultTwigConfig = [ 'debug' => null, 'cache' => false, 'auto_reload' => null ]; + $this->config['twig_config'] = is_array($this->config['twig_config']) ? $this->config['twig_config'] : []; $this->config['twig_config'] = array_merge($defaultTwigConfig, $themeTwigConfig, $this->config['twig_config']); if ($this->config['twig_config']['autoescape'] === true) { @@ -1131,7 +1128,7 @@ protected function loadTheme() } // meta headers - $this->themeMetaHeaders = is_array($themeConfig['meta']) ? $themeConfig['meta'] : array(); + $this->themeMetaHeaders = is_array($themeConfig['meta']) ? $themeConfig['meta'] : []; unset($themeConfig['meta']); // theme config @@ -1229,7 +1226,7 @@ protected function evaluateRequestUrl() $scriptName = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : '/index.php'; $basePath = dirname($scriptName); - $basePath = !in_array($basePath, array('.', '/', '\\'), true) ? $basePath . '/' : '/'; + $basePath = !in_array($basePath, [ '.', '/', '\\' ], true) ? $basePath . '/' : '/'; $basePathLength = strlen($basePath); $requestUri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; @@ -1413,7 +1410,7 @@ public function is404Content() public function getMetaHeaders() { if ($this->metaHeaders === null) { - $this->metaHeaders = array( + $this->metaHeaders = [ 'Title' => 'title', 'Description' => 'description', 'Author' => 'author', @@ -1422,14 +1419,14 @@ public function getMetaHeaders() 'Time' => 'time', 'Robots' => 'robots', 'Template' => 'template', - 'Hidden' => 'hidden' - ); + 'Hidden' => 'hidden', + ]; if ($this->themeMetaHeaders) { $this->metaHeaders += $this->themeMetaHeaders; } - $this->triggerEvent('onMetaHeaders', array(&$this->metaHeaders)); + $this->triggerEvent('onMetaHeaders', [ &$this->metaHeaders ]); } return $this->metaHeaders; @@ -1447,7 +1444,7 @@ public function getYamlParser() { if ($this->yamlParser === null) { $this->yamlParser = new \Symfony\Component\Yaml\Parser(); - $this->triggerEvent('onYamlParserRegistered', array(&$this->yamlParser)); + $this->triggerEvent('onYamlParserRegistered', [ &$this->yamlParser ]); } return $this->yamlParser; @@ -1475,12 +1472,12 @@ public function getYamlParser() */ public function parseFileMeta($rawContent, array $headers) { - $meta = array(); + $meta = []; $pattern = "/^(?:\xEF\xBB\xBF)?(\/(\*)|---)[[:blank:]]*(?:\r)?\n" . "(?:(.*?)(?:\r)?\n)?(?(2)\*\/|---)[[:blank:]]*(?:(?:\r)?\n|$)/s"; if (preg_match($pattern, $rawContent, $rawMetaMatches) && isset($rawMetaMatches[3])) { - $meta = $this->getYamlParser()->parse($rawMetaMatches[3]) ?: array(); - $meta = is_array($meta) ? $meta : array('title' => $meta); + $meta = $this->getYamlParser()->parse($rawMetaMatches[3]) ?: []; + $meta = is_array($meta) ? $meta : [ 'title' => $meta ]; foreach ($headers as $name => $key) { if (isset($meta[$name])) { @@ -1556,7 +1553,7 @@ public function getParsedown() $this->parsedown->setMarkupEscaped((bool) $this->config['content_config']['escape']); $this->parsedown->setUrlsLinked((bool) $this->config['content_config']['auto_urls']); - $this->triggerEvent('onParsedownRegistered', array(&$this->parsedown)); + $this->triggerEvent('onParsedownRegistered', [ &$this->parsedown ]); } return $this->parsedown; @@ -1577,7 +1574,7 @@ public function getParsedown() * * @return string prepared Markdown contents */ - public function prepareFileContent($rawContent, array $meta = array()) + public function prepareFileContent($rawContent, array $meta = []) { // remove meta header $metaHeaderPattern = "/^(?:\xEF\xBB\xBF)?(\/(\*)|---)[[:blank:]]*(?:\r)?\n" @@ -1598,9 +1595,9 @@ public function prepareFileContent($rawContent, array $meta = array()) * * @return string substituted Markdown contents */ - public function substituteFileContent($markdown, array $meta = array()) + public function substituteFileContent($markdown, array $meta = []) { - $variables = array(); + $variables = []; // replace %version% $variables['%version%'] = static::VERSION; @@ -1715,7 +1712,7 @@ protected function readPages() $contentDir = $this->getConfig('content_dir'); $contentExt = $this->getConfig('content_ext'); - $this->pages = array(); + $this->pages = []; $files = $this->getFiles($contentDir, $contentExt, self::SORT_NONE); foreach ($files as $i => $file) { // skip 404 page @@ -1730,7 +1727,7 @@ protected function readPages() // skip inaccessible pages (e.g. drop "sub.md" if "sub/index.md" exists) by default $conflictFile = $contentDir . $id . '/index' . $contentExt; $skipFile = in_array($conflictFile, $files, true) ?: null; - $this->triggerEvent('onSinglePageLoading', array($id, &$skipFile)); + $this->triggerEvent('onSinglePageLoading', [ $id, &$skipFile ]); if ($skipFile) { continue; @@ -1741,7 +1738,7 @@ protected function readPages() $rawContent = $this->loadFileContent($file); // trigger onSinglePageContent event - $this->triggerEvent('onSinglePageContent', array($id, &$rawContent)); + $this->triggerEvent('onSinglePageContent', [ $id, &$rawContent ]); $headers = $this->getMetaHeaders(); try { @@ -1758,7 +1755,7 @@ protected function readPages() // build page data // title, description, author and date are assumed to be pretty basic data // everything else is accessible through $page['meta'] - $page = array( + $page = [ 'id' => $id, 'url' => $url, 'title' => &$meta['title'], @@ -1769,8 +1766,8 @@ protected function readPages() 'date_formatted' => &$meta['date_formatted'], 'hidden' => ($meta['hidden'] || preg_match('/(?:^|\/)_/', $id)), 'raw_content' => &$rawContent, - 'meta' => &$meta - ); + 'meta' => &$meta, + ]; if ($file === $this->requestFile) { $page['content'] = &$this->content; @@ -1779,7 +1776,7 @@ protected function readPages() unset($rawContent, $meta); // trigger onSinglePageLoaded event - $this->triggerEvent('onSinglePageLoaded', array(&$page)); + $this->triggerEvent('onSinglePageLoaded', [ &$page ]); if ($page !== null) { $this->pages[$id] = $page; @@ -2009,7 +2006,7 @@ public function getNextPage() */ protected function buildPageTree() { - $this->pageTree = array(); + $this->pageTree = []; foreach ($this->pages as $id => &$pageData) { // main index page if ($id === 'index') { @@ -2116,11 +2113,11 @@ function ($page) use ($pico, &$pages) { } return null; }, - array('is_safe' => array('html')) + [ 'is_safe' => [ 'html' ] ] )); // trigger onTwigRegistration event - $this->triggerEvent('onTwigRegistered', array(&$this->twig)); + $this->triggerEvent('onTwigRegistered', [ &$this->twig ]); } return $this->twig; @@ -2135,7 +2132,7 @@ function ($page) use ($pico, &$pages) { */ protected function getTwigVariables() { - return array( + return [ 'config' => $this->getConfig(), 'base_url' => rtrim($this->getBaseUrl(), '/'), 'plugins_url' => rtrim($this->getConfig('plugins_url'), '/'), @@ -2149,8 +2146,8 @@ protected function getTwigVariables() 'previous_page' => $this->previousPage, 'current_page' => $this->currentPage, 'next_page' => $this->nextPage, - 'version' => static::VERSION - ); + 'version' => static::VERSION, + ]; } /** @@ -2205,7 +2202,7 @@ public function getBaseUrl() $protocol = 'http'; if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) { $secureProxyHeader = strtolower(current(explode(',', $_SERVER['HTTP_X_FORWARDED_PROTO']))); - $protocol = in_array($secureProxyHeader, array('https', 'on', 'ssl', '1'), true) ? 'https' : 'http'; + $protocol = in_array($secureProxyHeader, [ 'https', 'on', 'ssl', '1' ], true) ? 'https' : 'http'; } elseif (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] !== 'off')) { $protocol = 'https'; } elseif ($port === 443) { @@ -2213,7 +2210,7 @@ public function getBaseUrl() } $basePath = isset($_SERVER['SCRIPT_NAME']) ? dirname($_SERVER['SCRIPT_NAME']) : '/'; - $basePath = !in_array($basePath, array('.', '/', '\\'), true) ? $basePath . '/' : '/'; + $basePath = !in_array($basePath, [ '.', '/', '\\' ], true) ? $basePath . '/' : '/'; if ((($protocol === 'http') && ($port !== 80)) || (($protocol === 'https') && ($port !== 443))) { $host = $host . ':' . $port; @@ -2364,14 +2361,14 @@ public function getPageId($path) */ public function substituteUrl($url) { - $variables = array( + $variables = [ '%base_url%?' => $this->getBaseUrl() . (!$this->isUrlRewritingEnabled() ? '?' : ''), '%base_url%' => rtrim($this->getBaseUrl(), '/'), '%plugins_url%' => rtrim($this->getConfig('plugins_url'), '/'), '%themes_url%' => rtrim($this->getConfig('themes_url'), '/'), '%assets_url%' => rtrim($this->getConfig('assets_url'), '/'), - '%theme_url%' => $this->getConfig('themes_url') . $this->getTheme() - ); + '%theme_url%' => $this->getConfig('themes_url') . $this->getTheme(), + ]; return str_replace(array_keys($variables), $variables, $url); } @@ -2415,7 +2412,7 @@ public function getUrlFromPath($absolutePath) $basePath = ''; if (isset($_SERVER['SCRIPT_FILENAME']) && strrpos($_SERVER['SCRIPT_FILENAME'], '/')) { $basePath = dirname($_SERVER['SCRIPT_FILENAME']); - $basePath = !in_array($basePath, array('.', '/', '\\'), true) ? $basePath . '/' : '/'; + $basePath = !in_array($basePath, [ '.', '/', '\\' ], true) ? $basePath . '/' : '/'; $basePathLength = strlen($basePath); if ((substr($absolutePath, 0, $basePathLength) === $basePath) && ($basePath !== '/')) { @@ -2539,7 +2536,7 @@ protected function filterVariable($variable, $filter = '', $options = null, $fla $defaultValue = isset($options['default']) ? $options['default'] : null; } elseif ($options !== null) { $defaultValue = $options; - $options = array('default' => $defaultValue); + $options = [ 'default' => $defaultValue ]; } if ($variable === null) { @@ -2551,7 +2548,7 @@ protected function filterVariable($variable, $filter = '', $options = null, $fla return false; } - $filterOptions = array('options' => $options, 'flags' => 0); + $filterOptions = [ 'options' => $options, 'flags' => 0 ]; foreach ((array) $flags as $flag) { if (is_numeric($flag)) { $filterOptions['flags'] |= (int) $flag; @@ -2586,14 +2583,14 @@ public function getFiles($directory, $fileExtension = '', $order = self::SORT_AS { $directory = rtrim($directory, '/'); $fileExtensionLength = strlen($fileExtension); - $result = array(); + $result = []; $files = scandir($directory, $order); if ($files !== false) { foreach ($files as $file) { // exclude hidden files/dirs starting with a .; this also excludes the special dirs . and .. // exclude files ending with a ~ (vim/nano backup) or # (emacs backup) - if (($file[0] === '.') || in_array(substr($file, -1), array('~', '#'), true)) { + if (($file[0] === '.') || in_array(substr($file, -1), [ '~', '#' ], true)) { continue; } @@ -2626,14 +2623,14 @@ public function getFiles($directory, $fileExtension = '', $order = self::SORT_AS */ public function getFilesGlob($pattern, $order = self::SORT_ASC) { - $result = array(); + $result = []; $sortFlag = ($order === self::SORT_NONE) ? GLOB_NOSORT : 0; $files = glob($pattern, GLOB_MARK | $sortFlag); if ($files) { foreach ($files as $file) { // exclude dirs and files ending with a ~ (vim/nano backup) or # (emacs backup) - if (in_array(substr($file, -1), array('/', '~', '#'), true)) { + if (in_array(substr($file, -1), [ '/', '~', '#' ], true)) { continue; } @@ -2711,7 +2708,7 @@ public function getNormalizedPath($path, $allowAbsolutePath = false, $endSlash = $path = str_replace('\\', '/', $path); $pathParts = explode('/', $path); - $resultParts = array(); + $resultParts = []; foreach ($pathParts as $pathPart) { if (($pathPart === '') || ($pathPart === '.')) { continue; @@ -2770,7 +2767,7 @@ public function getAbsoluteUrl($url, $baseUrl = null, $endSlash = true) * @param string $eventName name of the event to trigger * @param array $params optional parameters to pass */ - public function triggerEvent($eventName, array $params = array()) + public function triggerEvent($eventName, array $params = []) { foreach ($this->nativePlugins as $plugin) { $plugin->handleEvent($eventName, $params); diff --git a/lib/TwigExtension.php b/lib/TwigExtension.php index d726191f2..3f8df6f27 100644 --- a/lib/TwigExtension.php +++ b/lib/TwigExtension.php @@ -73,17 +73,17 @@ public function getName() */ public function getFilters() { - return array( + return [ 'markdown' => new \Twig_SimpleFilter( 'markdown', - array($this, 'markdownFilter'), - array('is_safe' => array('html')) + [ $this, 'markdownFilter' ], + [ 'is_safe' => [ 'html' ] ] ), - 'map' => new \Twig_SimpleFilter('map', array($this, 'mapFilter')), - 'sort_by' => new \Twig_SimpleFilter('sort_by', array($this, 'sortByFilter')), - 'link' => new \Twig_SimpleFilter('link', array($this->pico, 'getPageUrl')), - 'url' => new \Twig_SimpleFilter('url', array($this->pico, 'substituteUrl')) - ); + 'map' => new \Twig_SimpleFilter('map', [ $this, 'mapFilter' ]), + 'sort_by' => new \Twig_SimpleFilter('sort_by', [ $this, 'sortByFilter' ]), + 'link' => new \Twig_SimpleFilter('link', [ $this->pico, 'getPageUrl' ]), + 'url' => new \Twig_SimpleFilter('url', [ $this->pico, 'substituteUrl' ]), + ]; } /** @@ -95,11 +95,11 @@ public function getFilters() */ public function getFunctions() { - return array( - 'url_param' => new \Twig_SimpleFunction('url_param', array($this, 'urlParamFunction')), - 'form_param' => new \Twig_SimpleFunction('form_param', array($this, 'formParamFunction')), - 'pages' => new \Twig_SimpleFunction('pages', array($this, 'pagesFunction')) - ); + return [ + 'url_param' => new \Twig_SimpleFunction('url_param', [ $this, 'urlParamFunction' ]), + 'form_param' => new \Twig_SimpleFunction('form_param', [ $this, 'formParamFunction' ]), + 'pages' => new \Twig_SimpleFunction('pages', [ $this, 'pagesFunction' ]), + ]; } /** @@ -119,7 +119,7 @@ public function getFunctions() * * @return string parsed HTML */ - public function markdownFilter($markdown, array $meta = array(), $singleLine = false) + public function markdownFilter($markdown, array $meta = [], $singleLine = false) { $markdown = $this->getPico()->substituteFileContent($markdown, $meta); return $this->getPico()->parseFileContent($markdown, $singleLine); @@ -149,7 +149,7 @@ public function mapFilter($var, $mapKeyPath) )); } - $result = array(); + $result = []; foreach ($var as $key => $value) { $mapValue = $this->getKeyOfVar($value, $mapKeyPath); $result[$key] = ($mapValue !== null) ? $mapValue : $value; @@ -200,7 +200,7 @@ public function sortByFilter($var, $sortKeyPath, $fallback = 'bottom') $twigExtension = $this; $varKeys = array_keys($var); - $removeItems = array(); + $removeItems = []; uksort($var, function ($a, $b) use ($twigExtension, $var, $varKeys, $sortKeyPath, $fallback, &$removeItems) { $aSortValue = $twigExtension->getKeyOfVar($var[$a], $sortKeyPath); $aSortValueNull = ($aSortValue === null); @@ -258,7 +258,7 @@ public static function getKeyOfVar($var, $keyPath) if (!$keyPath) { return null; } elseif (!is_array($keyPath)) { - $keyPath = array($keyPath); + $keyPath = [ $keyPath ]; } foreach ($keyPath as $key) { @@ -270,9 +270,9 @@ public static function getKeyOfVar($var, $keyPath) } elseif (isset($var->{$key})) { $var = $var->{$key}; continue; - } elseif (is_callable(array($var, 'get' . ucfirst($key)))) { + } elseif (is_callable([ $var, 'get' . ucfirst($key) ])) { try { - $var = call_user_func(array($var, 'get' . ucfirst($key))); + $var = call_user_func([ $var, 'get' . ucfirst($key) ]); continue; } catch (\BadMethodCallException $e) { return null; @@ -433,7 +433,7 @@ public function pagesFunction($start = '', $depth = 0, $depthOffset = 0, $offset } for (; $offset < 0; $offset++) { - if (in_array($start, array('', '.', '/'), true)) { + if (in_array($start, [ '', '.', '/' ], true)) { $offset = 0; break; } @@ -449,7 +449,7 @@ public function pagesFunction($start = '', $depth = 0, $depthOffset = 0, $offset } $pageTree = $this->getPico()->getPageTree(); - if (in_array($start, array('', '.', '/'), true)) { + if (in_array($start, [ '', '.', '/' ], true)) { if (($depth === null) && ($depthOffset <= 0)) { return $this->getPico()->getPages(); } @@ -463,11 +463,11 @@ public function pagesFunction($start = '', $depth = 0, $depthOffset = 0, $offset } if (!$startNode) { - return array(); + return []; } $getPagesClosure = function ($nodes, $depth, $depthOffset) use (&$getPagesClosure) { - $pages = array(); + $pages = []; foreach ($nodes as $node) { if (isset($node['page']) && ($depthOffset <= 0)) { $pages[$node['page']['id']] = &$node['page']; @@ -481,7 +481,7 @@ public function pagesFunction($start = '', $depth = 0, $depthOffset = 0, $offset }; return $getPagesClosure( - array($startNode), + [ $startNode ], ($depth !== null) ? $depth : INF, $depthOffset ); From 85d757302015b53a16b2dff85c50831d46a9d696 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 10 Apr 2020 23:11:53 +0200 Subject: [PATCH 09/75] Update to Symfony YAML 5.0 and Twig 3.0 Pico now requires PHP 7.2.5+ --- composer.json | 6 +++--- config/config.yml.template | 2 +- content-sample/_meta.md | 2 +- index.php.dist | 4 ++-- lib/Pico.php | 27 +++++++++++++++---------- lib/TwigExtension.php | 41 +++++++++++++++++++++----------------- 6 files changed, 47 insertions(+), 35 deletions(-) diff --git a/composer.json b/composer.json index 2dfe2a4ec..8be85c6a4 100644 --- a/composer.json +++ b/composer.json @@ -31,9 +31,9 @@ "source": "https://github.com/picocms/Pico" }, "require": { - "php": ">=7.0.8", - "twig/twig": "^2.12", - "symfony/yaml" : "^3.4", + "php": ">=7.2.5", + "twig/twig": "^3.0", + "symfony/yaml" : "^5.0", "erusev/parsedown": "1.7.4", "erusev/parsedown-extra": "0.8.1" }, diff --git a/config/config.yml.template b/config/config.yml.template index 159585bc6..4e292277e 100644 --- a/config/config.yml.template +++ b/config/config.yml.template @@ -27,7 +27,7 @@ twig_config: # Twig template engine config ## # Content # -date_format: %D %T # Pico's default date format; +date_format: "%D %T" # Pico's default date format; # See https://php.net/manual/en/function.strftime.php for more info pages_order_by_meta: author # Sort pages by meta value "author" (set "pages_order_by" to "meta") pages_order_by: alpha # Change how Pico sorts pages ("alpha" for alphabetical order, "date", or "meta") diff --git a/content-sample/_meta.md b/content-sample/_meta.md index d18f05120..b686a84a5 100644 --- a/content-sample/_meta.md +++ b/content-sample/_meta.md @@ -1,5 +1,5 @@ --- -Logo: %theme_url%/img/pico-white.svg +Logo: "%theme_url%/img/pico-white.svg" Tagline: Making the web easy. Social: - title: Visit us on GitHub diff --git a/index.php.dist b/index.php.dist index 3dc407027..9550c5922 100644 --- a/index.php.dist +++ b/index.php.dist @@ -11,8 +11,8 @@ */ // check PHP platform requirements -if (PHP_VERSION_ID < 70008) { - die('Pico requires PHP 7.0.8 or above to run'); +if (PHP_VERSION_ID < 70205) { + die('Pico requires PHP 7.2.5 or above to run'); } if (!extension_loaded('dom')) { die("Pico requires the PHP extension 'dom' to run"); diff --git a/lib/Pico.php b/lib/Pico.php index e3e54ded2..6cd245feb 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -18,6 +18,13 @@ namespace picocms\Pico; +use Symfony\Component\Yaml\Parser as YamlParser; +use Twig\Environment as TwigEnvironment; +use Twig\Extension\DebugExtension as TwigDebugExtension; +use Twig\Loader\FilesystemLoader as TwigFilesystemLoader; +use Twig\Markup as TwigMarkup; +use Twig\TwigFilter; + /** * Pico * @@ -229,7 +236,7 @@ class Pico * Symfony YAML instance used for meta header parsing * * @see Pico::getYamlParser() - * @var \Symfony\Component\Yaml\Parser|null + * @var YamlParser|null */ protected $yamlParser; @@ -309,7 +316,7 @@ class Pico * Twig instance used for template parsing * * @see Pico::getTwig() - * @var \Twig_Environment|null + * @var TwigEnvironment|null */ protected $twig; @@ -1438,12 +1445,12 @@ public function getMetaHeaders() * This method triggers the `onYamlParserRegistered` event when the Symfony * YAML parser wasn't initiated yet. * - * @return \Symfony\Component\Yaml\Parser Symfony YAML parser + * @return YamlParser Symfony YAML parser */ public function getYamlParser() { if ($this->yamlParser === null) { - $this->yamlParser = new \Symfony\Component\Yaml\Parser(); + $this->yamlParser = new YamlParser(); $this->triggerEvent('onYamlParserRegistered', [ &$this->yamlParser ]); } @@ -2080,19 +2087,19 @@ public function getPageTree() * @see http://twig.sensiolabs.org/ Twig website * @see https://github.com/twigphp/Twig Twig on GitHub * - * @return \Twig_Environment|null Twig template engine + * @return TwigEnvironment|null Twig template engine */ public function getTwig() { if ($this->twig === null) { $twigConfig = $this->getConfig('twig_config'); - $twigLoader = new \Twig_Loader_Filesystem($this->getThemesDir() . $this->getTheme()); - $this->twig = new \Twig_Environment($twigLoader, $twigConfig); + $twigLoader = new TwigFilesystemLoader($this->getThemesDir() . $this->getTheme()); + $this->twig = new TwigEnvironment($twigLoader, $twigConfig); $this->twig->addExtension(new TwigExtension($this)); if (!empty($twigConfig['debug'])) { - $this->twig->addExtension(new \Twig_Extension_Debug()); + $this->twig->addExtension(new TwigDebugExtension()); } // register content filter @@ -2100,7 +2107,7 @@ public function getTwig() // this is the reason why we can't register this filter as part of PicoTwigExtension $pico = $this; $pages = &$this->pages; - $this->twig->addFilter(new \Twig_SimpleFilter( + $this->twig->addFilter(new TwigFilter( 'content', function ($page) use ($pico, &$pages) { if (isset($pages[$page])) { @@ -2141,7 +2148,7 @@ protected function getTwigVariables() 'theme_url' => $this->getConfig('themes_url') . $this->getTheme(), 'site_title' => $this->getConfig('site_title'), 'meta' => $this->meta, - 'content' => new \Twig_Markup($this->content, 'UTF-8'), + 'content' => new TwigMarkup($this->content, 'UTF-8'), 'pages' => $this->pages, 'previous_page' => $this->previousPage, 'current_page' => $this->currentPage, diff --git a/lib/TwigExtension.php b/lib/TwigExtension.php index 3f8df6f27..eb5827466 100644 --- a/lib/TwigExtension.php +++ b/lib/TwigExtension.php @@ -12,6 +12,11 @@ namespace picocms\Pico; +use Twig\Error\RuntimeError as TwigRuntimeError; +use Twig\Extension\AbstractExtension as AbstractTwigExtension; +use Twig\TwigFilter; +use Twig\TwigFunction; + /** * Pico's Twig extension to implement additional filters * @@ -20,7 +25,7 @@ * @license http://opensource.org/licenses/MIT The MIT License * @version 3.0 */ -class TwigExtension extends \Twig_Extension +class TwigExtension extends AbstractTwigExtension { /** * Current instance of Pico @@ -69,20 +74,20 @@ public function getName() * * @see Twig_ExtensionInterface::getFilters() * - * @return \Twig_SimpleFilter[] array of Pico's Twig filters + * @return TwigFilter[] array of Pico's Twig filters */ public function getFilters() { return [ - 'markdown' => new \Twig_SimpleFilter( + 'markdown' => new TwigFilter( 'markdown', [ $this, 'markdownFilter' ], [ 'is_safe' => [ 'html' ] ] ), - 'map' => new \Twig_SimpleFilter('map', [ $this, 'mapFilter' ]), - 'sort_by' => new \Twig_SimpleFilter('sort_by', [ $this, 'sortByFilter' ]), - 'link' => new \Twig_SimpleFilter('link', [ $this->pico, 'getPageUrl' ]), - 'url' => new \Twig_SimpleFilter('url', [ $this->pico, 'substituteUrl' ]), + 'map' => new TwigFilter('map', [ $this, 'mapFilter' ]), + 'sort_by' => new TwigFilter('sort_by', [ $this, 'sortByFilter' ]), + 'link' => new TwigFilter('link', [ $this->pico, 'getPageUrl' ]), + 'url' => new TwigFilter('url', [ $this->pico, 'substituteUrl' ]), ]; } @@ -91,14 +96,14 @@ public function getFilters() * * @see Twig_ExtensionInterface::getFunctions() * - * @return \Twig_SimpleFunction[] array of Pico's Twig functions + * @return TwigFunction[] array of Pico's Twig functions */ public function getFunctions() { return [ - 'url_param' => new \Twig_SimpleFunction('url_param', [ $this, 'urlParamFunction' ]), - 'form_param' => new \Twig_SimpleFunction('form_param', [ $this, 'formParamFunction' ]), - 'pages' => new \Twig_SimpleFunction('pages', [ $this, 'pagesFunction' ]), + 'url_param' => new TwigFunction('url_param', [ $this, 'urlParamFunction' ]), + 'form_param' => new TwigFunction('form_param', [ $this, 'formParamFunction' ]), + 'pages' => new TwigFunction('pages', [ $this, 'pagesFunction' ]), ]; } @@ -138,12 +143,12 @@ public function markdownFilter($markdown, array $meta = [], $singleLine = false) * * @return array mapped values * - * @throws \Twig_Error_Runtime + * @throws TwigRuntimeError */ public function mapFilter($var, $mapKeyPath) { if (!is_array($var) && (!is_object($var) || !($var instanceof \Traversable))) { - throw new \Twig_Error_Runtime(sprintf( + throw new TwigRuntimeError(sprintf( 'The map filter only works with arrays or "Traversable", got "%s"', is_object($var) ? get_class($var) : gettype($var) )); @@ -180,20 +185,20 @@ public function mapFilter($var, $mapKeyPath) * * @return array sorted array * - * @throws \Twig_Error_Runtime + * @throws TwigRuntimeError */ public function sortByFilter($var, $sortKeyPath, $fallback = 'bottom') { if (is_object($var) && ($var instanceof \Traversable)) { $var = iterator_to_array($var, true); } elseif (!is_array($var)) { - throw new \Twig_Error_Runtime(sprintf( + throw new TwigRuntimeError(sprintf( 'The sort_by filter only works with arrays or "Traversable", got "%s"', is_object($var) ? get_class($var) : gettype($var) )); } if (($fallback !== 'top') && ($fallback !== 'bottom') && ($fallback !== 'keep') && ($fallback !== "remove")) { - throw new \Twig_Error_Runtime( + throw new TwigRuntimeError( 'The sort_by filter only supports the "top", "bottom", "keep" and "remove" fallbacks' ); } @@ -423,7 +428,7 @@ public function formParamFunction($name, $filter = '', $options = null, $flags = * * @return array[] the data of the matched pages * - * @throws \Twig_Error_Runtime + * @throws TwigRuntimeError */ public function pagesFunction($start = '', $depth = 0, $depthOffset = 0, $offset = 1) { @@ -445,7 +450,7 @@ public function pagesFunction($start = '', $depth = 0, $depthOffset = 0, $offset $depthOffset = $depthOffset + $offset; if (($depth !== null) && ($depth < 0)) { - throw new \Twig_Error_Runtime('The pages function doesn\'t support negative depths'); + throw new TwigRuntimeError('The pages function doesn\'t support negative depths'); } $pageTree = $this->getPico()->getPageTree(); From 62aa4dbc7e7feb26a562d3aaca0325e3d2bdc374 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 10 Apr 2020 23:44:00 +0200 Subject: [PATCH 10/75] Check theme dir before trying to load theme --- lib/Pico.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Pico.php b/lib/Pico.php index 6cd245feb..21d57694c 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -1085,6 +1085,12 @@ public function getConfig($configName = null, $default = null) */ protected function loadTheme() { + if (!is_dir($this->getThemesDir() . $this->getTheme())) { + throw new \RuntimeException( + 'Couldn\'t load theme "' . $this->theme . '": No such theme directory' + ); + } + $themeConfig = []; // load theme config from pico-theme.yml From bdafcb5b96722392e04a2da94cacfb515fb02137 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 10 Apr 2020 23:46:44 +0200 Subject: [PATCH 11/75] Fix Travis CI --- .travis.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8aa14fc84..5d7ee4ede 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +os: linux dist: bionic sudo: false @@ -10,21 +11,15 @@ cache: jobs: include: # Test stage - - php: 7.0 - dist: xenial - - php: 7.1 - php: 7.2 - php: 7.3 - php: 7.4 - php: nightly - - php: hhvm-3.27 # until Sep 2019 - - php: hhvm-3.30 # until Nov 2019 # Branch deployment stage - stage: deploy-branch if: type == "push" && tag IS blank - php: 7.0 - dist: xenial + php: 7.2 install: - '[[ ",$DEPLOY_PHPDOC_BRANCHES," == *,"$TRAVIS_BRANCH",* ]] || travis_terminate 0' - install.sh --deploy @@ -34,8 +29,7 @@ jobs: # Release deployment stage - stage: deploy-release if: tag IS present - php: 7.0 - dist: xenial + php: 7.2 install: - install.sh --deploy script: From 646aa355e5acbb6d3d66fcef01c6e5e359e4d266 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sat, 11 Apr 2020 21:15:50 +0200 Subject: [PATCH 12/75] Various small improvements --- lib/Pico.php | 7 +++++-- lib/TwigExtension.php | 9 +++++---- plugins/DummyPlugin.php | 11 ++++++----- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/Pico.php b/lib/Pico.php index 21d57694c..e5a14f5fc 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -1559,8 +1559,11 @@ public function getFileMeta() public function getParsedown() { if ($this->parsedown === null) { - $className = $this->config['content_config']['extra'] ? '\ParsedownExtra' : '\Parsedown'; - $this->parsedown = new $className(); + if ($this->config['content_config']['extra']) { + $this->parsedown = new \ParsedownExtra(); + } else { + $this->parsedown = new \Parsedown(); + } $this->parsedown->setBreaksEnabled((bool) $this->config['content_config']['breaks']); $this->parsedown->setMarkupEscaped((bool) $this->config['content_config']['escape']); diff --git a/lib/TwigExtension.php b/lib/TwigExtension.php index eb5827466..2b76b66bb 100644 --- a/lib/TwigExtension.php +++ b/lib/TwigExtension.php @@ -14,6 +14,7 @@ use Twig\Error\RuntimeError as TwigRuntimeError; use Twig\Extension\AbstractExtension as AbstractTwigExtension; +use Twig\Extension\ExtensionInterface as TwigExtensionInterface; use Twig\TwigFilter; use Twig\TwigFunction; @@ -60,7 +61,7 @@ public function getPico() /** * Returns the name of the extension * - * @see Twig_ExtensionInterface::getName() + * @see TwigExtensionInterface::getName() * * @return string the extension name */ @@ -72,7 +73,7 @@ public function getName() /** * Returns a list of Pico-specific Twig filters * - * @see Twig_ExtensionInterface::getFilters() + * @see TwigExtensionInterface::getFilters() * * @return TwigFilter[] array of Pico's Twig filters */ @@ -94,7 +95,7 @@ public function getFilters() /** * Returns a list of Pico-specific Twig functions * - * @see Twig_ExtensionInterface::getFunctions() + * @see TwigExtensionInterface::getFunctions() * * @return TwigFunction[] array of Pico's Twig functions */ @@ -406,7 +407,7 @@ public function formParamFunction($name, $filter = '', $options = null, $flags = * returns Pico's full pages array. * * If `$depth` is negative after taking `$offset` into consideration, the - * function will throw a {@see Twig_Error_Runtime} exception, since this + * function will throw a {@see TwigRuntimeError} exception, since this * would simply make no sense and is likely an error. Passing a negative * `$depthOffset` is equivalent to passing `$depthOffset = 0`. * diff --git a/plugins/DummyPlugin.php b/plugins/DummyPlugin.php index 987a6266c..4a066e797 100644 --- a/plugins/DummyPlugin.php +++ b/plugins/DummyPlugin.php @@ -12,6 +12,7 @@ use picocms\Pico\AbstractPlugin; use picocms\Pico\Pico; +use Twig\Environment as TwigEnvironment; /** * Pico dummy plugin - a template for plugins @@ -31,7 +32,7 @@ class DummyPlugin extends AbstractPlugin * * @var int */ - const API_VERSION = 3; + public const API_VERSION = 3; /** * This plugin is disabled by default @@ -39,8 +40,8 @@ class DummyPlugin extends AbstractPlugin * Usually you should remove this class property (or set it to NULL) to * leave the decision whether this plugin should be enabled or disabled by * default up to Pico. If all the plugin's dependenies are fulfilled (see - * {@see DummyPlugin::$dependsOn}), Pico enables the plugin by default. - * Otherwise the plugin is silently disabled. + * {@see self::$dependsOn}), Pico enables the plugin by default. Otherwise + * the plugin is silently disabled. * * If this plugin should never be disabled *silently* (e.g. when dealing * with security-relevant stuff like access control, or similar), set this @@ -498,9 +499,9 @@ public function onParsedownRegistered(Parsedown &$parsedown) * * @see Pico::getTwig() * - * @param Twig_Environment &$twig Twig instance + * @param TwigEnvironment &$twig Twig instance */ - public function onTwigRegistered(Twig_Environment &$twig) + public function onTwigRegistered(TwigEnvironment &$twig) { // your code } From 1b1fa73fd9dd872f449bf3911c9daae9089e6afb Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sat, 11 Apr 2020 21:21:33 +0200 Subject: [PATCH 13/75] Fix Travis CI --- .build/deploy-branch.sh | 2 +- .build/install.sh | 2 +- .build/release.sh | 2 +- .travis.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.build/deploy-branch.sh b/.build/deploy-branch.sh index d8284a7ed..ca0fda7a5 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 Pico::VERSION;")" +VERSION="$(php -r "require_once('$PICO_PROJECT_DIR/lib/Pico.php'); echo picocms\Pico\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 dff079c8e..738f64848 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', Pico::VERSION); + echo preg_replace('/\.[0-9]+-dev$/', '.x-dev', picocms\Pico\Pico::VERSION); ")" fi diff --git a/.build/release.sh b/.build/release.sh index 7a2cc1d0d..b8fb6537d 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)?$/', '', Pico::VERSION); + echo preg_replace('/-(?:dev|n|nightly)(?:[.-]?[0-9]+)?(?:[.-]dev)?$/', '', picocms\Pico\Pico::VERSION); ")" VERSION="v$PICO_VERSION-dev+${PROJECT_REPO_BRANCH:-master}" diff --git a/.travis.yml b/.travis.yml index 5d7ee4ede..ee54509d4 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 Pico::VERSION;")" ]' + - '[ "$PROJECT_REPO_TAG" == "v$(php -r "require_once(\"lib/Pico.php\"); echo picocms\Pico\Pico::VERSION;")" ]' - deploy-release.sh before_deploy: - release.sh "$PROJECT_REPO_TAG" From de5bd4399ce134816d4df50bff432d1f30b57506 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sat, 11 Apr 2020 22:13:00 +0200 Subject: [PATCH 14/75] Update to phpDocumentor 3 config --- .phpdoc.xml | 65 ++++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/.phpdoc.xml b/.phpdoc.xml index 8f6456e48..3d3a64b6d 100644 --- a/.phpdoc.xml +++ b/.phpdoc.xml @@ -1,33 +1,36 @@ - - <![CDATA[Pico API Documentation]]> - - .build/phpdoc.cache - - - .build/phpdoc - - -