vendor/twig/twig/src/TokenParser/DoTokenParser.php line 31

  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\DoNode;
  12. use Twig\Node\Node;
  13. use Twig\Token;
  14. /**
  15.  * Evaluates an expression, discarding the returned value.
  16.  *
  17.  * @internal
  18.  */
  19. final class DoTokenParser extends AbstractTokenParser
  20. {
  21.     public function parse(Token $token): Node
  22.     {
  23.         $expr $this->parser->getExpressionParser()->parseExpression();
  24.         $this->parser->getStream()->expect(/* Token::BLOCK_END_TYPE */ 3);
  25.         return new DoNode($expr$token->getLine(), $this->getTag());
  26.     }
  27.     public function getTag(): string
  28.     {
  29.         return 'do';
  30.     }
  31. }