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 Displaying Deprecation Notices for more information.
Twig_Environment::removeExtension()method will be removed in 2.0.
Twig_ExtensionInterface::initRuntime()method is deprecated. You have two options to avoid the deprecation notice: if you implement this method to store the environment for your custom filters, functions, or tests, use the
needs_environmentoption instead; if you have more complex needs, explicitly implement
Twig_ExtensionInterface::getGlobals()method is deprecated. Implement
Twig_Extension_GlobalsInterfaceto avoid deprecation notices.
PEAR support has been discontinued in Twig 1.15.1, and no PEAR packages are provided anymore. Use Composer instead.
Twig_SimpleFilterto add a filter. The following classes and interfaces will be removed in 2.0:
Twig_SimpleFilterclass is deprecated and will be removed in Twig 3.x (use
Twig_Filterinstead). In Twig 2.x,
Twig_SimpleFilteris just an alias for
Twig_SimpleFunctionto add a function. The following classes and interfaces will be removed in 2.0:
Twig_SimpleFunctionclass is deprecated and will be removed in Twig 3.x (use
Twig_Functioninstead). In Twig 2.x,
Twig_SimpleFunctionis just an alias for
Twig_SimpleTestto add a test. The following classes and interfaces will be removed in 2.0:
Twig_SimpleTestclass is deprecated and will be removed in Twig 3.x (use
Twig_Testinstead). In Twig 2.x,
Twig_SimpleTestis just an alias for
divisiblebytests are deprecated in favor of
Node::toXml()is deprecated and will be removed in Twig 2.0.
Twig_Templateinstead, and use those constants Twig_Template::ANY_CALL, Twig_Template::ARRAY_CALL, Twig_Template::METHOD_CALL)
Twig_Loader_Stringis deprecated and will be removed in 2.0. You can render a string via
Twig_NodeInterfacein 2.0, you need to extend
Twig_BaseNodeVisitorinstead of implementing
Twig_NodeVisitorInterfacedirectly to make your node visitors compatible with both Twig 1.x and 2.x.
_selfglobal variable to get access to the current
Twig_Templateinstance is deprecated; most usages only need the current template name, which will continue to work in Twig 2.0. In Twig 2.0,
_selfreturns the current template name instead of the current
Twig_Environment::getTemplateClassPrefix()are deprecated and will be removed in 2.0.
Twig_TemplateInterface::getEnvironment()are deprecated and will be removed in 2.0.