-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
In MacroNode constructor, the $name argument can be overridden by the last "key" of the $argments argument
// 🟢
public function __construct(string $name, Node $body, Node $arguments, int $lineno)
{
// ...
if (!$arguments instanceof ArrayExpression) {
// ...
// 🟢
foreach ($arguments as $name => $default) {
$args->addElement($default, new LocalVariable($name, $default->getTemplateLine()));
}
// ...
}
// ...
// 🟢
parent::__construct(['body' => $body, 'arguments' => $arguments], ['name' => $name], $lineno);
}Lines 34 to 57 in c1f7277
| public function __construct(string $name, Node $body, Node $arguments, int $lineno) | |
| { | |
| if (!$body instanceof BodyNode) { | |
| trigger_deprecation('twig/twig', '3.12', \sprintf('Not passing a "%s" instance as the "body" argument of the "%s" constructor is deprecated ("%s" given).', BodyNode::class, static::class, $body::class)); | |
| } | |
| if (!$arguments instanceof ArrayExpression) { | |
| trigger_deprecation('twig/twig', '3.15', \sprintf('Not passing a "%s" instance as the "arguments" argument of the "%s" constructor is deprecated ("%s" given).', ArrayExpression::class, static::class, $arguments::class)); | |
| $args = new ArrayExpression([], $arguments->getTemplateLine()); | |
| foreach ($arguments as $name => $default) { | |
| $args->addElement($default, new LocalVariable($name, $default->getTemplateLine())); | |
| } | |
| $arguments = $args; | |
| } | |
| foreach ($arguments->getKeyValuePairs() as $pair) { | |
| if ("\u{035C}".self::VARARGS_NAME === $pair['key']->getAttribute('name')) { | |
| throw new SyntaxError(\sprintf('The argument "%s" in macro "%s" cannot be defined because the variable "%s" is reserved for arbitrary arguments.', self::VARARGS_NAME, $name, self::VARARGS_NAME), $pair['value']->getTemplateLine(), $pair['value']->getSourceContext()); | |
| } | |
| } | |
| parent::__construct(['body' => $body, 'arguments' => $arguments], ['name' => $name], $lineno); | |
| } |
Not sure if this has any real occurence / consequence... if no sorry for the waste of time 🤷
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels