9
9
use PhpParser \Node ;
10
10
use PhpParser \Node \Stmt \Return_ ;
11
11
use PHPStan \Analyser \Scope ;
12
+ use PHPStan \BetterReflection \Reflection \Adapter \ReflectionClass ;
13
+ use PHPStan \BetterReflection \Reflection \Adapter \ReflectionMethod ;
12
14
use PHPStan \BetterReflection \Reflector \Exception \IdentifierNotFound ;
13
15
use PHPStan \DependencyInjection \Container ;
14
16
use PHPStan \DependencyInjection \ParameterNotFoundException ;
19
21
use RecursiveDirectoryIterator ;
20
22
use RecursiveIteratorIterator ;
21
23
use ReflectionAttribute ;
22
- use ReflectionClass ;
23
- use ReflectionMethod ;
24
24
use Reflector ;
25
25
use ShipMonk \PHPStan \DeadCode \Graph \ClassConstantRef ;
26
26
use ShipMonk \PHPStan \DeadCode \Graph \ClassConstantUsage ;
42
42
use function simplexml_load_string ;
43
43
use function sprintf ;
44
44
use function strpos ;
45
- use const PHP_VERSION_ID ;
46
45
47
46
class SymfonyUsageProvider implements MemberUsageProvider
48
47
{
@@ -350,8 +349,10 @@ protected function isConstructorWithAsControllerAttribute(ReflectionMethod $meth
350
349
351
350
protected function isMethodWithRouteAttribute (ReflectionMethod $ method ): bool
352
351
{
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 );
355
356
}
356
357
357
358
/**
@@ -371,15 +372,11 @@ protected function isProbablySymfonyListener(ReflectionMethod $method): bool
371
372
}
372
373
373
374
/**
374
- * @param ReflectionClass<object> |ReflectionMethod $classOrMethod
375
+ * @param ReflectionClass|ReflectionMethod $classOrMethod
375
376
* @param ReflectionAttribute::IS_*|0 $flags
376
377
*/
377
378
protected function hasAttribute (Reflector $ classOrMethod , string $ attributeClass , int $ flags = 0 ): bool
378
379
{
379
- if (PHP_VERSION_ID < 8_00_00 ) {
380
- return false ;
381
- }
382
-
383
380
if ($ classOrMethod ->getAttributes ($ attributeClass ) !== []) {
384
381
return true ;
385
382
}
0 commit comments