1010use PhpParser \Node \Expr \New_ ;
1111use PhpParser \Node \Name \FullyQualified ;
1212use PHPStan \Analyser \Scope ;
13+ use PHPStan \Reflection \ReflectionProvider ;
1314use PHPStan \Rules \IdentifierRuleError ;
1415use PHPStan \Rules \Rule ;
1516use PHPStan \Rules \RuleErrorBuilder ;
@@ -34,12 +35,14 @@ final class DoctrineKeyValueStyleRule implements Rule
3435 */
3536 private array $ classMethods ;
3637
38+ private ReflectionProvider $ reflectionProvider ;
39+
3740 private ?QueryReflection $ queryReflection = null ;
3841
3942 /**
4043 * @param list<string> $classMethods
4144 */
42- public function __construct (array $ classMethods )
45+ public function __construct (array $ classMethods, ReflectionProvider $ reflectionProvider )
4346 {
4447 $ this ->classMethods = [];
4548 foreach ($ classMethods as $ classMethod ) {
@@ -54,6 +57,8 @@ public function __construct(array $classMethods)
5457 }
5558 $ this ->classMethods [] = [$ className , $ methodName , $ arrayArgPositions ];
5659 }
60+
61+ $ this ->reflectionProvider = $ reflectionProvider ;
5762 }
5863
5964 public function getNodeType (): string
@@ -89,7 +94,7 @@ public function processNode(Node $callLike, Scope $scope): array
8994 $ arrayArgPositions = [];
9095 foreach ($ this ->classMethods as [$ className , $ methodName , $ arrayArgPositionsConfig ]) {
9196 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) ))) {
9398 $ arrayArgPositions = $ arrayArgPositionsConfig ;
9499 $ unsupportedMethod = false ;
95100 break ;
0 commit comments