4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\ExpressionLanguage\Node;
14 use Symfony\Component\ExpressionLanguage\Compiler;
17 * Represents a node in the AST.
19 * @author Fabien Potencier <fabien@symfony.com>
23 public $nodes = array();
24 public $attributes = array();
29 * @param array $nodes An array of nodes
30 * @param array $attributes An array of attributes
32 public function __construct(array $nodes = array(), array $attributes = array())
34 $this->nodes = $nodes;
35 $this->attributes = $attributes;
38 public function __toString()
40 $attributes = array();
41 foreach ($this->attributes as $name => $value) {
42 $attributes[] = sprintf('%s: %s', $name, str_replace("\n", '', var_export($value, true)));
45 $repr = array(str_replace('Symfony\Component\ExpressionLanguage\Node\\', '', get_class($this)).'('.implode(', ', $attributes));
47 if (count($this->nodes)) {
48 foreach ($this->nodes as $node) {
49 foreach (explode("\n", (string) $node) as $line) {
59 return implode("\n", $repr);
62 public function compile(Compiler $compiler)
64 foreach ($this->nodes as $node) {
65 $node->compile($compiler);
69 public function evaluate($functions, $values)
72 foreach ($this->nodes as $node) {
73 $results[] = $node->evaluate($functions, $values);