Skip to content

Commit 05dbd5e

Browse files
committed
Revert "ArrayType::setOffsetValueType() - generalize item type if it goes over a threshold"
This reverts commit 10ba3c6.
1 parent ab7f8d2 commit 05dbd5e

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/Type/ArrayType.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,10 @@ public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $uni
285285
$keyType = $keyType->generalize(GeneralizePrecision::moreSpecific());
286286
}
287287

288-
$itemType = $valueType;
289-
if ($unionValues) {
290-
$itemType = TypeCombinator::union($this->itemType, $valueType);
291-
if (count(TypeUtils::getConstantScalars($itemType)) > ConstantArrayTypeBuilder::ARRAY_COUNT_LIMIT) {
292-
$itemType = $itemType->generalize(GeneralizePrecision::moreSpecific());
293-
}
294-
}
295-
296-
$array = new self($keyType, $itemType);
288+
$array = new self(
289+
$keyType,
290+
$unionValues ? TypeCombinator::union($this->itemType, $valueType) : $valueType,
291+
);
297292
if ($offsetType instanceof ConstantIntegerType || $offsetType instanceof ConstantStringType) {
298293
return TypeCombinator::intersect($array, new HasOffsetValueType($offsetType, $valueType), new NonEmptyArrayType());
299294
}

0 commit comments

Comments
 (0)