From 78d64e36049da260f164919da17b8f8bbc2b7c9b Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 2 Dec 2022 21:07:17 +0100 Subject: [PATCH] Fix --- psalm-baseline.xml | 353 ++++++++++++------ psalm.xml.dist | 1 - .../ArrayMapReturnTypeProvider.php | 4 + 3 files changed, 239 insertions(+), 119 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 895f5bf4f..93705ab03 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + $comment_block->tags['variablesfrom'][0] @@ -13,8 +13,12 @@ - + + $const_name + $const_name $matches[0] + $property_name + $symbol_name $symbol_parts[1] @@ -31,17 +35,24 @@ - + $comments[0] + $property_name $stmt->props[0] $uninitialized_variables[0] + + + $property_name + + - + $destination_parts[1] $destination_parts[1] $destination_parts[1] + $php_minor_version $source_parts[1] @@ -50,9 +61,6 @@ if (AtomicTypeComparator::isContainedBy( if (AtomicTypeComparator::isContainedBy( - - $iterator_atomic_type->type_params[1] - @@ -72,9 +80,6 @@ - - new Atomic\TList(Type::getMixed()) - $assertion->rule[0] $assertion->rule[0] @@ -106,12 +111,10 @@ $gettype_expr->getArgs()[0] - - - $array_atomic_type - $array_atomic_type - $array_atomic_type - + + + $new_property_name + @@ -123,45 +126,32 @@ verifyType - - $array_type - $unpacked_atomic_array - TKeyedArray|TArray|TClassStringMap - TKeyedArray|TArray|TClassStringMap|null - - $non_existent_method_ids[0] + $method_name $parts[1] explode('::', $cased_method_id)[1] - - - $array_type - $array_type - - - $arg_function_params[$argument_offset][0] - - - - $array_arg_type - $array_type - $array_type - $replacement_array_type - - + $args[0] $args[0] $args[1] $callmap_callables[0] + $method_name - - $parts[1] + $stmt->getArgs()[0] + + + $parts[1] + + + + + $method @@ -174,21 +164,24 @@ $result->non_existent_magic_method_ids[0] + + + $new_method_name + + $callable_arg->items[0] $callable_arg->items[1] + + + $new_const_name + $new_const_name + + - - $array_type - $array_type - $type - $type - TArray|TKeyedArray|TClassStringMap - TList - $stmt_type $stmt_type @@ -205,11 +198,21 @@ $invalid_fetch_types[0] + + + $new_property_name + + $atomic_return_type->type_params[2] + + + $method_name + + $token_list[$iter] @@ -221,14 +224,38 @@ - + $stmt->expr->getArgs()[0] + + + $check_type_string + + + + + $identifier_name + + + + + $trait + + + + + $destination_name + $destination_name + $destination_name + $source_const_name + $stub + + + + + $stub - - $array_atomic_type - $callables[0] $callables[0] @@ -239,6 +266,16 @@ $function_callables[0] + + + $property_name + $property_name + $property_name + $property_name + $property_name + $property_name + + $a->props[0] @@ -249,6 +286,11 @@ $b_stmt_comments[0] + + + $b[$y] + + $stmt->props[0] @@ -314,8 +356,7 @@ - - $line_parts[1] + $since_parts[1] @@ -323,11 +364,11 @@ - - $array_type - + + $fixed_type_tokens[$i - 1] + - $flow_parts[0] + $source_param_string @@ -340,32 +381,26 @@ $cs[0] - - - $array_arg_type - + + + $callable_method_name + - - - $array_atomic_type - $array_atomic_type - + + + $class_strings ?: null + - - - $container_type_part - $container_type_part - $input_type_part - $input_type_part - TArray|TKeyedArray|TClassStringMap - TArray|TKeyedArray|TClassStringMap - + + + $method_name + - - TList::class - TList::class - + + $array->properties[0] + $array->properties[0] + @@ -376,9 +411,12 @@ - - TList::class - + + $array_atomic_type->properties[0] + $properties[0] + $properties[0] + $properties[0] + @@ -387,8 +425,8 @@ - - + + $combination->array_type_params[1] $combination->array_type_params[1] $combination->array_type_params[1] $combination->array_type_params[1] @@ -397,8 +435,15 @@ $combination->array_type_params[1] + + + $fallback_params + + - + + $const_name + $const_name $intersection_types[0] $parse_tree->children[0] $parse_tree->condition->children[0] @@ -409,6 +454,25 @@ array_keys($template_type_map[$template_param_name])[0] + + + $chars[$i - 1] + + + $type_tokens[$i - 1] + $type_tokens[$i - 1] + $type_tokens[$i - 1] + $type_tokens[$i - 1] + $type_tokens[$i - 1] + $type_tokens[$i - 1] + $type_tokens[$i - 2] + + + + + __construct + + CustomMetadataTrait @@ -423,11 +487,10 @@ - - new TCallableList($of, null, null, $from_docblock) - new TList($of, $from_docblock) - new TNonEmptyList($of, null, null, $from_docblock) - + + getListKey + getListKey + @@ -465,6 +528,10 @@ replace replace + + TTypeParams|null + TTypeParams|null + $this->type_params[1] @@ -474,11 +541,6 @@ getMostSpecificTypeFromBounds - - - TNonEmptyList - - replace @@ -501,7 +563,7 @@ - + combine combine combineUnionTypes @@ -510,26 +572,25 @@ combineUnionTypes combineUnionTypes combineUnionTypes + combineUnionTypes + getListKey + replace + replace replace replace $key_type->possibly_undefined - - - - replace - replace - - - $cloned->type_param - - - - - TList - + + $fallback_params + $fallback_params + + + $this->properties[0] + $this->properties[0] + $this->properties[0] + @@ -564,7 +625,8 @@ - + + $const_name $type[0] $type[0][0] @@ -596,11 +658,6 @@ allFloatLiterals - - - new Type\Atomic\TList($last_callable_arg->return_type ?? Type::getMixed()) - - UndefinedMethod @@ -611,4 +668,64 @@ $subNodes['expr'] + + + $parts + + + + + $conds + + + + + self::prepareName($name) + + + + + $stmts + + + + + $stmts + + + + + $stmts + + + + + $stmts + + + + + $stmts + + + + + $stmts + + + + + $stmts + + + + + $stmts + + + + + $stmts + + diff --git a/psalm.xml.dist b/psalm.xml.dist index f832bb221..90d2c8382 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -40,7 +40,6 @@ - diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php index 0c71fe0a7..a54a0c8ff 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php @@ -75,6 +75,10 @@ class ArrayMapReturnTypeProvider implements FunctionReturnTypeProviderInterface if ($function_call_type && $function_call_type->isNull()) { array_shift($call_args); + if (!$call_args) { + return Type::getNever(); + } + $array_arg_types = []; $orig_types = [];