{"record":{"id":"161a214106fb782b","repo":"twigphp/Twig","slug":"the-deprecation-info-option-must-be-an-instance-of-s","errorCode":null,"errorMessage":"The \"deprecation_info\" option must be an instance of \"%s\".","messagePattern":"The \"deprecation_info\" option must be an instance of \"(.+?)\"\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"src/AbstractTwigCallable.php","lineNumber":45,"sourceCode":"    {\n        $this->name = $this->dynamicName = $name;\n        $this->callable = $callable;\n        $this->arguments = [];\n        $this->options = array_merge([\n            'needs_environment' => false,\n            'needs_context' => false,\n            'needs_charset' => false,\n            'needs_is_sandboxed' => false,\n            'is_variadic' => false,\n            'always_allowed_in_sandbox' => false,\n            'deprecation_info' => null,\n            'deprecated' => false,\n            'deprecating_package' => '',\n            'alternative' => null,\n        ], $options);\n\n        if ($this->options['deprecation_info'] && !$this->options['deprecation_info'] instanceof DeprecatedCallableInfo) {\n            throw new \\LogicException(\\sprintf('The \"deprecation_info\" option must be an instance of \"%s\".', DeprecatedCallableInfo::class));\n        }\n\n        if ($this->options['deprecated']) {\n            if ($this->options['deprecation_info']) {\n                throw new \\LogicException('When setting the \"deprecation_info\" option, you need to remove the obsolete deprecated options.');\n            }\n\n            trigger_deprecation('twig/twig', '3.15', 'Using the \"deprecated\", \"deprecating_package\", and \"alternative\" options is deprecated, pass a \"deprecation_info\" one instead.');\n\n            $this->options['deprecation_info'] = new DeprecatedCallableInfo(\n                $this->options['deprecating_package'],\n                $this->options['deprecated'],\n                null,\n                $this->options['alternative'],\n            );\n        }\n\n        if ($this->options['deprecation_info']) {","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/twigphp/Twig/blob/a414c3a491defb5a60f2fc88ef79ff37c90010cd/src/AbstractTwigCallable.php#L27-L63","documentation":"AbstractTwigCallable's constructor validates the options array passed by subclasses (TwigFunction, TwigFilter, TwigTest). If a 'deprecation_info' option is provided, it must be a DeprecatedCallableInfo instance; anything else triggers this LogicException. The library throws it early so misconfigured callable definitions fail at registration time rather than at render time.","triggerScenarios":"Calling new TwigFunction/TwigFilter/TwigTest(..., ['deprecation_info' => <something not a DeprecatedCallableInfo>]), e.g. passing an array of deprecation fields, a string, or null-ish data instead of a DeprecatedCallableInfo object.","commonSituations":"Migrating from the pre-3.15 'deprecated'/'deprecating_package'/'alternative' options to 'deprecation_info' but passing raw config data instead of constructing DeprecatedCallableInfo; typos in a custom extension's options array.","solutions":["Wrap the deprecation data in a DeprecatedCallableInfo instance before passing it as the 'deprecation_info' option.","Remove the 'deprecation_info' option if the callable is not actually deprecated.","Check the package version: 'deprecation_info' requires twig/twig >= 3.15; on older versions use the legacy 'deprecated' options."],"exampleFix":"// before\nnew TwigFunction('legacy', $fn, ['deprecation_info' => ['package' => 'acme/pkg', 'version' => '2.0']]);\n// after\n$info = new \\Twig\\DeprecatedCallableInfo('acme/pkg', '2.0');\nnew TwigFunction('legacy', $fn, ['deprecation_info' => $info]);","handlingStrategy":"validation","validationCode":"if (isset($options['deprecation_info']) && !class_exists(\\Twig\\DeprecatedCallableInfo::class)) {\n    unset($options['deprecation_info']); // legacy Twig: fall back to old options\n} elseif (isset($options['deprecation_info']) && !$options['deprecation_info'] instanceof \\Twig\\DeprecatedCallableInfo) {\n    $options['deprecation_info'] = new \\Twig\\DeprecatedCallableInfo(\n        $options['deprecation_info']['package'] ?? '',\n        $options['deprecation_info']['version'] ?? ''\n    );\n}","typeGuard":"function isValidDeprecationInfo(mixed $v): bool {\n    return $v === null || (class_exists(\\Twig\\DeprecatedCallableInfo::class) && $v instanceof \\Twig\\DeprecatedCallableInfo);\n}","tryCatchPattern":"try {\n    $fn = new TwigFunction('x', $fn, $options);\n} catch (\\LogicException $e) {\n    // inspect $options['deprecation_info'] and rebuild with a DeprecatedCallableInfo\n}","preventionTips":["Always construct deprecation data with new \\Twig\\DeprecatedCallableInfo(...), never with arrays.","Only pass 'deprecation_info' when targeting twig/twig >= 3.15.","Keep extension option arrays small and typed; avoid spreading unvalidated config into them."],"tags":["php","twig","configuration","logic-exception"],"backgroundTag":"invalid-argument-value","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"}