bug #4683 Fix compatibility layer (fabpot)

This PR was merged into the 3.x branch.

Discussion
----------

Fix compatibility layer

Closes #4652

Commits
-------

806049f7a2 Fix compatibility layer
This commit is contained in:
Fabien Potencier
2025-08-17 19:24:27 +02:00
+2 -2
View File
@@ -214,7 +214,7 @@ class ExpressionParser
{
trigger_deprecation('twig/twig', '3.19', \sprintf('The "%s()" method is deprecated, use "Twig\ExpressionParser\Infix\ArgumentsTrait::parseNamedArguments()" instead.', __METHOD__));
$parsePrimary = new \ReflectionMethod($this->parser, 'parsePrimary');
$parsePrimaryExpression = new \ReflectionMethod($this->parser, 'parsePrimaryExpression');
$namedArguments = false;
$definition = false;
@@ -263,7 +263,7 @@ class ExpressionParser
$name = $value->getAttribute('name');
if ($definition) {
$value = $parsePrimary->invoke($this->parser);
$value = $parsePrimaryExpression->invoke($this->parser);
if (!$this->checkConstantExpression($value)) {
throw new SyntaxError('A default value for an argument must be a constant (a boolean, a string, a number, a sequence, or a mapping).', $token->getLine(), $stream->getSourceContext());