This document lists all deprecated features in Twig. Deprecated features are kept for backward compatibility and removed in the next major release (a feature that was deprecated in Twig 1.x is removed in Twig 2.0).
As of Twig 1.21, Twig generates deprecation notices when a template uses deprecated features. See deprecation-notices
for more information.
- As of Twig 1.x, the token parser broker sub-system is deprecated. The following class and interface will be removed in 2.0:
Twig_TokenParserBrokerInterface
Twig_TokenParserBroker
- As of Twig 1.x, the ability to remove an extension is deprecated and the
Twig_Environment::removeExtension()
method will be removed in 2.0.
PEAR support has been discontinued in Twig 1.15.1, and no PEAR packages are provided anymore. Use Composer instead.
- As of Twig 1.x, use
Twig_SimpleFilter
to add a filter. The following classes and interfaces will be removed in 2.0:Twig_FilterInterface
Twig_FilterCallableInterface
Twig_Filter
Twig_Filter_Function
Twig_Filter_Method
Twig_Filter_Node
- As of Twig 2.x, the
Twig_SimpleFilter
class is deprecated and will be removed in Twig 3.x (useTwig_Filter
instead). In Twig 2.x,Twig_SimpleFilter
is just an alias forTwig_Filter
.
- As of Twig 1.x, use
Twig_SimpleFunction
to add a function. The following classes and interfaces will be removed in 2.0:Twig_FunctionInterface
Twig_FunctionCallableInterface
Twig_Function
Twig_Function_Function
Twig_Function_Method
Twig_Function_Node
- As of Twig 2.x, the
Twig_SimpleFunction
class is deprecated and will be removed in Twig 3.x (useTwig_Function
instead). In Twig 2.x,Twig_SimpleFunction
is just an alias forTwig_Function
.
- As of Twig 1.x, use
Twig_SimpleTest
to add a test. The following classes and interfaces will be removed in 2.0:Twig_TestInterface
Twig_TestCallableInterface
Twig_Test
Twig_Test_Function
Twig_Test_Method
Twig_Test_Node
- As of Twig 2.x, the
Twig_SimpleTest
class is deprecated and will be removed in Twig 3.x (useTwig_Test
instead). In Twig 2.x,Twig_SimpleTest
is just an alias forTwig_Test
. - The
sameas
anddivisibleby
tests are deprecated in favor ofsame as
anddivisible by
respectively.
- As of Twig 1.x, the
raw
tag is deprecated. You should useverbatim
instead.
- As of Twig 1.x,
Node::toXml()
is deprecated and will be removed in Twig 2.0.
- As of Twig 2.x, the following interfaces are deprecated and empty (they will be removed in Twig 3.0):
Twig_CompilerInterface
(useTwig_Compiler
instead)Twig_LexerInterface
(useTwig_Lexer
instead)Twig_NodeInterface
(useTwig_Node
instead)Twig_ParserInterface
(useTwig_Parser
instead)Twig_ExistsLoaderInterface
(merged withTwig_LoaderInterface
)Twig_TemplateInterface
(useTwig_Template
instead, and use those constants Twig_Template::ANY_CALL, Twig_Template::ARRAY_CALL, Twig_Template::METHOD_CALL)
- As of Twig 1.x,
Twig_Loader_String
is deprecated and will be removed in 2.0.
- Because of the removal of
Twig_NodeInterface
in 2.0, you need to extendTwig_BaseNodeVistor
instead of implementingTwig_NodeVisitorInterface
directly to make your node visitors compatible with both Twig 1.x and 2.x.
- As of Twig 2.x, the ability to register a global variable after the runtime or the extensions have been initialized is not possible anymore (but changing the value of an already registered global is possible).
- As of Twig 1.x, the
_self
global variable is deprecated except for usage in thefrom
and theimport
tags. In Twig 2.0,_self
is not exposed anymore but still usable in thefrom
and theimport
tags.
- As of Twig 1.x,
Twig_Environment::clearTemplateCache()
is deprecated and will be removed in 2.0. - As of Twig 1.x,
Twig_Template::getEnvironment()
andTwig_TemplateInterface::getEnvironment()
are deprecated and will be removed in 2.0.