diff --git a/src/Type/Php/ImplodeFunctionReturnTypeExtension.php b/src/Type/Php/ImplodeFunctionReturnTypeExtension.php index 76afc963c2..4cdc080ac1 100644 --- a/src/Type/Php/ImplodeFunctionReturnTypeExtension.php +++ b/src/Type/Php/ImplodeFunctionReturnTypeExtension.php @@ -22,7 +22,6 @@ use function count; use function implode; use function in_array; -use const COUNT_RECURSIVE; final class ImplodeFunctionReturnTypeExtension implements DynamicFunctionReturnTypeExtension { @@ -116,15 +115,17 @@ private function inferConstantType(ConstantArrayType $arrayType, ConstantStringT $valueTypes = $array->getValueTypes(); $arrayValues = []; + $combinationsCount = 1; foreach ($valueTypes as $valueType) { $constScalars = $valueType->getConstantScalarValues(); if (count($constScalars) === 0) { return null; } $arrayValues[] = $constScalars; + $combinationsCount *= count($constScalars); } - if (count($strings) + count($arrayValues, COUNT_RECURSIVE) > InitializerExprTypeResolver::CALCULATE_SCALARS_LIMIT) { + if (count($strings) + $combinationsCount > InitializerExprTypeResolver::CALCULATE_SCALARS_LIMIT) { return null; }