From 29caa26d608964d933c62030a443a70630591c3c 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..9c7c946883 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 ($combinationsCount > InitializerExprTypeResolver::CALCULATE_SCALARS_LIMIT) { return null; }