1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Fix #2705 - mark by-ref args as used if not variables already

This commit is contained in:
Matthew Brown 2020-01-29 21:46:30 -05:00
parent e92656c4cb
commit 2aebc522f1
2 changed files with 18 additions and 1 deletions

View File

@ -430,7 +430,9 @@ class CallAnalyzer
return false;
}
continue;
if ($arg->value instanceof PhpParser\Node\Expr\Variable) {
continue;
}
}
$toggled_class_exists = false;

View File

@ -1408,6 +1408,21 @@ class UnusedVariableTest extends TestCase
}
}'
],
'passedByRefArrayOffset' => [
'<?php
$a = [
"a" => [1],
"b" => [2]
];
foreach (["a"] as $e){
takes_ref($a[$e]);
}
function takes_ref(array &$p): void {
echo implode(",", $p);
}'
],
];
}