Skip to content

Commit a37e631

Browse files
committed
array_replace optimization
1 parent 7114465 commit a37e631

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Type/Php/ArrayReplaceFunctionDynamicReturnTypeExtension.php

Lines changed: 6 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,11 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
4546
foreach ($arrays as $constantArray) {
4647
foreach ($constantArray->getKeyTypes() as $i => $keyType) {
4748
$returnedArrayBuilderFilled = true;
49+
$offsetCount++;
50+
51+
if ($offsetCount > ConstantArrayTypeBuilder::ARRAY_COUNT_LIMIT) {
52+
$returnedArrayBuilder->degradeToGeneralArray();
53+
}
4854

4955
$returnedArrayBuilder->setOffsetValueType(
5056
$keyType,

0 commit comments

Comments
 (0)