88use PHPStan \Internal \SprintfHelper ;
99use PHPStan \Reflection \ParametersAcceptorSelector ;
1010use PHPStan \Rules \FunctionCallParametersCheck ;
11+ use PHPStan \Rules \IdentifierRuleError ;
1112use PHPStan \Rules \Rule ;
13+ use PHPStan \Type \Constant \ConstantStringType ;
14+ use function array_map ;
1215use function array_merge ;
1316
1417/**
@@ -31,12 +34,33 @@ public function getNodeType(): string
3134
3235 public function processNode (Node $ node , Scope $ scope ): array
3336 {
34- if (!$ node ->name instanceof Node \Identifier) {
35- return [];
37+ if ($ node ->name instanceof Node \Identifier) {
38+ $ methodNames = [$ node ->name ->name ];
39+ } else {
40+ $ methodNames = array_map (
41+ static fn (ConstantStringType $ constantString ): string => $ constantString ->getValue (),
42+ $ scope ->getType ($ node ->name )->getConstantStrings (),
43+ );
44+ if ($ methodNames === []) {
45+ return [];
46+ }
3647 }
3748
38- $ methodName = $ node ->name ->name ;
49+ foreach ($ methodNames as $ methodName ) {
50+ $ errors = $ this ->processMethod ($ methodName , $ node , $ scope );
51+ if ($ errors !== []) {
52+ return $ errors ;
53+ }
54+ }
55+
56+ return [];
57+ }
3958
59+ /**
60+ * @return list<IdentifierRuleError>
61+ */
62+ private function processMethod (string $ methodName , MethodCall $ node , Scope $ scope ): array
63+ {
4064 [$ errors , $ methodReflection ] = $ this ->methodCallCheck ->check ($ scope , $ methodName , $ node ->var );
4165 if ($ methodReflection === null ) {
4266 return $ errors ;
0 commit comments