mirror of
https://github.com/twigphp/Twig.git
synced 2026-10-05 03:16:52 +00:00
Move extends validation into correctness visitor
This commit is contained in:
+5
-1
@@ -414,7 +414,7 @@ class Parser
|
||||
return $this->parent || 0 < \count($this->traits);
|
||||
}
|
||||
|
||||
public function setParent(?Node $parent): void
|
||||
public function setParent(?Node $parent, bool $throwOnMultiple = true): void
|
||||
{
|
||||
if (null === $parent) {
|
||||
trigger_deprecation('twig/twig', '3.12', 'Passing "null" to "%s()" is deprecated.', __METHOD__);
|
||||
@@ -425,6 +425,10 @@ class Parser
|
||||
}
|
||||
|
||||
if (null !== $this->parent) {
|
||||
if (!$throwOnMultiple) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new SyntaxError('Multiple extends tags are forbidden.', $parent->getTemplateLine(), $parent->getSourceContext());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user