Skip to content

Commit

Permalink
Fix unused ref in assign op
Browse files Browse the repository at this point in the history
Fixes #1968
  • Loading branch information
muglug committed Jul 24, 2019
1 parent ed61bca commit e22e0ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Expand Up @@ -847,6 +847,7 @@ public static function analyzeAssignmentRef(

if ($lhs_var_id) {
$context->vars_in_scope[$lhs_var_id] = Type::getMixed();
$context->hasVariable($lhs_var_id, $statements_analyzer);
}

if ($rhs_var_id) {
Expand Down
7 changes: 7 additions & 0 deletions tests/UnusedVariableTest.php
Expand Up @@ -1002,6 +1002,13 @@ function foo(?A $a) : void {
}
}',
],
'varPassedByRef' => [
'<?php
function foo(array $b) : void {
$a = &$b;
$a["foo"] = 5;
}',
],
];
}

Expand Down

0 comments on commit e22e0ac

Please sign in to comment.