symfony/routing · error · LogicException
The " ()" method must not be called.
Error message
The "%s()" method must not be called.
What it means
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.
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.
Example fix
// before
$resolver = $attributeClassLoader->getResolver();
// after
if ($loader instanceof AttributeClassLoader) { return; } // no resolver support
Defensive patterns
Strategy: try-catch
Validate before calling
if (method_exists($loader, 'getResolver')) { /* still throws for AttributeClassLoader */ } // instead: if ($loader instanceof AttributeClassLoader) { skip resolver usage; } Type guard
function supportsResolver(object $loader): bool { return !$loader instanceof AttributeClassLoader; } Try / catch
try { $resolver = $loader->getResolver(); } catch (\LogicException $e) { $resolver = null; // AttributeClassLoader never delegates } Prevention
- 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().
When it happens
Trigger: Programmatically calling $loader->getResolver() on an AttributeClassLoader instance, e.g. in tests or custom loader code that assumes the standard LoaderInterface resolver contract.
Common situations: Test code (testGetResolver) or custom loader wiring that attaches child loaders and then queries the resolver; copying generic loader handling code.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Parameter " " for route " " must match " " (" " given) to…
- Parameters for route
- Route aliases cannot be used on non-invokable class
- The return value in config file
- Namespace " " is not a valid PSR-4 prefix.
AI-assisted analysis of symfony/routing@83fa223250 (2026-09-14).
Data as JSON: /api/errors/dd8096c5b956a248.
Report an issue: GitHub.
Appendix: source
Thrown at Loader/AttributeClassLoader.php:258
$aliasAttribute->message
);
}
}
}
}
public function supports(mixed $resource, ?string $type = null): bool
{
return \is_string($resource) && preg_match('/^(?:\\\\?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)+$/', $resource) && (!$type || 'attribute' === $type);
}
public function setResolver(LoaderResolverInterface $resolver): void
{
}
public function getResolver(): LoaderResolverInterface
{
throw new LogicException(\sprintf('The "%s()" method must not be called.', __METHOD__));
}
/**
* Gets the default route name for a class method.
*/
protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method): string
{
$name = str_replace('\\', '_', $class->name).'_'.$method->name;
$name = \function_exists('mb_strtolower') && preg_match('//u', $name) ? mb_strtolower($name, 'UTF-8') : strtolower($name);
if ($this->defaultRouteIndex > 0) {
$name .= '_'.$this->defaultRouteIndex;
}
++$this->defaultRouteIndex;
return $name;
}
/**View on GitHub (pinned to 83fa223250)