Do.php 980B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) 2011 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. /**
  11. * Evaluates an expression, disgarding the returned value.
  12. */
  13. class Twig_TokenParser_Do extends Twig_TokenParser
  14. {
  15. /**
  16. * Parses a token and returns a node.
  17. *
  18. * @param Twig_Token $token A Twig_Token instance
  19. *
  20. * @return Twig_NodeInterface A Twig_NodeInterface instance
  21. */
  22. public function parse(Twig_Token $token)
  23. {
  24. $expr = $this->parser->getExpressionParser()->parseExpression();
  25. $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
  26. return new Twig_Node_Do($expr, $token->getLine(), $this->getTag());
  27. }
  28. /**
  29. * Gets the tag name associated with this token parser.
  30. *
  31. * @return string The tag name
  32. */
  33. public function getTag()
  34. {
  35. return 'do';
  36. }
  37. }