{"record":{"id":"dd8096c5b956a248","repo":"symfony/routing","slug":"the-s-method-must-not-be-called","errorCode":null,"errorMessage":"The \"%s()\" method must not be called.","messagePattern":"The \"(.+?)\\(\\)\" method must not be called\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"Loader/AttributeClassLoader.php","lineNumber":258,"sourceCode":"                        $aliasAttribute->message\n                    );\n                }\n            }\n        }\n    }\n\n    public function supports(mixed $resource, ?string $type = null): bool\n    {\n        return \\is_string($resource) && preg_match('/^(?:\\\\\\\\?[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)+$/', $resource) && (!$type || 'attribute' === $type);\n    }\n\n    public function setResolver(LoaderResolverInterface $resolver): void\n    {\n    }\n\n    public function getResolver(): LoaderResolverInterface\n    {\n        throw new LogicException(\\sprintf('The \"%s()\" method must not be called.', __METHOD__));\n    }\n\n    /**\n     * Gets the default route name for a class method.\n     */\n    protected function getDefaultRouteName(\\ReflectionClass $class, \\ReflectionMethod $method): string\n    {\n        $name = str_replace('\\\\', '_', $class->name).'_'.$method->name;\n        $name = \\function_exists('mb_strtolower') && preg_match('//u', $name) ? mb_strtolower($name, 'UTF-8') : strtolower($name);\n        if ($this->defaultRouteIndex > 0) {\n            $name .= '_'.$this->defaultRouteIndex;\n        }\n        ++$this->defaultRouteIndex;\n\n        return $name;\n    }\n\n    /**","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/symfony/routing/blob/83fa223250b50f4f018c011e101c330e65ac63cc/Loader/AttributeClassLoader.php#L240-L276","documentation":"AttributeClassLoader deliberately does not support child loaders: setResolver() is a no-op and getResolver() always throws this LogicException. It exists to prevent accidental reliance on a resolver, since attribute-based controllers are loaded directly without delegation.","triggerScenarios":"Programmatically calling $loader->getResolver() on an AttributeClassLoader instance, e.g. in tests or custom loader code that assumes the standard LoaderInterface resolver contract.","commonSituations":"Test code (testGetResolver) or custom loader wiring that attaches child loaders and then queries the resolver; copying generic loader handling code.","solutions":["Do not call getResolver() on AttributeClassLoader; handle it directly without delegation.","In resolver-related tests, skip/branch when the loader is an AttributeClassLoader.","Use a different loader implementation if child-loader resolution is genuinely required."],"exampleFix":"// before\n$resolver = $attributeClassLoader->getResolver();\n// after\nif ($loader instanceof AttributeClassLoader) { return; } // no resolver support\n","handlingStrategy":"try-catch","validationCode":"if (method_exists($loader, 'getResolver')) { /* still throws for AttributeClassLoader */ } // instead: if ($loader instanceof AttributeClassLoader) { skip resolver usage; }","typeGuard":"function supportsResolver(object $loader): bool { return !$loader instanceof AttributeClassLoader; }","tryCatchPattern":"try { $resolver = $loader->getResolver(); } catch (\\LogicException $e) { $resolver = null; // AttributeClassLoader never delegates }","preventionTips":["Treat AttributeClassLoader as a leaf loader with no child delegation.","Do not write generic loader-pipeline code that assumes getResolver() works on all loaders.","Assert loader capabilities in tests rather than probing getResolver()."],"tags":["symfony","routing","loader"],"backgroundTag":"unsupported-operation","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"}