mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-01 13:07:22 +00:00
Forbid adding Nodes to EmptyNode
This commit is contained in:
@@ -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.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user