diff --git a/psalm-baseline.xml b/psalm-baseline.xml index c8dee018001..227420cf7b7 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + $comment_block->tags['variablesfrom'][0] @@ -182,6 +182,9 @@ + + $properties[0] + $stmt_type $stmt_type @@ -231,6 +234,11 @@ $check_type_string + + + $options['tcp'] ?? null + + $identifier_name @@ -390,9 +398,6 @@ $class_strings ?: null - - $is_replace - @@ -461,17 +466,11 @@ - - $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] diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php index 172b8fb5563..4f11f44c7ab 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php @@ -649,12 +649,14 @@ private static function updateArrayAssignmentChildType( ]); } else { assert($array_atomic_type_list !== null); + $array_atomic_type = array_fill( + $atomic_root_type_array->getMinCount(), + count($atomic_root_type_array->properties)-1, + $array_atomic_type_list, + ); + assert(count($array_atomic_type) > 0); $array_atomic_type = new TKeyedArray( - array_fill( - $atomic_root_type_array->getMinCount(), - count($atomic_root_type_array->properties)-1, - $array_atomic_type_list, - ), + $array_atomic_type, null, null, true, diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php index 42e5ab1d710..d0d52d581a4 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php @@ -1545,7 +1545,7 @@ private static function handleArrayAccessOnKeyedArray( ); } $properties[0] = $properties[0]->setPossiblyUndefined( - $replacement_type->possibly_undefined + $replacement_type->possibly_undefined, ); $properties[$key_value->value] = $properties[$key_value->value]-> setPossiblyUndefined(true) diff --git a/src/Psalm/Internal/Type/TypeCombiner.php b/src/Psalm/Internal/Type/TypeCombiner.php index 5056c18dcdf..0132e4e6bf4 100644 --- a/src/Psalm/Internal/Type/TypeCombiner.php +++ b/src/Psalm/Internal/Type/TypeCombiner.php @@ -676,9 +676,7 @@ private static function scrapeTypeProperties( if (!$candidate_property_type->possibly_undefined) { $has_defined_keys = true; - } - - if ($combination->fallbackKeyContains($candidate_property_name)) { + } elseif ($combination->fallbackKeyContains($candidate_property_name)) { $combination->objectlike_entries[$candidate_property_name] = Type::combineUnionTypes( $combination->objectlike_entries[$candidate_property_name], $combination->objectlike_value_type, diff --git a/src/Psalm/Type/Atomic/TKeyedArray.php b/src/Psalm/Type/Atomic/TKeyedArray.php index f673af9d0c9..b78fa8654da 100644 --- a/src/Psalm/Type/Atomic/TKeyedArray.php +++ b/src/Psalm/Type/Atomic/TKeyedArray.php @@ -95,7 +95,9 @@ public function __construct( $this->is_list = false; break; } - $had_possibly_undefined = $v->possibly_undefined || $had_possibly_undefined; + if ($v->possibly_undefined) { + $had_possibly_undefined = true; + } $last_k = $k; } } @@ -121,7 +123,9 @@ public function setProperties(array $properties): self $cloned->is_list = false; break; } - $had_possibly_undefined = $v->possibly_undefined || $had_possibly_undefined; + if ($v->possibly_undefined) { + $had_possibly_undefined = true; + } $last_k = $k; } } diff --git a/src/Psalm/Type/Reconciler.php b/src/Psalm/Type/Reconciler.php index 006850317e5..9bf4d261d63 100644 --- a/src/Psalm/Type/Reconciler.php +++ b/src/Psalm/Type/Reconciler.php @@ -1093,10 +1093,6 @@ private static function adjustTKeyedArrayType( array &$changed_var_ids, Union $result_type ): void { - if ($result_type->isNever()) { - return; - } - array_pop($key_parts); $array_key = array_pop($key_parts); array_pop($key_parts); diff --git a/tests/ArrayFunctionCallTest.php b/tests/ArrayFunctionCallTest.php index bbd6421afe6..ae228a438bb 100644 --- a/tests/ArrayFunctionCallTest.php +++ b/tests/ArrayFunctionCallTest.php @@ -219,8 +219,8 @@ function getInts(): array { return [123]; } $result = array_merge($a1, $a2); ', 'assertions' => [ - '$result===' => "array{a: 'a2'}" - ] + '$result===' => "array{a: 'a2'}", + ], ], 'arrayMergeListOfShapes' => [ 'code' => '