Skip to content

Commit 7340657

Browse files
committed
array_merge optimization
1 parent a37e631 commit 7340657

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Type/Php/ArrayMergeFunctionDynamicReturnTypeExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
3333
$returnedArrayBuilder = ConstantArrayTypeBuilder::createEmpty();
3434
$returnedArrayBuilderFilled = false;
3535
$nonEmpty = false;
36+
$offsetCount = 0;
3637
foreach ($functionCall->args as $arg) {
3738
$argType = $scope->getType($arg->value);
3839

@@ -45,6 +46,10 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
4546
foreach ($arrays as $constantArray) {
4647
foreach ($constantArray->getKeyTypes() as $i => $keyType) {
4748
$returnedArrayBuilderFilled = true;
49+
$offsetCount++;
50+
if ($offsetCount > ConstantArrayTypeBuilder::ARRAY_COUNT_LIMIT) {
51+
$returnedArrayBuilder->degradeToGeneralArray();
52+
}
4853

4954
$returnedArrayBuilder->setOffsetValueType(
5055
is_numeric($keyType->getValue()) ? null : $keyType,

0 commit comments

Comments
 (0)