Skip to content

Commit

Permalink
Fix Spread operator support
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Feb 9, 2025
1 parent c142a32 commit aedf2c5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Node/Expression/ArrayExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Twig\Node\Expression;

use Twig\Compiler;
use Twig\Node\Expression\Unary\SpreadUnary;
use Twig\Node\Expression\Unary\StringCastUnary;
use Twig\Node\Expression\Variable\ContextVariable;
use Twig\Node\Expression\Variable\LocalVariable;
Expand Down Expand Up @@ -90,7 +91,7 @@ public function compile(Compiler $compiler): void
$key = $pair['key']->getAttribute('value');
}

if ($nextIndex !== $key) {
if ($nextIndex !== $key && !$pair['value'] instanceof SpreadUnary) {
$compiler
->subcompile($pair['key'])
->raw(' => ')
Expand Down

0 comments on commit aedf2c5

Please sign in to comment.