twigphp/Twig · error · SyntaxError
Named arguments are not supported for
Error message
Named arguments are not supported for %s "%s".
What it means
When a Twig callable (function/filter/test) has no underlying PHP callable, extractArguments() cannot map named arguments to parameters. If the template nevertheless passes named arguments, a SyntaxError is thrown stating that named arguments are unsupported for that callable. This protects against silently ignoring named options.
Solutions
- Use only positional arguments for this function/filter/test.
- Register a real PHP callable for the Twig callable if named arguments should be supported.
- Wrap the call in a custom Twig function whose callable signature exposes the parameters you want to name.
Example fix
{# before #}
{{ dump(var=values) }}
{# after #}
{{ dump(values) }} Defensive patterns
Strategy: validation
Try / catch
try {
$html = $twig->render($template, $ctx);
} catch (Twig\Error\SyntaxError $e) {
if (str_contains($e->getMessage(), 'Named arguments are not supported')) {
// rewrite the call positionally or register a callable for the Twig callable
throw new RuntimeException('Use positional args for this callable: '.$e->getMessage(), 0, $e);
}
throw $e;
} Prevention
- Only use named arguments with callables that expose a PHP signature.
- When creating node-based (callable-less) Twig functions, document that named arguments are unavailable.
- Prefer registering plain PHP callables so Twig can validate named arguments.
When it happens
Trigger: Calling a Twig function/filter/test registered without a callable (custom node-based callables) while using named-argument syntax, e.g. {{ special(x=1) }}.
Common situations: Custom extensions registering callables via abstract expression factories or node visitors without getCallable(); using named-argument style on core constructs that never supported it.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Calling the "parent" function outside of a block is…
- Calling the "parent" function on a template that does not…
- You cannot assign a value to
- A template that extends another one cannot include content…
- Positional arguments cannot be used after named arguments…
AI-assisted analysis of twigphp/Twig@a414c3a491 (2026-09-13).
Data as JSON: /api/errors/219df053fcc02b36.
Report an issue: GitHub.
Appendix: source
Thrown at src/Util/CallableArgumentsExtractor.php:69
$extractedArguments[$normalizedName = $this->normalizeName($name)] = $node;
$extractedArgumentNameMap[$normalizedName] = $name;
}
if (!$named && !$this->twigCallable->isVariadic()) {
$min = $this->twigCallable->getMinimalNumberOfRequiredArguments();
if (\count($extractedArguments) < $this->rc->getReflector()->getNumberOfRequiredParameters() - $min) {
$argName = $this->toSnakeCase($this->rc->getReflector()->getParameters()[$min + \count($extractedArguments)]->getName());
throw new SyntaxError(\sprintf('Value for argument "%s" is required for %s "%s".', $argName, $this->twigCallable->getType(), $this->twigCallable->getName()), $this->node->getTemplateLine(), $this->node->getSourceContext());
}
return $extractedArguments;
}
if (!$callable = $this->twigCallable->getCallable()) {
if ($named) {
throw new SyntaxError(\sprintf('Named arguments are not supported for %s "%s".', $this->twigCallable->getType(), $this->twigCallable->getName()));
}
throw new SyntaxError(\sprintf('Arbitrary positional arguments are not supported for %s "%s".', $this->twigCallable->getType(), $this->twigCallable->getName()));
}
[$callableParameters, $isPhpVariadic] = $this->getCallableParameters();
$arguments = [];
$callableParameterNames = [];
$missingArguments = [];
$optionalArguments = [];
$pos = 0;
foreach ($callableParameters as $callableParameter) {
$callableParameterName = $callableParameter->name;
if (\PHP_VERSION_ID >= 80000 && 'range' === $callable) {
if ('start' === $callableParameterName) {
$callableParameterName = 'low';
} elseif ('end' === $callableParameterName) {
$callableParameterName = 'high';View on GitHub (pinned to a414c3a491)