blob: 32c8f12ff866ea83ce8d045179ed19651e7c9e17 [file] [log] [blame]
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01001<?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
12namespace Twig\TokenParser;
13
14use Twig\Node\DoNode;
15use Twig\Node\Node;
16use Twig\Token;
17
18/**
19 * Evaluates an expression, discarding the returned value.
20 *
21 * @internal
22 */
23final 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}