mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix #340 - give up with mixed type when accessing unknown key on objectlike
This commit is contained in:
parent
8b0d99e28b
commit
a6f3781452
@ -1005,6 +1005,8 @@ class FetchChecker
|
||||
$has_valid_offset = true;
|
||||
} else {
|
||||
$invalid_offset_types[] = 'string';
|
||||
|
||||
$array_access_type = Type::getMixed();
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
@ -703,6 +703,23 @@ class ArrayAssignmentTest extends TestCase
|
||||
'$str' => 'string',
|
||||
],
|
||||
],
|
||||
'ignoreInvalidArrayOffset' => [
|
||||
'<?php
|
||||
$a = [
|
||||
"b" => [],
|
||||
];
|
||||
|
||||
$a["b"]["c"] = 0;
|
||||
|
||||
foreach ([1, 2, 3] as $i) {
|
||||
/**
|
||||
* @psalm-suppress InvalidArrayOffset
|
||||
* @psalm-suppress MixedOperand
|
||||
*/
|
||||
$a["b"]["d"] += $a["b"][$i];
|
||||
}',
|
||||
'assertions' => [],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user