[Routing] allow extending Route attribute

This commit is contained in:
robmro27 2021-05-01 14:19:42 +02:00 committed by Fabien Potencier
parent 0489ffcaed
commit d733b78f88

View File

@ -280,7 +280,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
$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 class AnnotationClassLoader implements LoaderInterface
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();
}
}