Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aa8d78c

Browse files
committed
do not add child nodes to EmptyNode instances
1 parent 85419bc commit aa8d78c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Bridge\Twig\Node\TransNode;
1616
use Twig\Environment;
1717
use Twig\Node\BlockNode;
18+
use Twig\Node\EmptyNode;
1819
use Twig\Node\Expression\ArrayExpression;
1920
use Twig\Node\Expression\AssignNameExpression;
2021
use Twig\Node\Expression\ConstantExpression;
@@ -70,11 +71,21 @@ public function enterNode(Node $node, Environment $env): Node
7071

7172
if ($node instanceof FilterExpression && 'trans' === ($node->hasAttribute('twig_callable') ? $node->getAttribute('twig_callable')->getName() : $node->getNode('filter')->getAttribute('value'))) {
7273
$arguments = $node->getNode('arguments');
74+
75+
if ($arguments instanceof EmptyNode) {
76+
$arguments = new Nodes();
77+
$node->setNode('arguments', $arguments);
78+
}
79+
7380
if ($this->isNamedArguments($arguments)) {
7481
if (!$arguments->hasNode('domain') && !$arguments->hasNode(1)) {
7582
$arguments->setNode('domain', $this->scope->get('domain'));
7683
}
7784
} elseif (!$arguments->hasNode(1)) {
85+
if ($arguments instanceof EmptyNode) {
86+
$arguments = new Nodes();
87+
$node->setNode('arguments', $arguments);
88+
}
7889
if (!$arguments->hasNode(0)) {
7990
$arguments->setNode(0, new ArrayExpression([], $node->getTemplateLine()));
8091
}

0 commit comments

Comments
 (0)