Skip to content

Commit

Permalink
Revert "ArrayType::setOffsetValueType() - generalize item type if it …
Browse files Browse the repository at this point in the history
…goes over a threshold"

This reverts commit 10ba3c6.
  • Loading branch information
ondrejmirtes committed Sep 7, 2022
1 parent ab7f8d2 commit 05dbd5e
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/Type/ArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,10 @@ public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $uni
$keyType = $keyType->generalize(GeneralizePrecision::moreSpecific());
}

$itemType = $valueType;
if ($unionValues) {
$itemType = TypeCombinator::union($this->itemType, $valueType);
if (count(TypeUtils::getConstantScalars($itemType)) > ConstantArrayTypeBuilder::ARRAY_COUNT_LIMIT) {
$itemType = $itemType->generalize(GeneralizePrecision::moreSpecific());
}
}

$array = new self($keyType, $itemType);
$array = new self(
$keyType,
$unionValues ? TypeCombinator::union($this->itemType, $valueType) : $valueType,
);
if ($offsetType instanceof ConstantIntegerType || $offsetType instanceof ConstantStringType) {
return TypeCombinator::intersect($array, new HasOffsetValueType($offsetType, $valueType), new NonEmptyArrayType());
}
Expand Down

0 comments on commit 05dbd5e

Please sign in to comment.