From 956fa4458e9e02f4f337ab08ae96899e48fb4b19 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 26 Nov 2022 15:11:43 +0100 Subject: [PATCH] Cleanup --- .../Type/SimpleAssertionReconciler.php | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php index 3cb551454..36ddd0a91 100644 --- a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php +++ b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php @@ -562,6 +562,7 @@ class SimpleAssertionReconciler extends Reconciler } /** + * @param NonEmptyCountable|HasAtLeastCount $assertion * @param string[] $suppressed_issues */ private static function reconcileNonEmptyCountable( @@ -599,20 +600,6 @@ class SimpleAssertionReconciler extends Reconciler $redundant = false; } - } elseif ($array_atomic_type instanceof TList) { - if (!$array_atomic_type instanceof TNonEmptyList - || ($assertion instanceof HasAtLeastCount - && $array_atomic_type->count < $assertion->count) - ) { - $non_empty_list = Type::getNonEmptyListAtomic( - $array_atomic_type->type_param, - null, - $assertion instanceof HasAtLeastCount ? $assertion->count : null - ); - - $redundant = false; - $existing_var_type->addType($non_empty_list); - } } elseif ($array_atomic_type instanceof TKeyedArray) { $prop_max_count = count($array_atomic_type->properties); $prop_min_count = 0; @@ -659,17 +646,16 @@ class SimpleAssertionReconciler extends Reconciler } else { $redundant = false; } - } elseif ($array_atomic_type->is_list - && $prop_min_count === $prop_max_count - ) { + } elseif ($array_atomic_type->is_list) { if ($assertion->count <= $prop_min_count) { $redundant = true; } else { $redundant = false; $properties = $array_atomic_type->properties; for ($i = $prop_max_count; $i < $assertion->count; $i++) { - $properties[$i] - = $array_atomic_type->fallback_params[1]; + $properties[$i] = $properties[$i] + ? $properties[$i]->setPossiblyUndefined(false) + : $array_atomic_type->fallback_params[1]; } $array_atomic_type = $array_atomic_type->setProperties($properties); $existing_var_type->removeType('array');