From 4e89ab93b02fcfa24c8e620d0d597a3cbadaeb5e Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 5 Jan 2025 17:46:02 +0100 Subject: [PATCH] fix combinations count --- src/Type/Php/ImplodeFunctionReturnTypeExtension.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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; }