Skip to content

Commit e792155

Browse files
calebdwsamsonasik
andauthored
fix: skip variable assignments in get_defined_vars (#7106)
* fix: skip variable assignments in get_defined_vars * Update rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php --------- Co-authored-by: Abdul Malik Ikhsan <[email protected]>
1 parent e283a30 commit e792155

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Rector\Tests\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector\Fixture;
4+
5+
class SkipInCompact
6+
{
7+
public function run()
8+
{
9+
$value = 'foobar';
10+
return get_defined_vars();
11+
}
12+
}
13+
14+
?>

rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private function shouldSkip(array $stmts): bool
154154
return false;
155155
}
156156

157-
return $this->isName($node, 'compact');
157+
return $this->isNames($node, ['compact', 'get_defined_vars']);
158158
});
159159
}
160160

0 commit comments

Comments
 (0)