diff --git a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php index 0b362ad1e0e04..a1bb35f09266f 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php @@ -280,7 +280,7 @@ protected function getGlobals(\ReflectionClass $class) $globals = $this->resetGlobals(); $annot = null; - if (\PHP_VERSION_ID >= 80000 && ($attribute = $class->getAttributes($this->routeAnnotationClass)[0] ?? null)) { + if (\PHP_VERSION_ID >= 80000 && ($attribute = $class->getAttributes($this->routeAnnotationClass, \ReflectionAttribute::IS_INSTANCEOF)[0] ?? null)) { $annot = $attribute->newInstance(); } if (!$annot && $this->reader) { @@ -372,7 +372,7 @@ abstract protected function configureRoute(Route $route, \ReflectionClass $class private function getAnnotations(object $reflection): iterable { if (\PHP_VERSION_ID >= 80000) { - foreach ($reflection->getAttributes($this->routeAnnotationClass) as $attribute) { + foreach ($reflection->getAttributes($this->routeAnnotationClass, \ReflectionAttribute::IS_INSTANCEOF) as $attribute) { yield $attribute->newInstance(); } }