{"record":{"id":"697198840a10814e","repo":"twigphp/Twig","slug":"the-s-modifier-takes-exactly-one-argument-0-given","errorCode":null,"errorMessage":"The \"%s\" modifier takes exactly one argument (0 given).","messagePattern":"The \"(.+?)\" modifier takes exactly one argument \\(0 given\\)\\.","errorType":"exception","errorClass":"Twig\\Error\\SyntaxError","httpStatus":null,"severity":"error","filePath":"extra/cache-extra/TokenParser/CacheTokenParser.php","lineNumber":41,"sourceCode":"{\n    public function parse(Token $token): Node\n    {\n        $stream = $this->parser->getStream();\n        $key = $this->parser->parseExpression();\n\n        $ttl = null;\n        $tags = null;\n        while ($stream->test(Token::NAME_TYPE)) {\n            $k = $stream->getCurrent()->getValue();\n            if (!\\in_array($k, ['ttl', 'tags'], true)) {\n                throw new SyntaxError(\\sprintf('Unknown \"%s\" configuration.', $k), $stream->getCurrent()->getLine(), $stream->getSourceContext());\n            }\n\n            $stream->next();\n            $stream->expect(Token::OPERATOR_TYPE, '(');\n            $line = $stream->getCurrent()->getLine();\n            if ($stream->test(Token::PUNCTUATION_TYPE, ')')) {\n                throw new SyntaxError(\\sprintf('The \"%s\" modifier takes exactly one argument (0 given).', $k), $line, $stream->getSourceContext());\n            }\n            $arg = $this->parser->parseExpression();\n            if ($stream->test(Token::PUNCTUATION_TYPE, ',')) {\n                throw new SyntaxError(\\sprintf('The \"%s\" modifier takes exactly one argument (2 given).', $k), $line, $stream->getSourceContext());\n            }\n            $stream->expect(Token::PUNCTUATION_TYPE, ')');\n\n            if ('ttl' === $k) {\n                $ttl = $arg;\n            } elseif ('tags' === $k) {\n                $tags = $arg;\n            }\n        }\n\n        $stream->expect(Token::BLOCK_END_TYPE);\n        $body = $this->parser->subparse([$this, 'decideCacheEnd'], true);\n        $stream->expect(Token::BLOCK_END_TYPE);\n","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/twigphp/Twig/blob/a414c3a491defb5a60f2fc88ef79ff37c90010cd/extra/cache-extra/TokenParser/CacheTokenParser.php#L23-L59","documentation":"This Twig SyntaxError is thrown when a {% cache %} modifier ('ttl' or 'tags') is followed by '(' but no argument expression before the closing ')'. The parser requires exactly one argument per modifier and reports '0 given'.","triggerScenarios":"Template like {% cache ttl() %} or {% cache tags() %} — a modifier with empty parentheses and no expression.","commonSituations":"Copy-pasting tag syntax where the argument was deleted or left as a placeholder, or generating templates programmatically with empty values.","solutions":["Supply exactly one expression inside the parentheses, e.g. ttl(60) or tags(['a','b']).","If the value is dynamic, pass a variable: ttl(ttlValue).","Remove the parentheses entirely if no argument is intended (not valid — ttl/tags always require an argument)."],"exampleFix":"// before\n{% cache ttl() %}...{% endcache %}\n// after\n{% cache ttl(60) %}...{% endcache %}","handlingStrategy":"validation","validationCode":"if (preg_match('/\\{\\%\\s*cache\\s+(ttl|tags)\\s*\\(\\s*\\)/', $template)) {\n    throw new InvalidArgumentException('cache ttl/tags modifiers require exactly one argument');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $twig->render($template);\n} catch (\\Twig\\Error\\SyntaxError $e) {\n    if (str_contains($e->getMessage(), '(0 given)')) {\n        // point developer at the empty modifier call\n    }\n    throw $e;\n}","preventionTips":["Always pass one expression inside ttl(...) / tags(...)","Lint templates in CI to catch empty modifier calls","Never generate {% cache %} tags programmatically without validating the argument exists"],"tags":["twig","template-syntax","argument-count","cache-extension"],"backgroundTag":"missing-required-argument","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"}