Constant.php 811 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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_Constant extends Twig_Extensions_Grammar
  14. {
  15. protected $type;
  16. public function __construct($name, $type = null)
  17. {
  18. $this->name = $name;
  19. $this->type = null === $type ? Twig_Token::NAME_TYPE : $type;
  20. }
  21. public function __toString()
  22. {
  23. return $this->name;
  24. }
  25. public function parse(Twig_Token $token)
  26. {
  27. $this->parser->getStream()->expect($this->type, $this->name);
  28. return $this->name;
  29. }
  30. public function getType()
  31. {
  32. return $this->type;
  33. }
  34. }