mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 11:56:50 +00:00
Fix some minor issues
This commit is contained in:
@@ -480,7 +480,7 @@ class ExpressionParser
|
||||
case 'attribute':
|
||||
$fakeNode = new Node(lineno: $line);
|
||||
$fakeNode->setSourceContext($this->parser->getStream()->getSourceContext());
|
||||
$fakeFunction = new TwigFunction('attribute', fn ($variable, $attribute, $arguments = []) => null);
|
||||
$fakeFunction = new TwigFunction('attribute', fn ($variable, $attribute, $arguments = null) => null);
|
||||
$args = (new CallableArgumentsExtractor($fakeNode, $fakeFunction))->extractArguments($this->parseArguments(true));
|
||||
|
||||
return new GetAttrExpression($args[0], $args[1], $args[2] ?? null, Template::ANY_CALL, $line);
|
||||
|
||||
@@ -121,7 +121,7 @@ final class CallableArgumentsExtractor
|
||||
$optionalArguments = [];
|
||||
++$pos;
|
||||
} elseif ($callableParameter->isDefaultValueAvailable()) {
|
||||
$optionalArguments[] = new ConstantExpression($callableParameter->getDefaultValue(), -1);
|
||||
$optionalArguments[] = new ConstantExpression($callableParameter->getDefaultValue(), $this->node->getTemplateLine());
|
||||
} elseif ($callableParameter->isOptional()) {
|
||||
if (!$extractedArguments) {
|
||||
break;
|
||||
@@ -134,12 +134,12 @@ final class CallableArgumentsExtractor
|
||||
}
|
||||
|
||||
if ($this->twigCallable->isVariadic()) {
|
||||
$arbitraryArguments = $isPhpVariadic ? new VariadicExpression([], -1) : new ArrayExpression([], -1);
|
||||
$arbitraryArguments = $isPhpVariadic ? new VariadicExpression([], $this->node->getTemplateLine()) : new ArrayExpression([], $this->node->getTemplateLine());
|
||||
foreach ($extractedArguments as $key => $value) {
|
||||
if (\is_int($key)) {
|
||||
$arbitraryArguments->addElement($value);
|
||||
} else {
|
||||
$arbitraryArguments->addElement($value, new ConstantExpression($key, -1));
|
||||
$arbitraryArguments->addElement($value, new ConstantExpression($key, $this->node->getTemplateLine()));
|
||||
}
|
||||
unset($extractedArguments[$key]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user