Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame^] | 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of Twig. |
| 5 | * |
| 6 | * (c) Fabien Potencier |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | |
| 12 | namespace Twig\TokenParser; |
| 13 | |
| 14 | use Twig\Node\DoNode; |
| 15 | use Twig\Node\Node; |
| 16 | use Twig\Token; |
| 17 | |
| 18 | /** |
| 19 | * Evaluates an expression, discarding the returned value. |
| 20 | * |
| 21 | * @internal |
| 22 | */ |
| 23 | final class DoTokenParser extends AbstractTokenParser |
| 24 | { |
| 25 | public function parse(Token $token): Node |
| 26 | { |
| 27 | $expr = $this->parser->getExpressionParser()->parseExpression(); |
| 28 | |
| 29 | $this->parser->getStream()->expect(/* Token::BLOCK_END_TYPE */ 3); |
| 30 | |
| 31 | return new DoNode($expr, $token->getLine(), $this->getTag()); |
| 32 | } |
| 33 | |
| 34 | public function getTag(): string |
| 35 | { |
| 36 | return 'do'; |
| 37 | } |
| 38 | } |