Skip to content

Commit 9a991c8

Browse files
committed
fix combinations count
1 parent 06ca776 commit 9a991c8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Type/Php/ImplodeFunctionReturnTypeExtension.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use function count;
2323
use function implode;
2424
use function in_array;
25-
use const COUNT_RECURSIVE;
2625

2726
final class ImplodeFunctionReturnTypeExtension implements DynamicFunctionReturnTypeExtension
2827
{
@@ -116,15 +115,17 @@ private function inferConstantType(ConstantArrayType $arrayType, ConstantStringT
116115
$valueTypes = $array->getValueTypes();
117116

118117
$arrayValues = [];
118+
$combinationsCount = 1;
119119
foreach ($valueTypes as $valueType) {
120120
$constScalars = $valueType->getConstantScalarValues();
121121
if (count($constScalars) === 0) {
122122
return null;
123123
}
124124
$arrayValues[] = $constScalars;
125+
$combinationsCount *= count($constScalars);
125126
}
126127

127-
if (count($strings) + count($arrayValues, COUNT_RECURSIVE) > InitializerExprTypeResolver::CALCULATE_SCALARS_LIMIT) {
128+
if (count($strings) + $combinationsCount > InitializerExprTypeResolver::CALCULATE_SCALARS_LIMIT) {
128129
return null;
129130
}
130131

0 commit comments

Comments
 (0)