diff --git a/src/Psalm/Internal/Type/TypeCombiner.php b/src/Psalm/Internal/Type/TypeCombiner.php index bc25398c72c..1e528170289 100644 --- a/src/Psalm/Internal/Type/TypeCombiner.php +++ b/src/Psalm/Internal/Type/TypeCombiner.php @@ -1167,8 +1167,7 @@ private static function scrapeIntProperties( } if ($type instanceof TLiteralInt) { - $combination->ints ??= []; - if (count($combination->ints) < $literal_limit) { + if ($combination->ints !== null && count($combination->ints) < $literal_limit) { $combination->ints[$type_key] = $type; } else { $combination->ints[$type_key] = $type; @@ -1214,6 +1213,7 @@ private static function scrapeIntProperties( ) { $combination->value_types['int'] = new TInt(); } + $combination->ints = null; } elseif ($type instanceof TIntRange) { $type = clone $type; if ($combination->ints) { @@ -1239,9 +1239,8 @@ private static function scrapeIntProperties( } } else { $combination->value_types['int'] = $type; + $combination->ints = null; } - - $combination->ints = null; } }