1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix #1366 - don’t complain about invalid array offset when possibly mixed

This commit is contained in:
Brown 2019-02-19 11:42:24 -05:00
parent cd2eb3edb9
commit 348b8eef1f
2 changed files with 19 additions and 1 deletions

View File

@ -807,7 +807,7 @@ class ArrayFetchAnalyzer
} else {
$non_array_types[] = (string)$type;
}
} else {
} elseif (!$array_type->hasMixed()) {
$non_array_types[] = (string)$type;
}
}

View File

@ -335,6 +335,24 @@ class ArrayAccessTest extends TestCase
echo $a[3];
echo $a[4];',
],
'arrayAccessAfterPossibleGeneralisation' => [
'<?php
function getArray() : array { return []; }
$params = array(
"a" => 1,
"b" => [
"c" => "a",
]
);
if (rand(0, 1)) {
$params = getArray();
}
echo $params["b"]["c"];',
[],
['MixedArrayAccess', 'MixedArgument']
],
];
}