From 7ffb188710651b4296f43b084f71a4490dad33cd Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 17 Dec 2016 22:01:48 +0100 Subject: [PATCH] deprecated function/test/filter/tag overriding --- CHANGELOG | 3 ++- composer.json | 2 +- ext/twig/php_twig.h | 2 +- lib/Twig/Environment.php | 8 ++++---- lib/Twig/Extension/Staging.php | 18 +++++++++++++++++- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c5da0bcea..709259dd6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ -* 1.29.1 (2017-XX-XX) +* 1.30.0 (2017-XX-XX) + * deprecated function/test/filter/tag overriding * deprecated the "disable_c_ext" attribute on Twig_Node_Expression_GetAttr * 1.29.0 (2016-12-13) diff --git a/composer.json b/composer.json index 5bf8a436c..57c0d91c7 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.29-dev" + "dev-master": "1.30-dev" } } } diff --git a/ext/twig/php_twig.h b/ext/twig/php_twig.h index e1301ddc5..cbc1ac82c 100644 --- a/ext/twig/php_twig.h +++ b/ext/twig/php_twig.h @@ -15,7 +15,7 @@ #ifndef PHP_TWIG_H #define PHP_TWIG_H -#define PHP_TWIG_VERSION "1.29.1-DEV" +#define PHP_TWIG_VERSION "1.30.0-DEV" #include "php.h" diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index 157ebb9de..87e5fb2a5 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -16,11 +16,11 @@ */ class Twig_Environment { - const VERSION = '1.29.1-DEV'; - const VERSION_ID = 12901; + const VERSION = '1.30.0-DEV'; + const VERSION_ID = 13000; const MAJOR_VERSION = 1; - const MINOR_VERSION = 29; - const RELEASE_VERSION = 1; + const MINOR_VERSION = 30; + const RELEASE_VERSION = 0; const EXTRA_VERSION = 'DEV'; protected $charset; diff --git a/lib/Twig/Extension/Staging.php b/lib/Twig/Extension/Staging.php index d21004d09..0ca6b96af 100644 --- a/lib/Twig/Extension/Staging.php +++ b/lib/Twig/Extension/Staging.php @@ -29,6 +29,10 @@ class Twig_Extension_Staging extends Twig_Extension public function addFunction($name, $function) { + if (isset($this->functions[$name])) { + @trigger_error(sprintf('Overriding function "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $name), E_USER_DEPRECATED); + } + $this->functions[$name] = $function; } @@ -39,6 +43,10 @@ class Twig_Extension_Staging extends Twig_Extension public function addFilter($name, $filter) { + if (isset($this->filters[$name])) { + @trigger_error(sprintf('Overriding filter "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $name), E_USER_DEPRECATED); + } + $this->filters[$name] = $filter; } @@ -59,7 +67,11 @@ class Twig_Extension_Staging extends Twig_Extension public function addTokenParser(Twig_TokenParserInterface $parser) { - $this->tokenParsers[] = $parser; + if (isset($this->tokenParsers[$parser->getTag()])) { + @trigger_error(sprintf('Overriding tag "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $parser->getTag()), E_USER_DEPRECATED); + } + + $this->tokenParsers[$parser->getTag()] = $parser; } public function getTokenParsers() @@ -79,6 +91,10 @@ class Twig_Extension_Staging extends Twig_Extension public function addTest($name, $test) { + if (isset($this->tests[$name])) { + @trigger_error(sprintf('Overriding test "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $name), E_USER_DEPRECATED); + } + $this->tests[$name] = $test; }