diff --git a/src/Type/Php/ImplodeFunctionReturnTypeExtension.php b/src/Type/Php/ImplodeFunctionReturnTypeExtension.php index 60d268fd4..76afc963c 100644 --- a/src/Type/Php/ImplodeFunctionReturnTypeExtension.php +++ b/src/Type/Php/ImplodeFunctionReturnTypeExtension.php @@ -22,6 +22,7 @@ use function count; use function implode; use function in_array; +use const COUNT_RECURSIVE; final class ImplodeFunctionReturnTypeExtension implements DynamicFunctionReturnTypeExtension { @@ -123,16 +124,16 @@ private function inferConstantType(ConstantArrayType $arrayType, ConstantStringT $arrayValues[] = $constScalars; } + if (count($strings) + count($arrayValues, COUNT_RECURSIVE) > InitializerExprTypeResolver::CALCULATE_SCALARS_LIMIT) { + return null; + } + $combinations = CombinationsHelper::combinations($arrayValues); foreach ($combinations as $combination) { $strings[] = new ConstantStringType(implode($separatorType->getValue(), $combination)); } } - if (count($strings) > InitializerExprTypeResolver::CALCULATE_SCALARS_LIMIT) { - return null; - } - return TypeCombinator::union(...$strings); }