Boolean.php 685 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) 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. /**
  11. * @deprecated since version 1.5
  12. */
  13. class Twig_Extensions_Grammar_Boolean extends Twig_Extensions_Grammar
  14. {
  15. public function __toString()
  16. {
  17. return sprintf('<%s:boolean>', $this->name);
  18. }
  19. public function parse(Twig_Token $token)
  20. {
  21. $this->parser->getStream()->expect(Twig_Token::NAME_TYPE, array('true', 'false'));
  22. return new Twig_Node_Expression_Constant('true' === $token->getValue() ? true : false, $token->getLine());
  23. }
  24. }