From 5ad1aca4df8edd4a62803f6e764c80e0183b9db6 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 29 Nov 2024 21:18:15 +0100 Subject: [PATCH] Fix code --- src/Node/Expression/Binary/NullCoalesceBinary.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Node/Expression/Binary/NullCoalesceBinary.php b/src/Node/Expression/Binary/NullCoalesceBinary.php index 6fb088fa62..af7137388c 100644 --- a/src/Node/Expression/Binary/NullCoalesceBinary.php +++ b/src/Node/Expression/Binary/NullCoalesceBinary.php @@ -15,11 +15,11 @@ use Twig\Node\EmptyNode; use Twig\Node\Expression\AbstractExpression; use Twig\Node\Expression\BlockReferenceExpression; -use Twig\Node\Expression\NameExpression; use Twig\Node\Expression\OperatorEscapeInterface; use Twig\Node\Expression\Test\DefinedTest; use Twig\Node\Expression\Test\NullTest; use Twig\Node\Expression\Unary\NotUnary; +use Twig\Node\Expression\Variable\ContextVariable; use Twig\TwigTest; final class NullCoalesceBinary extends AbstractBinary implements OperatorEscapeInterface @@ -28,7 +28,7 @@ public function __construct(AbstractExpression $left, AbstractExpression $right, { parent::__construct($left, $right, $lineno); - if (!$left instanceof NameExpression) { + if (!$left instanceof ContextVariable) { $left = clone $left; $test = new DefinedTest($left, new TwigTest('defined'), new EmptyNode(), $left->getTemplateLine()); // for "block()", we don't need the null test as the return value is always a string