mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 22:01:48 +01:00
Small assertion fix
This commit is contained in:
parent
c620f6e80d
commit
dbded437ad
@ -171,6 +171,7 @@ class Reconciler
|
|||||||
$has_negation = false;
|
$has_negation = false;
|
||||||
$has_isset = false;
|
$has_isset = false;
|
||||||
$has_inverted_isset = false;
|
$has_inverted_isset = false;
|
||||||
|
$has_inverted_key_exists = false;
|
||||||
$has_truthy_or_falsy_or_empty = false;
|
$has_truthy_or_falsy_or_empty = false;
|
||||||
$has_empty = false;
|
$has_empty = false;
|
||||||
$has_count_check = false;
|
$has_count_check = false;
|
||||||
@ -201,7 +202,9 @@ class Reconciler
|
|||||||
&& $new_type_part_part instanceof IsIdentical;
|
&& $new_type_part_part instanceof IsIdentical;
|
||||||
|
|
||||||
$has_inverted_isset = $has_inverted_isset
|
$has_inverted_isset = $has_inverted_isset
|
||||||
|| $new_type_part_part instanceof IsNotIsset
|
|| $new_type_part_part instanceof IsNotIsset;
|
||||||
|
|
||||||
|
$has_inverted_key_exists = $has_inverted_key_exists
|
||||||
|| $new_type_part_part instanceof ArrayKeyDoesNotExist;
|
|| $new_type_part_part instanceof ArrayKeyDoesNotExist;
|
||||||
|
|
||||||
$has_count_check = $has_count_check
|
$has_count_check = $has_count_check
|
||||||
@ -221,6 +224,7 @@ class Reconciler
|
|||||||
$code_location,
|
$code_location,
|
||||||
$has_isset,
|
$has_isset,
|
||||||
$has_inverted_isset,
|
$has_inverted_isset,
|
||||||
|
$has_inverted_key_exists,
|
||||||
$has_empty,
|
$has_empty,
|
||||||
$inside_loop,
|
$inside_loop,
|
||||||
$has_object_array_access,
|
$has_object_array_access,
|
||||||
@ -334,7 +338,7 @@ class Reconciler
|
|||||||
if ($type_changed || $failed_reconciliation) {
|
if ($type_changed || $failed_reconciliation) {
|
||||||
$changed_var_ids[$key] = true;
|
$changed_var_ids[$key] = true;
|
||||||
|
|
||||||
if (substr($key, -1) === ']' && !$has_inverted_isset && !$has_empty && !$is_equality) {
|
if (substr($key, -1) === ']' && !$has_inverted_isset && !$has_inverted_key_exists && !$has_empty && !$is_equality) {
|
||||||
self::adjustTKeyedArrayType(
|
self::adjustTKeyedArrayType(
|
||||||
$key_parts,
|
$key_parts,
|
||||||
$existing_types,
|
$existing_types,
|
||||||
@ -648,6 +652,7 @@ class Reconciler
|
|||||||
?CodeLocation $code_location,
|
?CodeLocation $code_location,
|
||||||
bool $has_isset,
|
bool $has_isset,
|
||||||
bool $has_inverted_isset,
|
bool $has_inverted_isset,
|
||||||
|
bool $has_inverted_key_exists,
|
||||||
bool $has_empty,
|
bool $has_empty,
|
||||||
bool $inside_loop,
|
bool $inside_loop,
|
||||||
bool &$has_object_array_access
|
bool &$has_object_array_access
|
||||||
@ -723,11 +728,11 @@ class Reconciler
|
|||||||
|
|
||||||
$new_base_type_candidate = $existing_key_type_part->type_params[1];
|
$new_base_type_candidate = $existing_key_type_part->type_params[1];
|
||||||
|
|
||||||
if ($new_base_type_candidate->isMixed() && !$has_isset && !$has_inverted_isset) {
|
if ($new_base_type_candidate->isMixed() && !$has_isset && !$has_inverted_isset && !$has_inverted_key_exists) {
|
||||||
return $new_base_type_candidate;
|
return $new_base_type_candidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($has_isset || $has_inverted_isset) && isset($new_assertions[$new_base_key])) {
|
if (($has_isset || $has_inverted_isset || $has_inverted_key_exists) && isset($new_assertions[$new_base_key])) {
|
||||||
if ($has_inverted_isset && $new_base_key === $key) {
|
if ($has_inverted_isset && $new_base_key === $key) {
|
||||||
$new_base_type_candidate = $new_base_type_candidate->getBuilder();
|
$new_base_type_candidate = $new_base_type_candidate->getBuilder();
|
||||||
$new_base_type_candidate->addType(new TNull);
|
$new_base_type_candidate->addType(new TNull);
|
||||||
@ -756,7 +761,7 @@ class Reconciler
|
|||||||
} elseif ($existing_key_type_part instanceof TString) {
|
} elseif ($existing_key_type_part instanceof TString) {
|
||||||
$new_base_type_candidate = Type::getString();
|
$new_base_type_candidate = Type::getString();
|
||||||
} elseif ($existing_key_type_part instanceof TNamedObject
|
} elseif ($existing_key_type_part instanceof TNamedObject
|
||||||
&& ($has_isset || $has_inverted_isset)
|
&& ($has_isset || $has_inverted_isset || $has_inverted_key_exists)
|
||||||
) {
|
) {
|
||||||
$has_object_array_access = true;
|
$has_object_array_access = true;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user