From ab7760e044bf6fd5b5252b9ce29c4e1d87216f01 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Wed, 7 Sep 2022 17:12:06 +0200 Subject: [PATCH] Revert "ArrayType::setOffsetValueType() - generalize key type if it goes over a threshold" This reverts commit 24aee609ebf91b0100e2f60b78cde5a785936b81. --- src/Type/ArrayType.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Type/ArrayType.php b/src/Type/ArrayType.php index f62ee9da8c..49cc1712b4 100644 --- a/src/Type/ArrayType.php +++ b/src/Type/ArrayType.php @@ -25,7 +25,6 @@ use PHPStan\Type\Traits\UndecidedBooleanTypeTrait; use PHPStan\Type\Traits\UndecidedComparisonTypeTrait; use function array_merge; -use function count; use function is_float; use function is_int; use function key; @@ -280,13 +279,8 @@ public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $uni return $builder->getArray(); } - $keyType = TypeCombinator::union($this->keyType, $offsetType); - if (count(TypeUtils::getConstantScalars($keyType)) > ConstantArrayTypeBuilder::ARRAY_COUNT_LIMIT) { - $keyType = $keyType->generalize(GeneralizePrecision::moreSpecific()); - } - $array = new self( - $keyType, + TypeCombinator::union($this->keyType, $offsetType), $unionValues ? TypeCombinator::union($this->itemType, $valueType) : $valueType, ); if ($offsetType instanceof ConstantIntegerType || $offsetType instanceof ConstantStringType) {