1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-11 16:59:45 +01:00
This commit is contained in:
Daniil Gentili 2022-12-02 21:03:39 +01:00
parent abe722d577
commit 23b0ac012a
2 changed files with 6 additions and 4 deletions

View File

@ -516,7 +516,9 @@ class ArrayAssignmentAnalyzer
&& $parent_var_id && $parent_var_id
&& ($parent_type = $context->vars_in_scope[$parent_var_id] ?? null) && ($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
&& $key_type->isTemplatedClassString() && $key_type->isTemplatedClassString()
) { ) {

View File

@ -551,16 +551,16 @@ class ArrayFunctionCallTest extends TestCase
'$b' => 'int', '$b' => 'int',
], ],
], ],
'arrayNotEmptyArrayAfterCountLessThanEqualToOne' => [ 'arrayNotEmptyArrayAfterCountBiggerThanEqualToOne' => [
'code' => '<?php 'code' => '<?php
/** @var list<int> */ /** @var list<int> */
$leftCount = [1, 2, 3]; $leftCount = [1, 2, 3];
if (count($leftCount) <= 1) { if (count($leftCount) >= 1) {
echo $leftCount[0]; echo $leftCount[0];
} }
/** @var list<int> */ /** @var list<int> */
$rightCount = [1, 2, 3]; $rightCount = [1, 2, 3];
if (1 >= count($rightCount)) { if (1 <= count($rightCount)) {
echo $rightCount[0]; echo $rightCount[0];
}', }',
], ],