db backup prior to drupal security update
[yaffs-website] / vendor / symfony / expression-language / Node / Node.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\ExpressionLanguage\Node;
13
14 use Symfony\Component\ExpressionLanguage\Compiler;
15
16 /**
17  * Represents a node in the AST.
18  *
19  * @author Fabien Potencier <fabien@symfony.com>
20  */
21 class Node
22 {
23     public $nodes = array();
24     public $attributes = array();
25
26     /**
27      * Constructor.
28      *
29      * @param array $nodes      An array of nodes
30      * @param array $attributes An array of attributes
31      */
32     public function __construct(array $nodes = array(), array $attributes = array())
33     {
34         $this->nodes = $nodes;
35         $this->attributes = $attributes;
36     }
37
38     public function __toString()
39     {
40         $attributes = array();
41         foreach ($this->attributes as $name => $value) {
42             $attributes[] = sprintf('%s: %s', $name, str_replace("\n", '', var_export($value, true)));
43         }
44
45         $repr = array(str_replace('Symfony\Component\ExpressionLanguage\Node\\', '', get_class($this)).'('.implode(', ', $attributes));
46
47         if (count($this->nodes)) {
48             foreach ($this->nodes as $node) {
49                 foreach (explode("\n", (string) $node) as $line) {
50                     $repr[] = '    '.$line;
51                 }
52             }
53
54             $repr[] = ')';
55         } else {
56             $repr[0] .= ')';
57         }
58
59         return implode("\n", $repr);
60     }
61
62     public function compile(Compiler $compiler)
63     {
64         foreach ($this->nodes as $node) {
65             $node->compile($compiler);
66         }
67     }
68
69     public function evaluate($functions, $values)
70     {
71         $results = array();
72         foreach ($this->nodes as $node) {
73             $results[] = $node->evaluate($functions, $values);
74         }
75
76         return $results;
77     }
78 }