From 23b0ac012ae6e8965b354d157c5f4d5ec6807dd0 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 2 Dec 2022 21:03:39 +0100 Subject: [PATCH] Hack --- .../Expression/Assignment/ArrayAssignmentAnalyzer.php | 4 +++- tests/ArrayFunctionCallTest.php | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php index 9e1506825..68b003f16 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php @@ -516,7 +516,9 @@ class ArrayAssignmentAnalyzer && $parent_var_id && ($parent_type = $context->vars_in_scope[$parent_var_id] ?? null) ) { - if ($parent_type->hasClassStringMap() + if ($parent_type->hasList() && strpos($parent_var_id, '[') === false) { + $array_atomic_type_list = $value_type; + } elseif ($parent_type->hasClassStringMap() && $key_type && $key_type->isTemplatedClassString() ) { diff --git a/tests/ArrayFunctionCallTest.php b/tests/ArrayFunctionCallTest.php index 227f8596c..19dbadaa8 100644 --- a/tests/ArrayFunctionCallTest.php +++ b/tests/ArrayFunctionCallTest.php @@ -551,16 +551,16 @@ class ArrayFunctionCallTest extends TestCase '$b' => 'int', ], ], - 'arrayNotEmptyArrayAfterCountLessThanEqualToOne' => [ + 'arrayNotEmptyArrayAfterCountBiggerThanEqualToOne' => [ 'code' => ' */ $leftCount = [1, 2, 3]; - if (count($leftCount) <= 1) { + if (count($leftCount) >= 1) { echo $leftCount[0]; } /** @var list */ $rightCount = [1, 2, 3]; - if (1 >= count($rightCount)) { + if (1 <= count($rightCount)) { echo $rightCount[0]; }', ],