From cc980282dee1964d867b70666ec7d2183d87ea4c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 18 Aug 2015 09:04:31 +0200 Subject: [PATCH] added deprecation notices for deprecated classes --- lib/Twig/Autoloader.php | 2 ++ lib/Twig/Environment.php | 2 +- lib/Twig/Filter/Function.php | 2 ++ lib/Twig/Filter/Method.php | 2 ++ lib/Twig/Filter/Node.php | 2 ++ lib/Twig/Function/Function.php | 2 ++ lib/Twig/Function/Method.php | 2 ++ lib/Twig/Function/Node.php | 2 ++ lib/Twig/Loader/String.php | 2 ++ lib/Twig/Test/Function.php | 2 ++ lib/Twig/Test/Method.php | 2 ++ lib/Twig/Test/Node.php | 2 ++ lib/Twig/TokenParserBroker.php | 6 +++++- test/Twig/Tests/AutoloaderTest.php | 3 +++ 14 files changed, 31 insertions(+), 2 deletions(-) diff --git a/lib/Twig/Autoloader.php b/lib/Twig/Autoloader.php index 2af5157e7..d47583fbf 100644 --- a/lib/Twig/Autoloader.php +++ b/lib/Twig/Autoloader.php @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Autoloader class is deprecated and will be removed in 2.0. Use Composer instead.', E_USER_DEPRECATED); + /** * Autoloads Twig classes. * diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index 68517fdba..a0e3f7580 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -1198,7 +1198,7 @@ class Twig_Environment } $this->extensionInitialized = true; - $this->parsers = new Twig_TokenParserBroker(); + $this->parsers = new Twig_TokenParserBroker(array(), array(), false); $this->filters = array(); $this->functions = array(); $this->tests = array(); diff --git a/lib/Twig/Filter/Function.php b/lib/Twig/Filter/Function.php index 45c14c764..d679cab2f 100644 --- a/lib/Twig/Filter/Function.php +++ b/lib/Twig/Filter/Function.php @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Filter_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.', E_USER_DEPRECATED); + /** * Represents a function template filter. * diff --git a/lib/Twig/Filter/Method.php b/lib/Twig/Filter/Method.php index f32435ffd..655aab405 100644 --- a/lib/Twig/Filter/Method.php +++ b/lib/Twig/Filter/Method.php @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Filter_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.', E_USER_DEPRECATED); + /** * Represents a method template filter. * diff --git a/lib/Twig/Filter/Node.php b/lib/Twig/Filter/Node.php index efbcc29d9..a922f5037 100644 --- a/lib/Twig/Filter/Node.php +++ b/lib/Twig/Filter/Node.php @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Filter_Node class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.', E_USER_DEPRECATED); + /** * Represents a template filter as a node. * diff --git a/lib/Twig/Function/Function.php b/lib/Twig/Function/Function.php index e7f3845a5..ae83e153c 100644 --- a/lib/Twig/Function/Function.php +++ b/lib/Twig/Function/Function.php @@ -10,6 +10,8 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Function_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.', E_USER_DEPRECATED); + /** * Represents a function template function. * diff --git a/lib/Twig/Function/Method.php b/lib/Twig/Function/Method.php index 17a7bd870..ba9945ed5 100644 --- a/lib/Twig/Function/Method.php +++ b/lib/Twig/Function/Method.php @@ -10,6 +10,8 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Function_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.', E_USER_DEPRECATED); + /** * Represents a method template function. * diff --git a/lib/Twig/Function/Node.php b/lib/Twig/Function/Node.php index 550a379c5..118b0bab7 100644 --- a/lib/Twig/Function/Node.php +++ b/lib/Twig/Function/Node.php @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Function_Node class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.', E_USER_DEPRECATED); + /** * Represents a template function as a node. * diff --git a/lib/Twig/Loader/String.php b/lib/Twig/Loader/String.php index 63d6890a3..e7fff3e81 100644 --- a/lib/Twig/Loader/String.php +++ b/lib/Twig/Loader/String.php @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Loader_String class is deprecated since version 1.18.1 and will be removed in 2.0. Use Twig_Loader_Array instead.', E_USER_DEPRECATED); + /** * Loads a template from a string. * diff --git a/lib/Twig/Test/Function.php b/lib/Twig/Test/Function.php index 30e1c6230..5e76c711b 100644 --- a/lib/Twig/Test/Function.php +++ b/lib/Twig/Test/Function.php @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Test_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleTest instead.', E_USER_DEPRECATED); + /** * Represents a function template test. * diff --git a/lib/Twig/Test/Method.php b/lib/Twig/Test/Method.php index 7fc250baa..277998649 100644 --- a/lib/Twig/Test/Method.php +++ b/lib/Twig/Test/Method.php @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Test_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleTest instead.', E_USER_DEPRECATED); + /** * Represents a method template test. * diff --git a/lib/Twig/Test/Node.php b/lib/Twig/Test/Node.php index cdf0b24ac..baef49cce 100644 --- a/lib/Twig/Test/Node.php +++ b/lib/Twig/Test/Node.php @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Test_Node class is deprecated since version 1.12 and will be removed in 2.0.', E_USER_DEPRECATED); + /** * Represents a template test as a Node. * diff --git a/lib/Twig/TokenParserBroker.php b/lib/Twig/TokenParserBroker.php index 4a9cb5c69..6ca73fb38 100644 --- a/lib/Twig/TokenParserBroker.php +++ b/lib/Twig/TokenParserBroker.php @@ -29,8 +29,12 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface * @param array|Traversable $parsers A Traversable of Twig_TokenParserInterface instances * @param array|Traversable $brokers A Traversable of Twig_TokenParserBrokerInterface instances */ - public function __construct($parsers = array(), $brokers = array()) + public function __construct($parsers = array(), $brokers = array(), $triggerDeprecationError = true) { + if ($triggerDeprecationError) { + @trigger_error('The '.__CLASS__.' class is deprecated since version 1.12 and will be removed in 2.0.', E_USER_DEPRECATED); + } + foreach ($parsers as $parser) { if (!$parser instanceof Twig_TokenParserInterface) { throw new LogicException('$parsers must a an array of Twig_TokenParserInterface'); diff --git a/test/Twig/Tests/AutoloaderTest.php b/test/Twig/Tests/AutoloaderTest.php index c8b7999aa..52107c0c1 100644 --- a/test/Twig/Tests/AutoloaderTest.php +++ b/test/Twig/Tests/AutoloaderTest.php @@ -11,6 +11,9 @@ class Twig_Tests_AutoloaderTest extends PHPUnit_Framework_TestCase { + /** + * @group legacy + */ public function testAutoload() { $this->assertFalse(class_exists('FooBarFoo'), '->autoload() does not try to load classes that does not begin with Twig');