Add a proper prefix spread operator

This commit is contained in:
Fabien Potencier
2025-02-14 10:34:17 +01:00
parent 2f3150579f
commit 3964aeba78
10 changed files with 51 additions and 111 deletions
+3 -12
View File
@@ -27,6 +27,7 @@ use Twig\Node\Expression\FilterExpression;
use Twig\Node\Expression\FunctionExpression;
use Twig\Node\Expression\TestExpression;
use Twig\Node\Expression\Unary\AbstractUnary;
use Twig\Node\Expression\Unary\SpreadUnary;
use Twig\Node\Expression\Variable\ContextVariable;
use Twig\Node\Node;
use Twig\Parser;
@@ -193,7 +194,7 @@ class ExpressionParserTest extends TestCase
new ConstantExpression(2, 1),
new ConstantExpression(2, 1),
self::createContextVariable('foo', ['spread' => true]),
new SpreadUnary(new ContextVariable('foo', 1), 1),
], 1)],
// mapping with spread operator
@@ -206,7 +207,7 @@ class ExpressionParserTest extends TestCase
new ConstantExpression('c', 1),
new ConstantExpression(0, 1),
self::createContextVariable('otherLetters', ['spread' => true]),
new SpreadUnary(new ContextVariable('otherLetters', 1), 1),
], 1)],
];
}
@@ -591,16 +592,6 @@ class ExpressionParserTest extends TestCase
$this->expectNotToPerformAssertions();
}
private static function createContextVariable(string $name, array $attributes): ContextVariable
{
$expression = new ContextVariable($name, 1);
foreach ($attributes as $key => $value) {
$expression->setAttribute($key, $value);
}
return $expression;
}
/**
* @dataProvider getBindingPowerTests
*/