|
35 | 35 | use PHPStan\Reflection\Callables\SimpleImpurePoint; |
36 | 36 | use PHPStan\Reflection\Callables\SimpleThrowPoint; |
37 | 37 | use PHPStan\Reflection\FunctionReflection; |
38 | | -use PHPStan\Reflection\MethodReflection; |
39 | 38 | use PHPStan\Reflection\ParametersAcceptor; |
40 | 39 | use PHPStan\Reflection\ParametersAcceptorSelector; |
41 | 40 | use PHPStan\Reflection\ReflectionProvider; |
@@ -241,8 +240,17 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex |
241 | 240 | continue; |
242 | 241 | } |
243 | 242 |
|
244 | | - $innerCalleeReflection ??= $this->resolveCallUserFuncCalleeReflection($innerFuncCall, $scope); |
245 | | - $byRefType = $nodeScopeResolver->resolveByRefParameterType($innerFuncCall, $innerCalleeReflection, $innerParameter, $scope); |
| 243 | + if ($innerCalleeReflection === null && $innerFuncCall->name instanceof Expr) { |
| 244 | + $calledOnType = $scope->getType($innerFuncCall->name); |
| 245 | + $callableAcceptors = $calledOnType->getCallableParametersAcceptors($scope); |
| 246 | + $innerCalleeReflection = count($callableAcceptors) === 1 |
| 247 | + ? $callableAcceptors[0]->getCalleeReflection() |
| 248 | + : false; |
| 249 | + } |
| 250 | + if ($innerCalleeReflection === null) { |
| 251 | + $innerCalleeReflection = false; |
| 252 | + } |
| 253 | + $byRefType = $nodeScopeResolver->resolveByRefParameterType($innerFuncCall, $innerCalleeReflection !== false ? $innerCalleeReflection : null, $innerParameter, $scope); |
246 | 254 | $scope = $nodeScopeResolver->processVirtualAssign( |
247 | 255 | $scope, |
248 | 256 | $storage, |
@@ -868,41 +876,6 @@ public function resolveType(MutatingScope $scope, Expr $expr): Type |
868 | 876 | return VoidToNullTypeTransformer::transform($parametersAcceptor->getReturnType(), $expr); |
869 | 877 | } |
870 | 878 |
|
871 | | - private function resolveCallUserFuncCalleeReflection(FuncCall $innerFuncCall, MutatingScope $scope): FunctionReflection|MethodReflection|null |
872 | | - { |
873 | | - if ($innerFuncCall->name instanceof Name) { |
874 | | - if ($this->reflectionProvider->hasFunction($innerFuncCall->name, $scope)) { |
875 | | - return $this->reflectionProvider->getFunction($innerFuncCall->name, $scope); |
876 | | - } |
877 | | - return null; |
878 | | - } |
879 | | - |
880 | | - $callbackType = $scope->getType($innerFuncCall->name); |
881 | | - |
882 | | - $constantStrings = $callbackType->getConstantStrings(); |
883 | | - if (count($constantStrings) === 1 && $constantStrings[0]->getValue() !== '') { |
884 | | - $funcName = new Name($constantStrings[0]->getValue()); |
885 | | - if ($this->reflectionProvider->hasFunction($funcName, $scope)) { |
886 | | - return $this->reflectionProvider->getFunction($funcName, $scope); |
887 | | - } |
888 | | - |
889 | | - return null; |
890 | | - } |
891 | | - |
892 | | - $constantArrays = $callbackType->getConstantArrays(); |
893 | | - if (count($constantArrays) === 1) { |
894 | | - $typeAndMethods = $constantArrays[0]->findTypeAndMethodNames(); |
895 | | - if (count($typeAndMethods) === 1 && !$typeAndMethods[0]->isUnknown() && $typeAndMethods[0]->getCertainty()->yes()) { |
896 | | - $methodType = $typeAndMethods[0]->getType(); |
897 | | - if ($methodType->hasMethod($typeAndMethods[0]->getMethod())->yes()) { |
898 | | - return $methodType->getMethod($typeAndMethods[0]->getMethod(), $scope); |
899 | | - } |
900 | | - } |
901 | | - } |
902 | | - |
903 | | - return null; |
904 | | - } |
905 | | - |
906 | 879 | private function getDynamicFunctionReturnType(MutatingScope $scope, FuncCall $normalizedNode, FunctionReflection $functionReflection): ?Type |
907 | 880 | { |
908 | 881 | foreach ($this->dynamicReturnTypeExtensionRegistryProvider->getRegistry()->getDynamicFunctionReturnTypeExtensions($functionReflection) as $dynamicFunctionReturnTypeExtension) { |
|
0 commit comments