|
98 | 98 | use PHPStan\Type\Constant\ConstantIntegerType; |
99 | 99 | use PHPStan\Type\Constant\ConstantStringType; |
100 | 100 | use PHPStan\Type\ConstantTypeHelper; |
101 | | -use PHPStan\Type\DynamicFunctionReturnTypeExtension; |
102 | 101 | use PHPStan\Type\DynamicReturnTypeExtensionRegistry; |
103 | 102 | use PHPStan\Type\ErrorType; |
104 | 103 | use PHPStan\Type\ExpressionTypeResolverExtensionRegistry; |
@@ -193,9 +192,6 @@ class MutatingScope implements Scope, NodeCallbackInvoker |
193 | 192 |
|
194 | 193 | private static int $resolveClosureTypeDepth = 0; |
195 | 194 |
|
196 | | - /** @var array<string, list<DynamicFunctionReturnTypeExtension>> */ |
197 | | - private static array $functionReturnTypeExtensions = []; |
198 | | - |
199 | 195 | /** |
200 | 196 | * @param int|array{min: int, max: int}|null $configPhpVersion |
201 | 197 | * @param callable(Node $node, Scope $scope): void|null $nodeCallback |
@@ -2504,33 +2500,18 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu |
2504 | 2500 |
|
2505 | 2501 | private function getDynamicFunctionReturnType(FuncCall $normalizedNode, FunctionReflection $functionReflection): ?Type |
2506 | 2502 | { |
2507 | | - $functionName = $functionReflection->getName(); |
2508 | | - if (isset(self::$functionReturnTypeExtensions[$functionName])) { |
2509 | | - $extensions = self::$functionReturnTypeExtensions[$functionName]; |
2510 | | - } else { |
2511 | | - $extensions = $this->dynamicReturnTypeExtensionRegistry->getDynamicFunctionReturnTypeExtensions(); |
2512 | | - } |
2513 | | - |
2514 | | - $supportedFunctions = []; |
2515 | | - foreach ($extensions as $dynamicFunctionReturnTypeExtension) { |
2516 | | - if (!$dynamicFunctionReturnTypeExtension->isFunctionSupported($functionReflection)) { |
2517 | | - continue; |
2518 | | - } |
2519 | | - |
| 2503 | + foreach ($this->dynamicReturnTypeExtensionRegistry->getDynamicFunctionReturnTypeExtensions($functionReflection) as $dynamicFunctionReturnTypeExtension) { |
2520 | 2504 | $resolvedType = $dynamicFunctionReturnTypeExtension->getTypeFromFunctionCall( |
2521 | 2505 | $functionReflection, |
2522 | 2506 | $normalizedNode, |
2523 | 2507 | $this, |
2524 | 2508 | ); |
2525 | 2509 |
|
2526 | | - $supportedFunctions[] = $dynamicFunctionReturnTypeExtension; |
2527 | 2510 | if ($resolvedType !== null) { |
2528 | | - self::$functionReturnTypeExtensions[$functionName] ??= $supportedFunctions; |
2529 | 2511 | return $resolvedType; |
2530 | 2512 | } |
2531 | 2513 | } |
2532 | 2514 |
|
2533 | | - self::$functionReturnTypeExtensions[$functionName] ??= $supportedFunctions; |
2534 | 2515 | return null; |
2535 | 2516 | } |
2536 | 2517 |
|
|
0 commit comments