From 03c53d7c9783808347f76915c7584ab174d11d27 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 21 Nov 2022 19:26:09 +0100 Subject: [PATCH] Deprecate TList and TNonEmptyList --- psalm-baseline.xml | 221 +++++++++++++++++++++++- src/Psalm/Type/Atomic/TList.php | 2 + src/Psalm/Type/Atomic/TNonEmptyList.php | 3 + 3 files changed, 225 insertions(+), 1 deletion(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 52f9aea82..15adb5413 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + $comment_block->tags['variablesfrom'][0] @@ -37,6 +37,11 @@ $uninitialized_variables[0] + + + new TList($param_type) + + $destination_parts[1] @@ -71,7 +76,16 @@ $traverser->traverse([$switch_condition])[0] + + + new TList($item_value_type ?? Type::getMixed()) + new TNonEmptyList($item_value_type ?? Type::getMixed()) + + + + new Atomic\TList(Type::getMixed()) + $assertion->rule[0] $assertion->rule[0] @@ -103,6 +117,12 @@ $gettype_expr->getArgs()[0] + + + new TList($current_type) + new TNonEmptyList($value_type) + + $invalid_left_messages[0] @@ -113,6 +133,14 @@ verifyType + + $array_type + $unpacked_atomic_array + TKeyedArray|TArray|TList|TClassStringMap + TKeyedArray|TArray|TList|TClassStringMap|null + new TList($input_type) + new TNonEmptyList($input_type) + $non_existent_method_ids[0] $parts[1] @@ -120,11 +148,34 @@ + + $array_type + $array_type + $arg_function_params[$argument_offset][0] + + $array_arg_type + $array_type + $array_type + $replacement_array_type + new TList($arg_value_atomic_type->type_params[1]) + new TList($array_atomic_type->type_param) + new TList($array_type->type_params[1]) + new TList($array_type->type_params[1]) + new TList($replacement_array_type->type_params[1]) + new TList(Type::getNever()) + new TList(Type::getNever()) + new TNonEmptyList($arg_value_atomic_type->type_params[1]) + new TNonEmptyList($arg_value_type) + new TNonEmptyList($array_type->getGenericValueType()) + new TNonEmptyList($array_type->type_params[1]) + new TNonEmptyList($array_type->type_params[1]) + new TNonEmptyList($replacement_array_type->type_params[1]) + $args[0] $args[0] @@ -138,6 +189,9 @@ $stmt->getArgs()[0] + + + $result->invalid_method_call_types[0] @@ -155,6 +209,14 @@ + + $array_type + $array_type + TArray|TKeyedArray|TList|TClassStringMap + TList + new TList($generic_params) + new TNonEmptyList($replacement_type) + $stmt_type $stmt_type @@ -171,6 +233,18 @@ $invalid_fetch_types[0] + + + new TList(Type::getNonEmptyString()) + new TNonEmptyList(Type::getString()) + new TNonEmptyList(Type::getString()) + + + + + new TNonEmptyList($item_value_type) + + $atomic_return_type->type_params[2] @@ -192,6 +266,9 @@ + + $array_atomic_type + $callables[0] $callables[0] @@ -286,6 +363,9 @@ + + $array_type + $flow_parts[0] @@ -300,6 +380,97 @@ $cs[0] + + + new TList(Type::getArray()) + new TNonEmptyList($array_type->value) + + + + + new TList($result_element_type ?? Type::getMixed()) + new TNonEmptyList($result_element_type ?? Type::getMixed()) + + + + + + + + + + + + + + new TList($inner_value_type) + new TNonEmptyList($inner_value_type) + + + + + new TList($value_type) + new TNonEmptyList($value_type) + + + + + + + + new TList($return_atomic_type->type_params[1]) + + + + + new TList(Type::getInt()) + new TList(Type::getMixed()) + new TList(Type::getString()) + + + + + new TList($inner_type) + new TList($inner_type) + new TList($inner_type) + new TNonEmptyList($inner_type) + new TNonEmptyList($inner_type) + new TNonEmptyList($inner_type) + + + + + $array_arg_type + + + + + new TList($value_type) + + + + + new TList(Type::getScalar()) + + + + + $array_atomic_type + $array_atomic_type + + + + + TArray|TKeyedArray|TList|TClassStringMap + TArray|TKeyedArray|TList|TClassStringMap + + + + + TList::class + TList::class + + $callable @@ -308,6 +479,17 @@ TCallable|TClosure|null + + + TList::class + new TList($type->type_params[1]) + new TList($type->type_params[1]) + new TNonEmptyList($array_atomic_type->type_param) + new TNonEmptyList($type->type_param) + new TNonEmptyList($type->type_param) + new TNonEmptyList($type->type_params[1]) + + getClassTemplateTypes @@ -315,6 +497,9 @@ + + new TList($generic_type_params[1]) + $combination->array_type_params[1] $combination->array_type_params[1] @@ -325,6 +510,10 @@ + + new TList($generic_params[0], $from_docblock) + new TNonEmptyList($generic_params[0], null, null, $from_docblock) + $intersection_types[0] $parse_tree->children[0] @@ -349,7 +538,17 @@ traverse + + + new TList(new Union([new TMixed])) + new TNonEmptyList(new Union([new TMixed])) + + + + new TList(Type::getMixed(false, $from_docblock)) + new TNonEmptyList(Type::getMixed(false, $from_docblock)) + classExtendsOrImplements classExtendsOrImplements @@ -394,6 +593,11 @@ getMostSpecificTypeFromBounds + + + TNonEmptyList + + replace @@ -416,6 +620,11 @@ + + TList + new TList($this->getGenericValueType()) + new TNonEmptyList($this->getGenericValueType()) + combine combine @@ -441,6 +650,11 @@ $cloned->type_param + + + TList + + replace @@ -506,6 +720,11 @@ allFloatLiterals + + + new Type\Atomic\TList($last_callable_arg->return_type ?? Type::getMixed()) + + UndefinedMethod diff --git a/src/Psalm/Type/Atomic/TList.php b/src/Psalm/Type/Atomic/TList.php index 8ead8881d..b0e64510a 100644 --- a/src/Psalm/Type/Atomic/TList.php +++ b/src/Psalm/Type/Atomic/TList.php @@ -19,6 +19,8 @@ use function get_class; * - they start at 0 * - they are consecutive and go upwards (no negative int) * + * @deprecated Will be removed and replaced with TKeyedArray in Psalm 5.1 + * * @psalm-immutable */ class TList extends Atomic diff --git a/src/Psalm/Type/Atomic/TNonEmptyList.php b/src/Psalm/Type/Atomic/TNonEmptyList.php index c56bd0b56..1acdb73f0 100644 --- a/src/Psalm/Type/Atomic/TNonEmptyList.php +++ b/src/Psalm/Type/Atomic/TNonEmptyList.php @@ -6,6 +6,9 @@ use Psalm\Type\Union; /** * Represents a non-empty list + * + * @deprecated Will be removed and replaced with TKeyedArray in Psalm 5.1 + * * @psalm-immutable */ class TNonEmptyList extends TList