|
49 | 49 | use PhpParser\NodeFinder; |
50 | 50 | use PhpParser\NodeTraverser; |
51 | 51 | use PHPStan\Analyser\ExprHandler\AssignHandler; |
| 52 | +use PHPStan\Analyser\ExprHandler\Helper\ClosureTypeResolver; |
52 | 53 | use PHPStan\Analyser\ExprHandler\Helper\ImplicitToStringCallHelper; |
53 | 54 | use PHPStan\Analyser\ExprHandler\Helper\MethodThrowPointHelper; |
54 | 55 | use PHPStan\BetterReflection\Reflection\Adapter\ReflectionClass; |
@@ -3875,6 +3876,10 @@ public function processArgs( |
3875 | 3876 |
|
3876 | 3877 | $this->callNodeCallbackWithExpression($nodeCallback, $arg->value, $scopeToPass, $storage, $context); |
3877 | 3878 | $closureResult = $this->processClosureNode($stmt, $arg->value, $scopeToPass, $storage, $nodeCallback, $context, $parameterType, $parameterNativeType); |
| 3879 | + // the preferred ClosureType read below now answers from this seed |
| 3880 | + // instead of walking the body again (unless a parked fiber may |
| 3881 | + // still complete the gathered data - then it keeps re-walking) |
| 3882 | + $this->container->getByType(ClosureTypeResolver::class)->seedCacheFromClosureWalk($scopeToPass, $arg->value, $closureResult, $storage); |
3878 | 3883 | if ($this->callCallbackImmediately($parameter, $parameterType, $calleeReflection)) { |
3879 | 3884 | $throwPoints = array_merge($throwPoints, array_map(static fn (InternalThrowPoint $throwPoint) => $throwPoint->isExplicit() ? InternalThrowPoint::createExplicit($scope, $throwPoint->getType(), $arg->value, $throwPoint->canContainAnyThrowable()) : InternalThrowPoint::createImplicit($scope, $arg->value), $closureResult->getThrowPoints())); |
3880 | 3885 | $impurePoints = array_merge($impurePoints, $closureResult->getImpurePoints()); |
@@ -3958,7 +3963,12 @@ public function processArgs( |
3958 | 3963 | } |
3959 | 3964 |
|
3960 | 3965 | $this->callNodeCallbackWithExpression($nodeCallback, $arg->value, $scopeToPass, $storage, $context); |
3961 | | - $arrowFunctionResult = $this->processArrowFunctionNode($stmt, $arg->value, $scopeToPass, $storage, $nodeCallback, $parameterType, $parameterNativeType)->getExpressionResult(); |
| 3966 | + $processArrowFunctionResult = $this->processArrowFunctionNode($stmt, $arg->value, $scopeToPass, $storage, $nodeCallback, $parameterType, $parameterNativeType); |
| 3967 | + // the invalidation read below now answers from this seed instead |
| 3968 | + // of walking the body again (unless a parked fiber may still |
| 3969 | + // complete the gathered data - then it keeps re-walking) |
| 3970 | + $this->container->getByType(ClosureTypeResolver::class)->seedCacheFromArrowFunctionWalk($scopeToPass, $arg->value, $processArrowFunctionResult, $storage); |
| 3971 | + $arrowFunctionResult = $processArrowFunctionResult->getExpressionResult(); |
3962 | 3972 | if ($this->callCallbackImmediately($parameter, $parameterType, $calleeReflection)) { |
3963 | 3973 | $throwPoints = array_merge($throwPoints, array_map(static fn (InternalThrowPoint $throwPoint) => $throwPoint->isExplicit() ? InternalThrowPoint::createExplicit($scope, $throwPoint->getType(), $arg->value, $throwPoint->canContainAnyThrowable()) : InternalThrowPoint::createImplicit($scope, $arg->value), $arrowFunctionResult->getThrowPoints())); |
3964 | 3974 | $impurePoints = array_merge($impurePoints, $arrowFunctionResult->getImpurePoints()); |
|
0 commit comments