mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix array key check after direct assignment
This commit is contained in:
parent
d3fa972fab
commit
47255fb19b
@ -240,6 +240,7 @@ class ArrayAssignmentChecker
|
||||
}
|
||||
|
||||
$new_child_type->removeType('null');
|
||||
$new_child_type->possibly_undefined = false;
|
||||
|
||||
if (!$child_stmt->inferredType->hasObjectType()) {
|
||||
$child_stmt->inferredType = $new_child_type;
|
||||
|
@ -983,6 +983,21 @@ class LoopScopeTest extends TestCase
|
||||
$value = 6;
|
||||
} while ($count);',
|
||||
],
|
||||
'arrayKeyJustSetInLoop' => [
|
||||
'<?php
|
||||
$a = null;
|
||||
$arr = [];
|
||||
|
||||
foreach ([1, 2, 3] as $_) {
|
||||
if (rand(0, 1)) {
|
||||
$arr["a"]["c"] = "foo";
|
||||
$a = $arr["a"]["c"];
|
||||
} else {
|
||||
$arr["b"]["c"] = "bar";
|
||||
$a = $arr["b"]["c"];
|
||||
}
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user