Debug.php 1.1KB

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