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:
parent
cd2eb3edb9
commit
348b8eef1f
@ -807,7 +807,7 @@ class ArrayFetchAnalyzer
|
||||
} else {
|
||||
$non_array_types[] = (string)$type;
|
||||
}
|
||||
} else {
|
||||
} elseif (!$array_type->hasMixed()) {
|
||||
$non_array_types[] = (string)$type;
|
||||
}
|
||||
}
|
||||
|
@ -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']
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user