diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php index c76bcfd70b7..11831441299 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php @@ -1099,10 +1099,7 @@ private static function handleArrayAccessOnArray( ): void { $has_array_access = true; - if ($in_assignment - && $type instanceof TArray - && $type->isEmptyArray() - ) { + if ($in_assignment && $type instanceof TArray) { $from_empty_array = $type->isEmptyArray(); if (count($key_values) === 1) { diff --git a/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php index 148cec13af5..6e32b7a3f57 100644 --- a/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php +++ b/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php @@ -527,7 +527,16 @@ private static function reconcileNotNonEmptyCountable( $did_remove_type = true; $existing_var_type->removeType('array'); - } elseif (!($array_atomic_type instanceof TArray && $array_atomic_type->isEmptyArray())) { + } elseif ($array_atomic_type instanceof TKeyedArray) { + $did_remove_type = true; + + foreach ($array_atomic_type->properties as $property_type) { + if (!$property_type->possibly_undefined) { + $did_remove_type = false; + break; + } + } + } elseif (!$array_atomic_type instanceof TArray || !$array_atomic_type->isEmptyArray()) { $did_remove_type = true; if (!$min_count) { @@ -538,15 +547,6 @@ private static function reconcileNotNonEmptyCountable( ] )); } - } elseif ($array_atomic_type instanceof TKeyedArray) { - $did_remove_type = true; - - foreach ($array_atomic_type->properties as $property_type) { - if (!$property_type->possibly_undefined) { - $did_remove_type = false; - break; - } - } } if (!$is_equality