Skip to content

Commit e9045da

Browse files
committed
Use the new Nodes class for a better test
1 parent b446c1e commit e9045da

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Node/SetNode.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public function __construct(bool $capture, Node $names, Node $values, int $linen
3333
$safe = false;
3434
if ($capture) {
3535
$safe = true;
36-
if (Node::class === get_class($values) && !count($values)) {
36+
// Node::class === get_class($values) should be removed in Twig 4.0
37+
if (($values instanceof Nodes || Node::class === get_class($values)) && !count($values)) {
3738
$values = new ConstantExpression('', $values->getTemplateLine());
3839
$capture = false;
3940
} elseif ($values instanceof TextNode) {

src/Parser.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ private function filterBodyNodes(Node $node, bool $nested = false): ?Node
373373

374374
// here, $nested means "being at the root level of a child template"
375375
// we need to discard the wrapping "Node" for the "body" node
376-
$nested = $nested || Nodes::class !== \get_class($node);
376+
// The second part of the condition should be removed in Twig 4.0
377+
$nested = $nested || $node instanceof Nodes || Node::class !== \get_class($node);
377378
foreach ($node as $k => $n) {
378379
if (null !== $n && null === $this->filterBodyNodes($n, $nested)) {
379380
$node->removeNode($k);

0 commit comments

Comments
 (0)