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

Open in your IDE?
  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\Token;
  13. /**
  14. * Deprecates a section of a template.
  15. *
  16. * {% deprecated 'The "base.twig" template is deprecated, use "layout.twig" instead.' %}
  17. * {% extends 'layout.html.twig' %}
  18. *
  19. * @author Yonel Ceruto <yonelceruto@gmail.com>
  20. *
  21. * @final
  22. */
  23. class DeprecatedTokenParser extends AbstractTokenParser
  24. {
  25. public function parse(Token $token)
  26. {
  27. $expr = $this->parser->getExpressionParser()->parseExpression();
  28. $this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
  29. return new DeprecatedNode($expr, $token->getLine(), $this->getTag());
  30. }
  31. public function getTag()
  32. {
  33. return 'deprecated';
  34. }
  35. }
  36. class_alias('Twig\TokenParser\DeprecatedTokenParser', 'Twig_TokenParser_Deprecated');