99use PhpParser \Node ;
1010use PhpParser \Node \Stmt \Return_ ;
1111use PHPStan \Analyser \Scope ;
12+ use PHPStan \BetterReflection \Reflection \Adapter \ReflectionClass ;
13+ use PHPStan \BetterReflection \Reflection \Adapter \ReflectionMethod ;
1214use PHPStan \BetterReflection \Reflector \Exception \IdentifierNotFound ;
1315use PHPStan \DependencyInjection \Container ;
1416use PHPStan \DependencyInjection \ParameterNotFoundException ;
1921use RecursiveDirectoryIterator ;
2022use RecursiveIteratorIterator ;
2123use ReflectionAttribute ;
22- use ReflectionClass ;
23- use ReflectionMethod ;
2424use Reflector ;
2525use ShipMonk \PHPStan \DeadCode \Graph \ClassConstantRef ;
2626use ShipMonk \PHPStan \DeadCode \Graph \ClassConstantUsage ;
4242use function simplexml_load_string ;
4343use function sprintf ;
4444use function strpos ;
45- use const PHP_VERSION_ID ;
4645
4746class SymfonyUsageProvider implements MemberUsageProvider
4847{
@@ -350,8 +349,10 @@ protected function isConstructorWithAsControllerAttribute(ReflectionMethod $meth
350349
351350 protected function isMethodWithRouteAttribute (ReflectionMethod $ method ): bool
352351 {
353- return $ this ->hasAttribute ($ method , 'Symfony\Component\Routing\Attribute\Route ' , ReflectionAttribute::IS_INSTANCEOF )
354- || $ this ->hasAttribute ($ method , 'Symfony\Component\Routing\Annotation\Route ' , ReflectionAttribute::IS_INSTANCEOF );
352+ $ isInstanceOf = 2 ; // ReflectionAttribute::IS_INSTANCEOF, since PHP 8.0
353+
354+ return $ this ->hasAttribute ($ method , 'Symfony\Component\Routing\Attribute\Route ' , $ isInstanceOf )
355+ || $ this ->hasAttribute ($ method , 'Symfony\Component\Routing\Annotation\Route ' , $ isInstanceOf );
355356 }
356357
357358 /**
@@ -371,15 +372,11 @@ protected function isProbablySymfonyListener(ReflectionMethod $method): bool
371372 }
372373
373374 /**
374- * @param ReflectionClass<object> |ReflectionMethod $classOrMethod
375+ * @param ReflectionClass|ReflectionMethod $classOrMethod
375376 * @param ReflectionAttribute::IS_*|0 $flags
376377 */
377378 protected function hasAttribute (Reflector $ classOrMethod , string $ attributeClass , int $ flags = 0 ): bool
378379 {
379- if (PHP_VERSION_ID < 8_00_00 ) {
380- return false ;
381- }
382-
383380 if ($ classOrMethod ->getAttributes ($ attributeClass ) !== []) {
384381 return true ;
385382 }
0 commit comments