From 646aa355e5acbb6d3d66fcef01c6e5e359e4d266 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sat, 11 Apr 2020 21:15:50 +0200 Subject: [PATCH] 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 21d5769..e5a14f5 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -1559,8 +1559,11 @@ class Pico 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 eb58274..2b76b66 100644 --- a/lib/TwigExtension.php +++ b/lib/TwigExtension.php @@ -14,6 +14,7 @@ namespace picocms\Pico; 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 @@ class TwigExtension extends AbstractTwigExtension /** * Returns the name of the extension * - * @see Twig_ExtensionInterface::getName() + * @see TwigExtensionInterface::getName() * * @return string the extension name */ @@ -72,7 +73,7 @@ class TwigExtension extends AbstractTwigExtension /** * 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 @@ class TwigExtension extends AbstractTwigExtension /** * 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 @@ class TwigExtension extends AbstractTwigExtension * 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 987a626..4a066e7 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 @@ class DummyPlugin extends AbstractPlugin * * @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 }