|
7 | 7 | use PhpParser\Node\Expr; |
8 | 8 | use PhpParser\Node\Expr\BinaryOp\Concat; |
9 | 9 | use PhpParser\Node\Identifier; |
| 10 | +use PhpParser\Node\Name; |
10 | 11 | use PHPStan\Analyser\Scope; |
11 | 12 | use PHPStan\ShouldNotHappenException; |
12 | 13 | use PHPStan\Type\Constant\ConstantArrayType; |
@@ -187,13 +188,21 @@ private function resolveQueryExpr(Expr $queryExpr, Scope $scope): ?string |
187 | 188 | */ |
188 | 189 | private function resolveQueryStringExpr(Expr $queryExpr, Scope $scope): ?string |
189 | 190 | { |
190 | | - if ($queryExpr instanceof Expr\MethodCall && $queryExpr->name instanceof Identifier) { |
191 | | - $classReflection = $scope->getClassReflection(); |
192 | | - |
193 | | - // XXX atm we only support inference-placeholder for method calls within the same class |
194 | | - if (null !== $classReflection && $classReflection->hasMethod($queryExpr->name->name)) { |
195 | | - $methodReflection = $classReflection->getMethod($queryExpr->name->name, $scope); |
| 191 | + if ($queryExpr instanceof Expr\CallLike) { |
| 192 | + $methodReflection = null; |
| 193 | + if ($queryExpr instanceof Expr\StaticCall) { |
| 194 | + if ($queryExpr->class instanceof Name && $queryExpr->name instanceof Identifier) { |
| 195 | + $classType = $scope->resolveTypeByName($queryExpr->class); |
| 196 | + $methodReflection = $scope->getMethodReflection($classType, $queryExpr->name->name); |
| 197 | + } |
| 198 | + } elseif ($queryExpr instanceof Expr\MethodCall && $queryExpr->name instanceof Identifier) { |
| 199 | + $classReflection = $scope->getClassReflection(); |
| 200 | + if (null !== $classReflection && $classReflection->hasMethod($queryExpr->name->name)) { |
| 201 | + $methodReflection = $classReflection->getMethod($queryExpr->name->name, $scope); |
| 202 | + } |
| 203 | + } |
196 | 204 |
|
| 205 | + if (null !== $methodReflection) { |
197 | 206 | // atm no resolved phpdoc for methods |
198 | 207 | // see https://github.com/phpstan/phpstan/discussions/7657 |
199 | 208 | $phpDocString = $methodReflection->getDocComment(); |
|
0 commit comments