Skip to content
Permalink
Browse files

Fix false positive UnusedVariable

  • Loading branch information
muglug committed Nov 13, 2019
1 parent 7516b7b commit c9e7dcfa92734e4085337cbbd098db305fa28d15
@@ -308,6 +308,16 @@ function (\Psalm\Internal\Clause $c) use ($mixed_var_ids) {
$t_else_context->unreferenced_vars
);
foreach ($context->unreferenced_vars as $var_id => $locations) {
if (isset($t_else_context->unreferenced_vars[$var_id])) {
$context->unreferenced_vars[$var_id] += $t_else_context->unreferenced_vars[$var_id];
}
if (isset($t_if_context->unreferenced_vars[$var_id])) {
$context->unreferenced_vars[$var_id] += $t_if_context->unreferenced_vars[$var_id];
}
}
$lhs_type = null;
if ($stmt->if) {
@@ -1270,7 +1270,28 @@ function foo(array $arr): array {
$arr["a"]["b"][$c] = 1;
return $arr;
}',
]
],
'binaryOpIncrementInElse' => [
'<?php
function foo(int $i, string $alias) : void {
echo $alias ?: $i++;
echo $i;
}'
],
'binaryOpIncrementInCond' => [
'<?php
function foo(int $i, string $alias) : void {
echo $i++ ?: $alias;
echo $i;
}'
],
'binaryOpIncrementInIf' => [
'<?php
function foo(int $i, string $alias) : void {
echo rand(0, 1) ? $i++ : $alias;
echo $i;
}'
],
];
}

0 comments on commit c9e7dcf

Please sign in to comment.
You can’t perform that action at this time.