10
10
use PhpParser \Node \Expr \New_ ;
11
11
use PhpParser \Node \Name \FullyQualified ;
12
12
use PHPStan \Analyser \Scope ;
13
+ use PHPStan \Reflection \ReflectionProvider ;
13
14
use PHPStan \Rules \IdentifierRuleError ;
14
15
use PHPStan \Rules \Rule ;
15
16
use PHPStan \Rules \RuleErrorBuilder ;
@@ -34,12 +35,14 @@ final class DoctrineKeyValueStyleRule implements Rule
34
35
*/
35
36
private array $ classMethods ;
36
37
38
+ private ReflectionProvider $ reflectionProvider ;
39
+
37
40
private ?QueryReflection $ queryReflection = null ;
38
41
39
42
/**
40
43
* @param list<string> $classMethods
41
44
*/
42
- public function __construct (array $ classMethods )
45
+ public function __construct (array $ classMethods, ReflectionProvider $ reflectionProvider )
43
46
{
44
47
$ this ->classMethods = [];
45
48
foreach ($ classMethods as $ classMethod ) {
@@ -54,6 +57,8 @@ public function __construct(array $classMethods)
54
57
}
55
58
$ this ->classMethods [] = [$ className , $ methodName , $ arrayArgPositions ];
56
59
}
60
+
61
+ $ this ->reflectionProvider = $ reflectionProvider ;
57
62
}
58
63
59
64
public function getNodeType (): string
@@ -89,7 +94,7 @@ public function processNode(Node $callLike, Scope $scope): array
89
94
$ arrayArgPositions = [];
90
95
foreach ($ this ->classMethods as [$ className , $ methodName , $ arrayArgPositionsConfig ]) {
91
96
if ($ methodName === $ methodReflection ->getName () &&
92
- ($ methodReflection ->getDeclaringClass ()->getName () === $ className || $ methodReflection ->getDeclaringClass ()->isSubclassOf ( $ className ))) {
97
+ ($ methodReflection ->getDeclaringClass ()->getName () === $ className || $ methodReflection ->getDeclaringClass ()->isSubclassOfClass ( $ this -> reflectionProvider -> getClass ( $ className) ))) {
93
98
$ arrayArgPositions = $ arrayArgPositionsConfig ;
94
99
$ unsupportedMethod = false ;
95
100
break ;
0 commit comments