Forbid adding Nodes to EmptyNode

This commit is contained in:
Fabien Potencier
2024-11-21 08:46:26 +01:00
parent 8f3f8df9cd
commit ff55f590e7
2 changed files with 10 additions and 5 deletions
+5
View File
@@ -25,4 +25,9 @@ final class EmptyNode extends Node
{
parent::__construct([], [], $lineno);
}
public function setNode(string $name, Node $node): void
{
throw new \LogicException('EmptyNode cannot have children.');
}
}
+5 -5
View File
@@ -44,11 +44,11 @@ final class ModuleNode extends Node
'blocks' => $blocks,
'macros' => $macros,
'traits' => $traits,
'display_start' => new EmptyNode(),
'display_end' => new EmptyNode(),
'constructor_start' => new EmptyNode(),
'constructor_end' => new EmptyNode(),
'class_end' => new EmptyNode(),
'display_start' => new Nodes(),
'display_end' => new Nodes(),
'constructor_start' => new Nodes(),
'constructor_end' => new Nodes(),
'class_end' => new Nodes(),
];
if (null !== $parent) {
$nodes['parent'] = $parent;