NameNode.php 826 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\ExpressionLanguage\Node;
  11. use Symfony\Component\ExpressionLanguage\Compiler;
  12. /**
  13. * @author Fabien Potencier <fabien@symfony.com>
  14. *
  15. * @internal
  16. */
  17. class NameNode extends Node
  18. {
  19. public function __construct($name)
  20. {
  21. parent::__construct(
  22. array(),
  23. array('name' => $name)
  24. );
  25. }
  26. public function compile(Compiler $compiler)
  27. {
  28. $compiler->raw('$'.$this->attributes['name']);
  29. }
  30. public function evaluate($functions, $values)
  31. {
  32. return $values[$this->attributes['name']];
  33. }
  34. }