Skip to content

Commit

Permalink
Change code so it handles what it was designed for
Browse files Browse the repository at this point in the history
  • Loading branch information
orklah committed Jan 30, 2022
1 parent faaf769 commit 5a3735b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
Expand Up @@ -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) {
Expand Down
20 changes: 10 additions & 10 deletions src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php
Expand Up @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit 5a3735b

Please sign in to comment.