Skip to content

Commit 450b7b6

Browse files
committed
generalize array based logic
1 parent 9954344 commit 450b7b6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Type/Php/ImplodeFunctionReturnTypeExtension.php

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

2627
final class ImplodeFunctionReturnTypeExtension implements DynamicFunctionReturnTypeExtension
2728
{
@@ -123,16 +124,16 @@ private function inferConstantType(ConstantArrayType $arrayType, ConstantStringT
123124
$arrayValues[] = $constScalars;
124125
}
125126

127+
if (count($strings) + count($arrayValues, COUNT_RECURSIVE) > InitializerExprTypeResolver::CALCULATE_SCALARS_LIMIT) {
128+
return null;
129+
}
130+
126131
$combinations = CombinationsHelper::combinations($arrayValues);
127132
foreach ($combinations as $combination) {
128133
$strings[] = new ConstantStringType(implode($separatorType->getValue(), $combination));
129134
}
130135
}
131136

132-
if (count($strings) > InitializerExprTypeResolver::CALCULATE_SCALARS_LIMIT) {
133-
return null;
134-
}
135-
136137
return TypeCombinator::union(...$strings);
137138
}
138139

0 commit comments

Comments
 (0)