1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-11 00:39:38 +01:00
This commit is contained in:
Daniil Gentili 2022-11-26 14:52:50 +01:00
parent b43207e4cb
commit 415d10365f
2 changed files with 9 additions and 6 deletions

View File

@ -2000,7 +2000,7 @@ class SimpleAssertionReconciler extends Reconciler
$did_remove_type = false;
foreach ($existing_var_atomic_types as $type) {
if ($type instanceof TArray || $type instanceof TKeyedArray || $type instanceof TList) {
if ($type instanceof TArray || $type instanceof TKeyedArray) {
$array_types[] = $type;
} elseif ($type instanceof TCallable) {
$array_types[] = new TCallableKeyedArray([
@ -2094,11 +2094,11 @@ class SimpleAssertionReconciler extends Reconciler
$did_remove_type = false;
foreach ($existing_var_atomic_types as $type) {
if ($type instanceof TList
|| ($type instanceof TKeyedArray && $type->is_list)
) {
if ($is_non_empty && $type instanceof TList && !$type instanceof TNonEmptyList) {
$array_types[] = Type::getNonEmptyListAtomic($type->type_param);
if ($type instanceof TKeyedArray && $type->is_list) {
if ($is_non_empty && !$type->isNonEmpty()) {
$properties = $type->properties;
$properties[0] = $properties[0]->setPossiblyUndefined(false);
$array_types[] = $type->setProperties($properties);
$did_remove_type = true;
} else {
$array_types[] = $type;

View File

@ -358,6 +358,9 @@ class TKeyedArray extends Atomic
public function isNonEmpty(): bool
{
if ($this->is_list) {
return !$this->properties[0]->possibly_undefined;
}
foreach ($this->properties as $property) {
if (!$property->possibly_undefined) {
return true;