diff --git a/src/Psalm/Internal/Type/Comparator/ArrayTypeComparator.php b/src/Psalm/Internal/Type/Comparator/ArrayTypeComparator.php index 1276c8119..4cf3b87dd 100644 --- a/src/Psalm/Internal/Type/Comparator/ArrayTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/ArrayTypeComparator.php @@ -80,9 +80,12 @@ class ArrayTypeComparator } if ($container_type_part instanceof TKeyedArray - && $input_type_part instanceof TKeyedArray && $container_type_part->is_list - && !$input_type_part->is_list + && ( + ($input_type_part instanceof TKeyedArray + && !$input_type_part->is_list) + || $input_type_part instanceof TArray + ) ) { return false; } diff --git a/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php b/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php index f3f86ead9..df4c1160c 100644 --- a/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php +++ b/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php @@ -38,6 +38,14 @@ class KeyedArrayComparator return false; } + if ($container_type_part instanceof TKeyedArray + && $container_type_part->is_list + && $input_type_part instanceof TKeyedArray + && !$input_type_part->is_list + ) { + return false; + } + $all_types_contain = true; $input_properties = $input_type_part->properties;