NameNode.php 903 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. [],
  23. ['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. public function toArray()
  35. {
  36. return [$this->attributes['name']];
  37. }
  38. }