{"record":{"id":"4810e621da46eb02","repo":"symfony/routing","slug":"the-deprecation-template-must-contain-the-alias-id","errorCode":null,"errorMessage":"The deprecation template must contain the \"%alias_id%\" placeholder.","messagePattern":"The deprecation template must contain the \"%alias_id%\" placeholder\\.","errorType":"validation","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Alias.php","lineNumber":63,"sourceCode":"     * Whether this alias is deprecated, that means it should not be referenced anymore.\n     *\n     * @param string $package The name of the composer package that is triggering the deprecation\n     * @param string $version The version of the package that introduced the deprecation\n     * @param string $message The deprecation message to use\n     *\n     * @return $this\n     *\n     * @throws InvalidArgumentException when the message template is invalid\n     */\n    public function setDeprecated(string $package, string $version, string $message): static\n    {\n        if ('' !== $message) {\n            if (preg_match('#[\\r\\n]|\\*/#', $message)) {\n                throw new InvalidArgumentException('Invalid characters found in deprecation template.');\n            }\n\n            if (!str_contains($message, '%alias_id%')) {\n                throw new InvalidArgumentException('The deprecation template must contain the \"%alias_id%\" placeholder.');\n            }\n        }\n\n        $this->deprecation = [\n            'package' => $package,\n            'version' => $version,\n            'message' => $message ?: 'The \"%alias_id%\" route alias is deprecated. You should stop using it, as it will be removed in the future.',\n        ];\n\n        return $this;\n    }\n\n    public function isDeprecated(): bool\n    {\n        return (bool) $this->deprecation;\n    }\n\n    /**","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/symfony/routing/blob/83fa223250b50f4f018c011e101c330e65ac63cc/Alias.php#L45-L81","documentation":"When marking an alias deprecated, the message template must include the '%alias_id%' placeholder, which the compiler replaces with the actual alias id at dump time. This error means the placeholder is missing, so the generated deprecation trigger could not reference the alias.","triggerScenarios":"Calling setDeprecated() with a non-empty $message that does not contain the literal string '%alias_id%'.","commonSituations":"Writing a custom deprecation message by hand and forgetting the placeholder; upgrading Symfony where templates previously without placeholders are now rejected.","solutions":["Add '%alias_id%' to the deprecation template.","Use the default template style: 'The \"%alias_id%\" alias is deprecated. ...'","If you want no custom message, pass '' instead of a template without the placeholder."],"exampleFix":"// before\n$alias->setDeprecated('acme/pkg', '2.0', 'This alias is deprecated.');\n// after\n$alias->setDeprecated('acme/pkg', '2.0', 'The \"%alias_id%\" alias is deprecated.');","handlingStrategy":"validation","validationCode":"if ('' !== $tpl && !str_contains($tpl, '%alias_id%')) {\n    throw new InvalidArgumentException('Template must contain %alias_id%.');\n}","typeGuard":"function hasAliasIdPlaceholder(string $m): bool { return $m === '' || str_contains($m, '%alias_id%'); }","tryCatchPattern":"try { $alias->setDeprecated($pkg, $ver, $tpl); } catch (InvalidArgumentException $e) { $alias->setDeprecated($pkg, $ver, 'The \"%alias_id%\" alias is deprecated.'); }","preventionTips":["Use a shared constant template containing %alias_id%","Never hand-write templates without the placeholder","Add a unit test asserting templates contain the placeholder"],"tags":["php","symfony-di","template"],"backgroundTag":"missing-required-argument","analyzedSha":"83fa223250b50f4f018c011e101c330e65ac63cc","analyzedAt":"2026-09-14T03:19:46.280Z","contentChangedAt":"2026-09-14T03:19:46.280Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}