Skip to content

Commit

Permalink
Removing code that forced indexed keys in favor of identical, non-ind…
Browse files Browse the repository at this point in the history
…exed
  • Loading branch information
weaverryan committed Jun 16, 2023
1 parent 87cd4f2 commit 9b84952
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/Node/Expression/ArrayExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ public function compile(Compiler $compiler): void
$compiler->raw('...')->subcompile($pair['value']);
} else {
$indexSpecified = false === $pair['key']->hasAttribute('index_specified') || true === $pair['key']->getAttribute('index_specified');
// if you apply the spread operator, for proper merging, we stop
// explicitly assigning indexes and allow PHP to do it
if ($indexSpecified || !$hasSpreadItem) {
if ($indexSpecified) {
$compiler
->subcompile($pair['key'])
->raw(' => ')
Expand Down
2 changes: 1 addition & 1 deletion tests/Node/Expression/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ protected function foobar()
new ConstantExpression('3', 1),
'foo' => new ConstantExpression('bar', 1),
]);
$tests[] = [$node, 'Twig\Tests\Node\Expression\twig_tests_filter_barbar($context, "abc", "1", "2", [0 => "3", "foo" => "bar"])', $environment];
$tests[] = [$node, 'Twig\Tests\Node\Expression\twig_tests_filter_barbar($context, "abc", "1", "2", ["3", "foo" => "bar"])', $environment];

// from extension
$node = $this->createFilter($string, 'foo');
Expand Down
2 changes: 1 addition & 1 deletion tests/Node/Expression/FunctionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function getTests()
new ConstantExpression('3', 1),
'foo' => new ConstantExpression('bar', 1),
]);
$tests[] = [$node, 'Twig\Tests\Node\Expression\twig_tests_function_barbar("1", "2", [0 => "3", "foo" => "bar"])', $environment];
$tests[] = [$node, 'Twig\Tests\Node\Expression\twig_tests_function_barbar("1", "2", ["3", "foo" => "bar"])', $environment];

// function as an anonymous function
$node = $this->createFunction('anonymous', [new ConstantExpression('foo', 1)]);
Expand Down
2 changes: 1 addition & 1 deletion tests/Node/Expression/GetAttrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getTests()
$args->addElement(new NameExpression('foo', 1));
$args->addElement(new ConstantExpression('bar', 1));
$node = new GetAttrExpression($expr, $attr, $args, Template::METHOD_CALL, 1);
$tests[] = [$node, sprintf('%s%s, "bar", [0 => %s, 1 => "bar"], "method", false, false, false, 1)', $this->getAttributeGetter(), $this->getVariableGetter('foo', 1), $this->getVariableGetter('foo'))];
$tests[] = [$node, sprintf('%s%s, "bar", [%s, "bar"], "method", false, false, false, 1)', $this->getAttributeGetter(), $this->getVariableGetter('foo', 1), $this->getVariableGetter('foo'))];

return $tests;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Node/Expression/TestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function getTests()
new ConstantExpression('3', 1),
'foo' => new ConstantExpression('bar', 1),
]);
$tests[] = [$node, 'Twig\Tests\Node\Expression\twig_tests_test_barbar("abc", "1", "2", [0 => "3", "foo" => "bar"])', $environment];
$tests[] = [$node, 'Twig\Tests\Node\Expression\twig_tests_test_barbar("abc", "1", "2", ["3", "foo" => "bar"])', $environment];

return $tests;
}
Expand Down

0 comments on commit 9b84952

Please sign in to comment.