function MacroNode::__construct
Parameters
BodyNode $body:
ArrayExpression $arguments:
Overrides Node::__construct
File
-
vendor/
twig/ twig/ src/ Node/ MacroNode.php, line 34
Class
- MacroNode
- Represents a macro node.
Namespace
Twig\NodeCode
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 ("͜" . 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);
}