vendor/twig/twig/src/Template.php line 455

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of Twig.
  4.  *
  5.  * (c) Fabien Potencier
  6.  * (c) Armin Ronacher
  7.  *
  8.  * For the full copyright and license information, please view the LICENSE
  9.  * file that was distributed with this source code.
  10.  */
  11. namespace Twig;
  12. use Twig\Error\Error;
  13. use Twig\Error\LoaderError;
  14. use Twig\Error\RuntimeError;
  15. /**
  16.  * Default base class for compiled templates.
  17.  *
  18.  * This class is an implementation detail of how template compilation currently
  19.  * works, which might change. It should never be used directly. Use $twig->load()
  20.  * instead, which returns an instance of \Twig\TemplateWrapper.
  21.  *
  22.  * @author Fabien Potencier <fabien@symfony.com>
  23.  *
  24.  * @internal
  25.  */
  26. abstract class Template implements \Twig_TemplateInterface
  27. {
  28.     /**
  29.      * @internal
  30.      */
  31.     protected static $cache = [];
  32.     protected $parent;
  33.     protected $parents = [];
  34.     protected $env;
  35.     protected $blocks = [];
  36.     protected $traits = [];
  37.     protected $sandbox;
  38.     public function __construct(Environment $env)
  39.     {
  40.         $this->env $env;
  41.     }
  42.     /**
  43.      * @internal this method will be removed in 2.0 and is only used internally to provide an upgrade path from 1.x to 2.0
  44.      */
  45.     public function __toString()
  46.     {
  47.         return $this->getTemplateName();
  48.     }
  49.     /**
  50.      * Returns the template name.
  51.      *
  52.      * @return string The template name
  53.      */
  54.     abstract public function getTemplateName();
  55.     /**
  56.      * Returns debug information about the template.
  57.      *
  58.      * @return array Debug information
  59.      */
  60.     public function getDebugInfo()
  61.     {
  62.         return [];
  63.     }
  64.     /**
  65.      * Returns the template source code.
  66.      *
  67.      * @return string The template source code
  68.      *
  69.      * @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead
  70.      */
  71.     public function getSource()
  72.     {
  73.         @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.'E_USER_DEPRECATED);
  74.         return '';
  75.     }
  76.     /**
  77.      * Returns information about the original template source code.
  78.      *
  79.      * @return Source
  80.      */
  81.     public function getSourceContext()
  82.     {
  83.         return new Source(''$this->getTemplateName());
  84.     }
  85.     /**
  86.      * @deprecated since 1.20 (to be removed in 2.0)
  87.      */
  88.     public function getEnvironment()
  89.     {
  90.         @trigger_error('The '.__METHOD__.' method is deprecated since version 1.20 and will be removed in 2.0.'E_USER_DEPRECATED);
  91.         return $this->env;
  92.     }
  93.     /**
  94.      * Returns the parent template.
  95.      *
  96.      * This method is for internal use only and should never be called
  97.      * directly.
  98.      *
  99.      * @param array $context
  100.      *
  101.      * @return \Twig_TemplateInterface|TemplateWrapper|false The parent template or false if there is no parent
  102.      *
  103.      * @internal
  104.      */
  105.     public function getParent(array $context)
  106.     {
  107.         if (null !== $this->parent) {
  108.             return $this->parent;
  109.         }
  110.         try {
  111.             $parent $this->doGetParent($context);
  112.             if (false === $parent) {
  113.                 return false;
  114.             }
  115.             if ($parent instanceof self || $parent instanceof TemplateWrapper) {
  116.                 return $this->parents[$parent->getSourceContext()->getName()] = $parent;
  117.             }
  118.             if (!isset($this->parents[$parent])) {
  119.                 $this->parents[$parent] = $this->loadTemplate($parent);
  120.             }
  121.         } catch (LoaderError $e) {
  122.             $e->setSourceContext(null);
  123.             $e->guess();
  124.             throw $e;
  125.         }
  126.         return $this->parents[$parent];
  127.     }
  128.     protected function doGetParent(array $context)
  129.     {
  130.         return false;
  131.     }
  132.     public function isTraitable()
  133.     {
  134.         return true;
  135.     }
  136.     /**
  137.      * Displays a parent block.
  138.      *
  139.      * This method is for internal use only and should never be called
  140.      * directly.
  141.      *
  142.      * @param string $name    The block name to display from the parent
  143.      * @param array  $context The context
  144.      * @param array  $blocks  The current set of blocks
  145.      */
  146.     public function displayParentBlock($name, array $context, array $blocks = [])
  147.     {
  148.         $name = (string) $name;
  149.         if (isset($this->traits[$name])) {
  150.             $this->traits[$name][0]->displayBlock($name$context$blocksfalse);
  151.         } elseif (false !== $parent $this->getParent($context)) {
  152.             $parent->displayBlock($name$context$blocksfalse);
  153.         } else {
  154.             throw new RuntimeError(sprintf('The template has no parent and no traits defining the "%s" block.'$name), -1$this->getSourceContext());
  155.         }
  156.     }
  157.     /**
  158.      * Displays a block.
  159.      *
  160.      * This method is for internal use only and should never be called
  161.      * directly.
  162.      *
  163.      * @param string $name      The block name to display
  164.      * @param array  $context   The context
  165.      * @param array  $blocks    The current set of blocks
  166.      * @param bool   $useBlocks Whether to use the current set of blocks
  167.      */
  168.     public function displayBlock($name, array $context, array $blocks = [], $useBlocks true)
  169.     {
  170.         $name = (string) $name;
  171.         if ($useBlocks && isset($blocks[$name])) {
  172.             $template $blocks[$name][0];
  173.             $block $blocks[$name][1];
  174.         } elseif (isset($this->blocks[$name])) {
  175.             $template $this->blocks[$name][0];
  176.             $block $this->blocks[$name][1];
  177.         } else {
  178.             $template null;
  179.             $block null;
  180.         }
  181.         // avoid RCEs when sandbox is enabled
  182.         if (null !== $template && !$template instanceof self) {
  183.             throw new \LogicException('A block must be a method on a \Twig\Template instance.');
  184.         }
  185.         if (null !== $template) {
  186.             try {
  187.                 $template->$block($context$blocks);
  188.             } catch (Error $e) {
  189.                 if (!$e->getSourceContext()) {
  190.                     $e->setSourceContext($template->getSourceContext());
  191.                 }
  192.                 // this is mostly useful for \Twig\Error\LoaderError exceptions
  193.                 // see \Twig\Error\LoaderError
  194.                 if (-=== $e->getTemplateLine()) {
  195.                     $e->guess();
  196.                 }
  197.                 throw $e;
  198.             } catch (\Exception $e) {
  199.                 $e = new RuntimeError(sprintf('An exception has been thrown during the rendering of a template ("%s").'$e->getMessage()), -1$template->getSourceContext(), $e);
  200.                 $e->guess();
  201.                 throw $e;
  202.             }
  203.         } elseif (false !== $parent $this->getParent($context)) {
  204.             $parent->displayBlock($name$contextarray_merge($this->blocks$blocks), false);
  205.         } else {
  206.             @trigger_error(sprintf('Silent display of undefined block "%s" in template "%s" is deprecated since version 1.29 and will throw an exception in 2.0. Use the "block(\'%s\') is defined" expression to test for block existence.'$name$this->getTemplateName(), $name), E_USER_DEPRECATED);
  207.         }
  208.     }
  209.     /**
  210.      * Renders a parent block.
  211.      *
  212.      * This method is for internal use only and should never be called
  213.      * directly.
  214.      *
  215.      * @param string $name    The block name to render from the parent
  216.      * @param array  $context The context
  217.      * @param array  $blocks  The current set of blocks
  218.      *
  219.      * @return string The rendered block
  220.      */
  221.     public function renderParentBlock($name, array $context, array $blocks = [])
  222.     {
  223.         if ($this->env->isDebug()) {
  224.             ob_start();
  225.         } else {
  226.             ob_start(function () { return ''; });
  227.         }
  228.         $this->displayParentBlock($name$context$blocks);
  229.         return ob_get_clean();
  230.     }
  231.     /**
  232.      * Renders a block.
  233.      *
  234.      * This method is for internal use only and should never be called
  235.      * directly.
  236.      *
  237.      * @param string $name      The block name to render
  238.      * @param array  $context   The context
  239.      * @param array  $blocks    The current set of blocks
  240.      * @param bool   $useBlocks Whether to use the current set of blocks
  241.      *
  242.      * @return string The rendered block
  243.      */
  244.     public function renderBlock($name, array $context, array $blocks = [], $useBlocks true)
  245.     {
  246.         if ($this->env->isDebug()) {
  247.             ob_start();
  248.         } else {
  249.             ob_start(function () { return ''; });
  250.         }
  251.         $this->displayBlock($name$context$blocks$useBlocks);
  252.         return ob_get_clean();
  253.     }
  254.     /**
  255.      * Returns whether a block exists or not in the current context of the template.
  256.      *
  257.      * This method checks blocks defined in the current template
  258.      * or defined in "used" traits or defined in parent templates.
  259.      *
  260.      * @param string $name    The block name
  261.      * @param array  $context The context
  262.      * @param array  $blocks  The current set of blocks
  263.      *
  264.      * @return bool true if the block exists, false otherwise
  265.      */
  266.     public function hasBlock($name, array $context null, array $blocks = [])
  267.     {
  268.         if (null === $context) {
  269.             @trigger_error('The '.__METHOD__.' method is internal and should never be called; calling it directly is deprecated since version 1.28 and won\'t be possible anymore in 2.0.'E_USER_DEPRECATED);
  270.             return isset($this->blocks[(string) $name]);
  271.         }
  272.         if (isset($blocks[$name])) {
  273.             return $blocks[$name][0] instanceof self;
  274.         }
  275.         if (isset($this->blocks[$name])) {
  276.             return true;
  277.         }
  278.         if (false !== $parent $this->getParent($context)) {
  279.             return $parent->hasBlock($name$context);
  280.         }
  281.         return false;
  282.     }
  283.     /**
  284.      * Returns all block names in the current context of the template.
  285.      *
  286.      * This method checks blocks defined in the current template
  287.      * or defined in "used" traits or defined in parent templates.
  288.      *
  289.      * @param array $context The context
  290.      * @param array $blocks  The current set of blocks
  291.      *
  292.      * @return array An array of block names
  293.      */
  294.     public function getBlockNames(array $context null, array $blocks = [])
  295.     {
  296.         if (null === $context) {
  297.             @trigger_error('The '.__METHOD__.' method is internal and should never be called; calling it directly is deprecated since version 1.28 and won\'t be possible anymore in 2.0.'E_USER_DEPRECATED);
  298.             return array_keys($this->blocks);
  299.         }
  300.         $names array_merge(array_keys($blocks), array_keys($this->blocks));
  301.         if (false !== $parent $this->getParent($context)) {
  302.             $names array_merge($names$parent->getBlockNames($context));
  303.         }
  304.         return array_unique($names);
  305.     }
  306.     /**
  307.      * @return Template|TemplateWrapper
  308.      */
  309.     protected function loadTemplate($template$templateName null$line null$index null)
  310.     {
  311.         try {
  312.             if (\is_array($template)) {
  313.                 return $this->env->resolveTemplate($template);
  314.             }
  315.             if ($template instanceof self || $template instanceof TemplateWrapper) {
  316.                 return $template;
  317.             }
  318.             if ($template === $this->getTemplateName()) {
  319.                 $class = \get_class($this);
  320.                 if (false !== $pos strrpos($class'___', -1)) {
  321.                     $class substr($class0$pos);
  322.                 }
  323.                 return $this->env->loadClass($class$template$index);
  324.             }
  325.             return $this->env->loadTemplate($template$index);
  326.         } catch (Error $e) {
  327.             if (!$e->getSourceContext()) {
  328.                 $e->setSourceContext($templateName ? new Source(''$templateName) : $this->getSourceContext());
  329.             }
  330.             if ($e->getTemplateLine() > 0) {
  331.                 throw $e;
  332.             }
  333.             if (!$line) {
  334.                 $e->guess();
  335.             } else {
  336.                 $e->setTemplateLine($line);
  337.             }
  338.             throw $e;
  339.         }
  340.     }
  341.     /**
  342.      * @internal
  343.      *
  344.      * @return Template
  345.      */
  346.     protected function unwrap()
  347.     {
  348.         return $this;
  349.     }
  350.     /**
  351.      * Returns all blocks.
  352.      *
  353.      * This method is for internal use only and should never be called
  354.      * directly.
  355.      *
  356.      * @return array An array of blocks
  357.      */
  358.     public function getBlocks()
  359.     {
  360.         return $this->blocks;
  361.     }
  362.     public function display(array $context, array $blocks = [])
  363.     {
  364.         $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks$blocks));
  365.     }
  366.     public function render(array $context)
  367.     {
  368.         $level ob_get_level();
  369.         if ($this->env->isDebug()) {
  370.             ob_start();
  371.         } else {
  372.             ob_start(function () { return ''; });
  373.         }
  374.         try {
  375.             $this->display($context);
  376.         } catch (\Exception $e) {
  377.             while (ob_get_level() > $level) {
  378.                 ob_end_clean();
  379.             }
  380.             throw $e;
  381.         } catch (\Throwable $e) {
  382.             while (ob_get_level() > $level) {
  383.                 ob_end_clean();
  384.             }
  385.             throw $e;
  386.         }
  387.         return ob_get_clean();
  388.     }
  389.     protected function displayWithErrorHandling(array $context, array $blocks = [])
  390.     {
  391.         try {
  392.             $this->doDisplay($context$blocks);
  393.         } catch (Error $e) {
  394.             if (!$e->getSourceContext()) {
  395.                 $e->setSourceContext($this->getSourceContext());
  396.             }
  397.             // this is mostly useful for \Twig\Error\LoaderError exceptions
  398.             // see \Twig\Error\LoaderError
  399.             if (-=== $e->getTemplateLine()) {
  400.                 $e->guess();
  401.             }
  402.             throw $e;
  403.         } catch (\Exception $e) {
  404.             $e = new RuntimeError(sprintf('An exception has been thrown during the rendering of a template ("%s").'$e->getMessage()), -1$this->getSourceContext(), $e);
  405.             $e->guess();
  406.             throw $e;
  407.         }
  408.     }
  409.     /**
  410.      * Auto-generated method to display the template with the given context.
  411.      *
  412.      * @param array $context An array of parameters to pass to the template
  413.      * @param array $blocks  An array of blocks to pass to the template
  414.      */
  415.     abstract protected function doDisplay(array $context, array $blocks = []);
  416.     /**
  417.      * Returns a variable from the context.
  418.      *
  419.      * This method is for internal use only and should never be called
  420.      * directly.
  421.      *
  422.      * This method should not be overridden in a sub-class as this is an
  423.      * implementation detail that has been introduced to optimize variable
  424.      * access for versions of PHP before 5.4. This is not a way to override
  425.      * the way to get a variable value.
  426.      *
  427.      * @param array  $context           The context
  428.      * @param string $item              The variable to return from the context
  429.      * @param bool   $ignoreStrictCheck Whether to ignore the strict variable check or not
  430.      *
  431.      * @return mixed The content of the context variable
  432.      *
  433.      * @throws RuntimeError if the variable does not exist and Twig is running in strict mode
  434.      *
  435.      * @internal
  436.      */
  437.     final protected function getContext($context$item$ignoreStrictCheck false)
  438.     {
  439.         if (!\array_key_exists($item$context)) {
  440.             if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
  441.                 return;
  442.             }
  443.             throw new RuntimeError(sprintf('Variable "%s" does not exist.'$item), -1$this->getSourceContext());
  444.         }
  445.         return $context[$item];
  446.     }
  447.     /**
  448.      * Returns the attribute value for a given array/object.
  449.      *
  450.      * @param mixed  $object            The object or array from where to get the item
  451.      * @param mixed  $item              The item to get from the array or object
  452.      * @param array  $arguments         An array of arguments to pass if the item is an object method
  453.      * @param string $type              The type of attribute (@see \Twig\Template constants)
  454.      * @param bool   $isDefinedTest     Whether this is only a defined check
  455.      * @param bool   $ignoreStrictCheck Whether to ignore the strict attribute check or not
  456.      *
  457.      * @return mixed The attribute value, or a Boolean when $isDefinedTest is true, or null when the attribute is not set and $ignoreStrictCheck is true
  458.      *
  459.      * @throws RuntimeError if the attribute does not exist and Twig is running in strict mode and $isDefinedTest is false
  460.      *
  461.      * @internal
  462.      */
  463.     protected function getAttribute($object$item, array $arguments = [], $type self::ANY_CALL$isDefinedTest false$ignoreStrictCheck false)
  464.     {
  465.         // array
  466.         if (self::METHOD_CALL !== $type) {
  467.             $arrayItem = \is_bool($item) || \is_float($item) ? (int) $item $item;
  468.             if (((\is_array($object) || $object instanceof \ArrayObject) && (isset($object[$arrayItem]) || \array_key_exists($arrayItem, (array) $object)))
  469.                 || ($object instanceof \ArrayAccess && isset($object[$arrayItem]))
  470.             ) {
  471.                 if ($isDefinedTest) {
  472.                     return true;
  473.                 }
  474.                 return $object[$arrayItem];
  475.             }
  476.             if (self::ARRAY_CALL === $type || !\is_object($object)) {
  477.                 if ($isDefinedTest) {
  478.                     return false;
  479.                 }
  480.                 if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
  481.                     return;
  482.                 }
  483.                 if ($object instanceof \ArrayAccess) {
  484.                     $message sprintf('Key "%s" in object with ArrayAccess of class "%s" does not exist.'$arrayItem, \get_class($object));
  485.                 } elseif (\is_object($object)) {
  486.                     $message sprintf('Impossible to access a key "%s" on an object of class "%s" that does not implement ArrayAccess interface.'$item, \get_class($object));
  487.                 } elseif (\is_array($object)) {
  488.                     if (empty($object)) {
  489.                         $message sprintf('Key "%s" does not exist as the array is empty.'$arrayItem);
  490.                     } else {
  491.                         $message sprintf('Key "%s" for array with keys "%s" does not exist.'$arrayItemimplode(', 'array_keys($object)));
  492.                     }
  493.                 } elseif (self::ARRAY_CALL === $type) {
  494.                     if (null === $object) {
  495.                         $message sprintf('Impossible to access a key ("%s") on a null variable.'$item);
  496.                     } else {
  497.                         $message sprintf('Impossible to access a key ("%s") on a %s variable ("%s").'$item, \gettype($object), $object);
  498.                     }
  499.                 } elseif (null === $object) {
  500.                     $message sprintf('Impossible to access an attribute ("%s") on a null variable.'$item);
  501.                 } else {
  502.                     $message sprintf('Impossible to access an attribute ("%s") on a %s variable ("%s").'$item, \gettype($object), $object);
  503.                 }
  504.                 throw new RuntimeError($message, -1$this->getSourceContext());
  505.             }
  506.         }
  507.         if (!\is_object($object)) {
  508.             if ($isDefinedTest) {
  509.                 return false;
  510.             }
  511.             if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
  512.                 return;
  513.             }
  514.             if (null === $object) {
  515.                 $message sprintf('Impossible to invoke a method ("%s") on a null variable.'$item);
  516.             } elseif (\is_array($object)) {
  517.                 $message sprintf('Impossible to invoke a method ("%s") on an array.'$item);
  518.             } else {
  519.                 $message sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s").'$item, \gettype($object), $object);
  520.             }
  521.             throw new RuntimeError($message, -1$this->getSourceContext());
  522.         }
  523.         // object property
  524.         if (self::METHOD_CALL !== $type && !$object instanceof self) { // \Twig\Template does not have public properties, and we don't want to allow access to internal ones
  525.             if (isset($object->$item) || \array_key_exists((string) $item, (array) $object)) {
  526.                 if ($isDefinedTest) {
  527.                     return true;
  528.                 }
  529.                 if ($this->env->hasExtension('\Twig\Extension\SandboxExtension')) {
  530.                     $this->env->getExtension('\Twig\Extension\SandboxExtension')->checkPropertyAllowed($object$item);
  531.                 }
  532.                 return $object->$item;
  533.             }
  534.         }
  535.         $class = \get_class($object);
  536.         // object method
  537.         if (!isset(self::$cache[$class])) {
  538.             // get_class_methods returns all methods accessible in the scope, but we only want public ones to be accessible in templates
  539.             if ($object instanceof self) {
  540.                 $ref = new \ReflectionClass($class);
  541.                 $methods = [];
  542.                 foreach ($ref->getMethods(\ReflectionMethod::IS_PUBLIC) as $refMethod) {
  543.                     // Accessing the environment from templates is forbidden to prevent untrusted changes to the environment
  544.                     if ('getenvironment' !== strtr($refMethod->name'ABCDEFGHIJKLMNOPQRSTUVWXYZ''abcdefghijklmnopqrstuvwxyz')) {
  545.                         $methods[] = $refMethod->name;
  546.                     }
  547.                 }
  548.             } else {
  549.                 $methods get_class_methods($object);
  550.             }
  551.             // sort values to have consistent behavior, so that "get" methods win precedence over "is" methods
  552.             sort($methods);
  553.             $cache = [];
  554.             foreach ($methods as $method) {
  555.                 $cache[$method] = $method;
  556.                 $cache[$lcName strtr($method'ABCDEFGHIJKLMNOPQRSTUVWXYZ''abcdefghijklmnopqrstuvwxyz')] = $method;
  557.                 if ('g' === $lcName[0] && === strpos($lcName'get')) {
  558.                     $name substr($method3);
  559.                     $lcName substr($lcName3);
  560.                 } elseif ('i' === $lcName[0] && === strpos($lcName'is')) {
  561.                     $name substr($method2);
  562.                     $lcName substr($lcName2);
  563.                 } else {
  564.                     continue;
  565.                 }
  566.                 // skip get() and is() methods (in which case, $name is empty)
  567.                 if ($name) {
  568.                     if (!isset($cache[$name])) {
  569.                         $cache[$name] = $method;
  570.                     }
  571.                     if (!isset($cache[$lcName])) {
  572.                         $cache[$lcName] = $method;
  573.                     }
  574.                 }
  575.             }
  576.             self::$cache[$class] = $cache;
  577.         }
  578.         $call false;
  579.         if (isset(self::$cache[$class][$item])) {
  580.             $method self::$cache[$class][$item];
  581.         } elseif (isset(self::$cache[$class][$lcItem strtr($item'ABCDEFGHIJKLMNOPQRSTUVWXYZ''abcdefghijklmnopqrstuvwxyz')])) {
  582.             $method self::$cache[$class][$lcItem];
  583.         } elseif (isset(self::$cache[$class]['__call'])) {
  584.             $method $item;
  585.             $call true;
  586.         } else {
  587.             if ($isDefinedTest) {
  588.                 return false;
  589.             }
  590.             if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
  591.                 return;
  592.             }
  593.             throw new RuntimeError(sprintf('Neither the property "%1$s" nor one of the methods "%1$s()", "get%1$s()"/"is%1$s()" or "__call()" exist and have public access in class "%2$s".'$item$class), -1$this->getSourceContext());
  594.         }
  595.         if ($isDefinedTest) {
  596.             return true;
  597.         }
  598.         if ($this->env->hasExtension('\Twig\Extension\SandboxExtension')) {
  599.             $this->env->getExtension('\Twig\Extension\SandboxExtension')->checkMethodAllowed($object$method);
  600.         }
  601.         // Some objects throw exceptions when they have __call, and the method we try
  602.         // to call is not supported. If ignoreStrictCheck is true, we should return null.
  603.         try {
  604.             if (!$arguments) {
  605.                 $ret $object->$method();
  606.             } else {
  607.                 $ret = \call_user_func_array([$object$method], $arguments);
  608.             }
  609.         } catch (\BadMethodCallException $e) {
  610.             if ($call && ($ignoreStrictCheck || !$this->env->isStrictVariables())) {
  611.                 return;
  612.             }
  613.             throw $e;
  614.         }
  615.         // @deprecated in 1.28
  616.         if ($object instanceof \Twig_TemplateInterface) {
  617.             $self $object->getTemplateName() === $this->getTemplateName();
  618.             $message sprintf('Calling "%s" on template "%s" from template "%s" is deprecated since version 1.28 and won\'t be supported anymore in 2.0.'$item$object->getTemplateName(), $this->getTemplateName());
  619.             if ('renderBlock' === $method || 'displayBlock' === $method) {
  620.                 $message .= sprintf(' Use block("%s"%s) instead).'$arguments[0], $self '' ', template');
  621.             } elseif ('hasBlock' === $method) {
  622.                 $message .= sprintf(' Use "block("%s"%s) is defined" instead).'$arguments[0], $self '' ', template');
  623.             } elseif ('render' === $method || 'display' === $method) {
  624.                 $message .= sprintf(' Use include("%s") instead).'$object->getTemplateName());
  625.             }
  626.             @trigger_error($messageE_USER_DEPRECATED);
  627.             return '' === $ret '' : new Markup($ret$this->env->getCharset());
  628.         }
  629.         return $ret;
  630.     }
  631. }
  632. class_alias('Twig\Template''Twig_Template');