1 | <?php |
||
9 | class CompileNode |
||
10 | { |
||
11 | /** |
||
12 | * @var Node[] |
||
13 | */ |
||
14 | protected array $children = []; |
||
|
|||
15 | protected Dictionary $context; |
||
16 | |||
17 | public function __construct() |
||
18 | { |
||
19 | $this->context = new Dictionary(); |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * @return Node[] |
||
24 | */ |
||
25 | public function getChildren(): array |
||
26 | { |
||
27 | return $this->children; |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @param Node[] $children |
||
32 | */ |
||
33 | public function setChildren(array $children): void |
||
34 | { |
||
35 | $this->children = $children; |
||
36 | } |
||
37 | |||
38 | public function addChild(Node $node): void |
||
39 | { |
||
40 | $this->children[] = $node; |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * @param Node[] $nodes |
||
45 | */ |
||
46 | public function addChildren(array $nodes): void |
||
47 | { |
||
48 | $this->children = array_merge($this->children, $nodes); |
||
49 | } |
||
50 | |||
51 | public function getContext(): Dictionary |
||
52 | { |
||
53 | return $this->context; |
||
54 | } |
||
55 | |||
56 | public function setContext(Dictionary $context): void |
||
57 | { |
||
58 | $this->context = $context; |
||
59 | } |
||
60 | |||
61 | public function evaluate() |
||
62 | { |
||
63 | foreach ($this->children as $child) { |
||
64 | $child->evaluate(); |
||
65 | } |
||
66 | |||
67 | return null; |
||
68 | } |
||
69 | } |
||
70 |