|
20 | 20 | use PhpParser\Node\Stmt\Return_;
|
21 | 21 | use PHPStan\Analyser\Scope;
|
22 | 22 | use PHPStan\Reflection\ClassReflection;
|
23 |
| -use PHPStan\Reflection\FunctionVariantWithPhpDocs; |
| 23 | +use PHPStan\Reflection\Native\NativeFunctionReflection; |
| 24 | +use PHPStan\Reflection\ParametersAcceptorWithPhpDocs; |
24 | 25 | use PHPStan\Type\MixedType;
|
25 | 26 | use PHPStan\Type\StaticType;
|
26 | 27 | use PHPStan\Type\Type;
|
@@ -116,18 +117,13 @@ public function resolveMethodCallReturnType($call) : ?Type
|
116 | 117 | return null;
|
117 | 118 | }
|
118 | 119 | $parametersAcceptorWithPhpDocs = ParametersAcceptorSelectorVariantsWrapper::select($methodReflection, $call, $scope);
|
119 |
| - if ($parametersAcceptorWithPhpDocs instanceof FunctionVariantWithPhpDocs) { |
| 120 | + if ($methodReflection instanceof NativeFunctionReflection) { |
| 121 | + $returnType = $parametersAcceptorWithPhpDocs->getReturnType(); |
| 122 | + } elseif ($parametersAcceptorWithPhpDocs instanceof ParametersAcceptorWithPhpDocs) { |
120 | 123 | // native return type is needed, as docblock can be false
|
121 | 124 | $returnType = $parametersAcceptorWithPhpDocs->getNativeReturnType();
|
122 | 125 | } else {
|
123 | 126 | $returnType = $parametersAcceptorWithPhpDocs->getReturnType();
|
124 |
| - // around PHPStan 1.12.4+ handling |
125 |
| - if (\method_exists($parametersAcceptorWithPhpDocs, 'getNativeReturnType')) { |
126 |
| - $nativeReturnType = $parametersAcceptorWithPhpDocs->getNativeReturnType(); |
127 |
| - if ($nativeReturnType instanceof MixedType && !$nativeReturnType->isExplicitMixed()) { |
128 |
| - $returnType = $nativeReturnType; |
129 |
| - } |
130 |
| - } |
131 | 127 | }
|
132 | 128 | if ($returnType instanceof MixedType) {
|
133 | 129 | if ($returnType->isExplicitMixed()) {
|
|
0 commit comments