mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
This commit is contained in:
parent
e93b37a225
commit
f2bc6913db
@ -232,11 +232,11 @@ class ArrayAnalyzer
|
||||
PhpParser\Node\Expr\ArrayItem $item,
|
||||
Codebase $codebase
|
||||
) : void {
|
||||
if (ExpressionAnalyzer::analyze($statements_analyzer, $item->value, $context) === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($item->unpack) {
|
||||
if (ExpressionAnalyzer::analyze($statements_analyzer, $item->value, $context) === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$unpacked_array_type = $statements_analyzer->node_data->getType($item->value);
|
||||
|
||||
if (!$unpacked_array_type) {
|
||||
@ -335,6 +335,10 @@ class ArrayAnalyzer
|
||||
$array_creation_info->item_key_atomic_types[] = new Type\Atomic\TLiteralInt($item_key_value);
|
||||
}
|
||||
|
||||
if (ExpressionAnalyzer::analyze($statements_analyzer, $item->value, $context) === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$array_creation_info->all_list = $array_creation_info->all_list && $item_is_list_item;
|
||||
|
||||
if ($item_key_value !== null) {
|
||||
|
@ -2392,6 +2392,16 @@ class UnusedVariableTest extends TestCase
|
||||
return implode("/", $arr);
|
||||
}'
|
||||
],
|
||||
'initVariableInOffset' => [
|
||||
'<?php
|
||||
$a = [
|
||||
$b = "b" => $b,
|
||||
];
|
||||
|
||||
foreach ($a as $key => $value) {
|
||||
echo $key . " " . $value;
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user