1
0
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:
Matt Brown 2017-11-27 12:01:23 -05:00
parent 8b0d99e28b
commit a6f3781452
2 changed files with 19 additions and 0 deletions

View File

@ -1005,6 +1005,8 @@ class FetchChecker
$has_valid_offset = true;
} else {
$invalid_offset_types[] = 'string';
$array_access_type = Type::getMixed();
}
}
continue;

View File

@ -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' => [],
],
];
}