1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-04 18:48:03 +01:00

Use ArrayCreationInfo for can_create_objectlike flag

This commit is contained in:
Bruce Weirdan 2021-08-11 00:39:56 +03:00
parent ba4f1db2cd
commit b6ade31dd0
No known key found for this signature in database
GPG Key ID: CFC3AAB181751B0D

View File

@ -430,8 +430,6 @@ class SimpleTypeInferer
return Type::getEmptyArray();
}
$can_create_objectlike = true;
$is_list = true;
$array_creation_info = new ArrayCreationInfo();
@ -486,7 +484,7 @@ class SimpleTypeInferer
$key_value = $item->key ? $item->key->value : $int_offset;
$array_creation_info->property_types[$key_value] = $single_item_value_type;
} else {
$can_create_objectlike = false;
$array_creation_info->can_create_objectlike = false;
}
if ($item->key
@ -509,7 +507,7 @@ class SimpleTypeInferer
|| $dim_type->hasMixed()
|| count($array_creation_info->property_types) > 50
) {
$can_create_objectlike = false;
$array_creation_info->can_create_objectlike = false;
} else {
$atomic_type = array_shift($dim_atomic_types);
@ -522,7 +520,7 @@ class SimpleTypeInferer
$array_creation_info->property_types[$atomic_type->value] = $single_item_value_type;
} else {
$can_create_objectlike = false;
$array_creation_info->can_create_objectlike = false;
}
}
}
@ -559,7 +557,7 @@ class SimpleTypeInferer
if ($item_value_type
&& $item_key_type
&& ($item_key_type->hasString() || $item_key_type->hasInt())
&& $can_create_objectlike
&& $array_creation_info->can_create_objectlike
&& $array_creation_info->property_types
) {
$objectlike = new Type\Atomic\TKeyedArray(