vendor/twig/twig/src/TokenParser/DeprecatedTokenParser.php line 36

  1. <?php
  2. /*
  3.  * This file is part of Twig.
  4.  *
  5.  * (c) Fabien Potencier
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Twig\TokenParser;
  11. use Twig\Node\DeprecatedNode;
  12. use Twig\Node\Node;
  13. use Twig\Token;
  14. /**
  15.  * Deprecates a section of a template.
  16.  *
  17.  *    {% deprecated 'The "base.twig" template is deprecated, use "layout.twig" instead.' %}
  18.  *    {% extends 'layout.html.twig' %}
  19.  *
  20.  * @author Yonel Ceruto <yonelceruto@gmail.com>
  21.  *
  22.  * @internal
  23.  */
  24. final class DeprecatedTokenParser extends AbstractTokenParser
  25. {
  26.     public function parse(Token $token): Node
  27.     {
  28.         $expr $this->parser->getExpressionParser()->parseExpression();
  29.         $this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
  30.         return new DeprecatedNode($expr$token->getLine(), $this->getTag());
  31.     }
  32.     public function getTag(): string
  33.     {
  34.         return 'deprecated';
  35.     }
  36. }