Skip to content

Commit

Permalink
Do not call ReflectionMethod::getAttributes on php <8 (#2072)
Browse files Browse the repository at this point in the history
* Do not call ReflectionMethod::getAttributes on php<8

* fix cs
  • Loading branch information
GuilhemN committed Jan 25, 2023
1 parent a9716c6 commit da9fd01
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Routing/FilteredRouteCollectionBuilder.php
Expand Up @@ -168,9 +168,11 @@ private function defaultRouteDisabled(Route $route): bool
}

$annotations = $this->annotationReader->getMethodAnnotations($method);
$annotations = array_merge($annotations, array_map(function (\ReflectionAttribute $attribute) {
return $attribute->newInstance();
}, $method->getAttributes(AbstractAnnotation::class, \ReflectionAttribute::IS_INSTANCEOF)));
if (method_exists(\ReflectionMethod::class, 'getAttributes')) {
$annotations = array_merge($annotations, array_map(function (\ReflectionAttribute $attribute) {
return $attribute->newInstance();
}, $method->getAttributes(AbstractAnnotation::class, \ReflectionAttribute::IS_INSTANCEOF)));
}

foreach ($annotations as $annotation) {
if (false !== strpos(get_class($annotation), 'Nelmio\\ApiDocBundle\\Annotation')
Expand Down

0 comments on commit da9fd01

Please sign in to comment.