{"record":{"id":"44ca171e49eb7b11","repo":"twigphp/Twig","slug":"arbitrary-positional-arguments-are-not-supported-for-s-s","errorCode":null,"errorMessage":"Arbitrary positional arguments are not supported for %s \"%s\".","messagePattern":"Arbitrary positional arguments are not supported for (.+?) \"(.+?)\"\\.","errorType":"exception","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"src/Util/CallableArgumentsExtractor.php","lineNumber":72,"sourceCode":"        }\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';\n                }\n            }\n","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/twigphp/Twig/blob/a414c3a491defb5a60f2fc88ef79ff37c90010cd/src/Util/CallableArgumentsExtractor.php#L54-L90","documentation":"For Twig callables registered without an underlying PHP callable, extractArguments() cannot validate or forward arbitrary extra positional arguments. If such a callable is invoked positionally at all (no named arguments), a SyntaxError is thrown stating that arbitrary positional arguments are not supported for it.","triggerScenarios":"Calling a function/filter/test that has no getCallable() (node-only callables) with any positional arguments — the branch reached when $named is false and no callable exists.","commonSituations":"Using named-argument-capable syntax against custom node-based Twig constructs; writing templates that call an extension's node-based function as if it were a plain PHP-mapped function.","solutions":["Do not pass arguments this way; use the syntax documented for that specific Twig construct.","Register a PHP callable on the Twig callable so positional arguments can be extracted and validated.","Replace the call with the dedicated tag or node syntax the extension provides."],"exampleFix":"{# before: calling a node-only construct like a raw function #}\n{{ mynodeconstruct('a', 'b') }}\n{# after: use its dedicated tag #}\n{% mytag 'a' 'b' %}{% endmytag %}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    $out = $twig->render($template, $ctx);\n} catch (Twig\\Error\\SyntaxError $e) {\n    if (str_contains($e->getMessage(), 'Arbitrary positional arguments are not supported')) {\n        throw new RuntimeException('This Twig construct does not accept positional arguments; use its dedicated syntax.', 0, $e);\n    }\n    throw $e;\n}","preventionTips":["Do not call node-only Twig functions/filters as if they were PHP-backed functions.","Register a real callable when you want normal argument extraction and validation.","Consult the extension docs for the intended tag/function syntax."],"tags":["twig","positional-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"}