mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
parent
d44be5eb9c
commit
c38108f95d
@ -119,6 +119,25 @@ class ArrayAnalyzer
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($item->byRef) {
|
||||
$var_id = ExpressionAnalyzer::getArrayVarId(
|
||||
$item->value,
|
||||
$statements_analyzer->getFQCLN(),
|
||||
$statements_analyzer
|
||||
);
|
||||
|
||||
if ($var_id) {
|
||||
$context->removeDescendents(
|
||||
$var_id,
|
||||
$context->vars_in_scope[$var_id],
|
||||
null,
|
||||
$statements_analyzer
|
||||
);
|
||||
|
||||
$context->vars_in_scope[$var_id] = Type::getMixed();
|
||||
}
|
||||
}
|
||||
|
||||
if ($item_value_atomic_types && !$can_create_objectlike) {
|
||||
continue;
|
||||
}
|
||||
|
@ -502,6 +502,24 @@ class ArrayAccessTest extends TestCase
|
||||
[],
|
||||
['MixedReturnStatement', 'MixedInferredReturnType']
|
||||
],
|
||||
'arrayAccessAfterByRefArrayOffsetAssignment' => [
|
||||
'<?php
|
||||
/**
|
||||
* @param array{param1: array} $params
|
||||
*/
|
||||
function dispatch(array $params) : void {
|
||||
$params["param1"]["foo"] = "bar";
|
||||
}
|
||||
|
||||
$ar = [];
|
||||
dispatch(["param1" => &$ar]);
|
||||
$value = "foo";
|
||||
if (isset($ar[$value])) {
|
||||
echo (string) $ar[$value];
|
||||
}',
|
||||
[],
|
||||
['MixedArrayAccess'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user