{"record":{"id":"23a1b1fe9958e51d","repo":"twigphp/Twig","slug":"when-setting-the-deprecation-info-option-you-need-to-remove","errorCode":null,"errorMessage":"When setting the \"deprecation_info\" option, you need to remove the obsolete deprecated options.","messagePattern":"When setting the \"deprecation_info\" option, you need to remove the obsolete deprecated options\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"src/AbstractTwigCallable.php","lineNumber":50,"sourceCode":"            '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']) {\n            $this->options['deprecation_info']->setName($name);\n            $this->options['deprecation_info']->setType($this->getType());\n        }\n    }\n","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/twigphp/Twig/blob/a414c3a491defb5a60f2fc88ef79ff37c90010cd/src/AbstractTwigCallable.php#L32-L68","documentation":"This LogicException is thrown when both the modern 'deprecation_info' option and the obsolete 'deprecated' (and related 'deprecating_package'/'alternative') options are set at once. The library forbids combining them to avoid ambiguity about which deprecation description is authoritative; the new-style options were introduced in twig/twig 3.15.","triggerScenarios":"new TwigFunction/TwigFilter/TwigTest(..., ['deprecated' => true, 'deprecation_info' => $info]) or setting 'deprecating_package'/'alternative' alongside 'deprecation_info'.","commonSituations":"Incrementally migrating an extension from legacy deprecation options to DeprecatedCallableInfo while leaving the old keys in place; copying config from an older extension when upgrading twig/twig.","solutions":["Remove the legacy 'deprecated', 'deprecating_package', and 'alternative' options and keep only 'deprecation_info'.","If you must support older Twig versions, keep the legacy options and drop 'deprecation_info' (a deprecation notice will be triggered).","Audit custom extension option arrays for both styles after upgrading twig/twig to >= 3.15."],"exampleFix":"// before\nnew TwigFilter('old', $fn, ['deprecated' => true, 'deprecating_package' => 'acme', 'deprecation_info' => $info]);\n// after\nnew TwigFilter('old', $fn, ['deprecation_info' => $info]);","handlingStrategy":"validation","validationCode":"$legacy = array_intersect_key($options, array_flip(['deprecated', 'deprecating_package', 'alternative']));\nif (isset($options['deprecation_info']) && $legacy) {\n    $options = array_diff_key($options, $legacy);\n}","typeGuard":"function hasConflictingDeprecationOptions(array $options): bool {\n    return isset($options['deprecation_info']) && (isset($options['deprecated']) || isset($options['deprecating_package']) || isset($options['alternative']));\n}","tryCatchPattern":"try {\n    $callable = new TwigFilter('x', $fn, $options);\n} catch (\\LogicException $e) {\n    unset($options['deprecated'], $options['deprecating_package'], $options['alternative']);\n    $callable = new TwigFilter('x', $fn, $options);\n}","preventionTips":["During migration, delete legacy keys ('deprecated', 'deprecating_package', 'alternative') in the same commit that adds 'deprecation_info'.","Centralize callable option building in one factory so both styles cannot be mixed.","Add a unit test asserting the constructor does not throw for your option sets."],"tags":["php","twig","configuration","deprecation"],"backgroundTag":"mutually-exclusive-options","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"}