{"record":{"id":"219df053fcc02b36","repo":"twigphp/Twig","slug":"named-arguments-are-not-supported-for-s-s","errorCode":null,"errorMessage":"Named arguments are not supported for %s \"%s\".","messagePattern":"Named arguments are not supported for (.+?) \"(.+?)\"\\.","errorType":"exception","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"src/Util/CallableArgumentsExtractor.php","lineNumber":69,"sourceCode":"\n            $extractedArguments[$normalizedName = $this->normalizeName($name)] = $node;\n            $extractedArgumentNameMap[$normalizedName] = $name;\n        }\n\n        if (!$named && !$this->twigCallable->isVariadic()) {\n            $min = $this->twigCallable->getMinimalNumberOfRequiredArguments();\n            if (\\count($extractedArguments) < $this->rc->getReflector()->getNumberOfRequiredParameters() - $min) {\n                $argName = $this->toSnakeCase($this->rc->getReflector()->getParameters()[$min + \\count($extractedArguments)]->getName());\n\n                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());\n            }\n\n            return $extractedArguments;\n        }\n\n        if (!$callable = $this->twigCallable->getCallable()) {\n            if ($named) {\n                throw new SyntaxError(\\sprintf('Named arguments are not supported for %s \"%s\".', $this->twigCallable->getType(), $this->twigCallable->getName()));\n            }\n\n            throw new SyntaxError(\\sprintf('Arbitrary positional arguments are not supported for %s \"%s\".', $this->twigCallable->getType(), $this->twigCallable->getName()));\n        }\n\n        [$callableParameters, $isPhpVariadic] = $this->getCallableParameters();\n        $arguments = [];\n        $callableParameterNames = [];\n        $missingArguments = [];\n        $optionalArguments = [];\n        $pos = 0;\n        foreach ($callableParameters as $callableParameter) {\n            $callableParameterName = $callableParameter->name;\n            if (\\PHP_VERSION_ID >= 80000 && 'range' === $callable) {\n                if ('start' === $callableParameterName) {\n                    $callableParameterName = 'low';\n                } elseif ('end' === $callableParameterName) {\n                    $callableParameterName = 'high';","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/twigphp/Twig/blob/a414c3a491defb5a60f2fc88ef79ff37c90010cd/src/Util/CallableArgumentsExtractor.php#L51-L87","documentation":"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.","triggerScenarios":"Calling a Twig function/filter/test registered without a callable (custom node-based callables) while using named-argument syntax, e.g. {{ special(x=1) }}.","commonSituations":"Custom extensions registering callables via abstract expression factories or node visitors without getCallable(); using named-argument style on core constructs that never supported it.","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."],"exampleFix":"{# before #}\n{{ dump(var=values) }}\n{# after #}\n{{ dump(values) }}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    $html = $twig->render($template, $ctx);\n} catch (Twig\\Error\\SyntaxError $e) {\n    if (str_contains($e->getMessage(), 'Named arguments are not supported')) {\n        // rewrite the call positionally or register a callable for the Twig callable\n        throw new RuntimeException('Use positional args for this callable: '.$e->getMessage(), 0, $e);\n    }\n    throw $e;\n}","preventionTips":["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."],"tags":["twig","named-arguments","compile-time","syntax-error"],"backgroundTag":"unsupported-operation","analyzedSha":"a414c3a491defb5a60f2fc88ef79ff37c90010cd","analyzedAt":"2026-09-13T15:10:46.849Z","contentChangedAt":"2026-09-13T15:10:46.849Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}