diff --git a/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php b/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php index 2217e2d42..0fe9df1d1 100644 --- a/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php +++ b/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php @@ -50,7 +50,7 @@ class KeyedArrayComparator $input_properties = $input_type_part->properties; foreach ($container_type_part->properties as $key => $container_property_type) { - if (!isset($input_properties[$key]) || $input_properties[$key]->possibly_undefined) { + if (!isset($input_properties[$key])) { if (!$container_property_type->possibly_undefined) { $all_types_contain = false; } @@ -58,6 +58,14 @@ class KeyedArrayComparator continue; } + if ($input_properties[$key]->possibly_undefined + && !$container_property_type->possibly_undefined + ) { + $all_types_contain = false; + + continue; + } + $input_property_type = $input_properties[$key]; unset($input_properties[$key]); diff --git a/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php b/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php index 5bf4f5a4d..c4f6e113e 100644 --- a/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php @@ -279,13 +279,6 @@ class ScalarTypeComparator return true; } - if ($container_type_part instanceof TIntRange - && $container_type_part->dependent_list_key - && $input_type_part instanceof TLiteralInt - ) { - return true; - } - if (get_class($container_type_part) === TFloat::class && $input_type_part instanceof TLiteralFloat) { return true; } @@ -336,13 +329,6 @@ class ScalarTypeComparator return true; } - if ($container_type_part instanceof TIntRange - && $container_type_part->dependent_list_key - && $input_type_part instanceof TInt - ) { - return true; - } - if (get_class($input_type_part) === TInt::class && $container_type_part instanceof TLiteralInt) { if ($atomic_comparison_result) { $atomic_comparison_result->type_coerced = true;