mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-07 03:40:50 +00:00
[DeadCode] Ensure parent assign is Expression Stmt for RemoveUnusedVariableAssignRector (#1893)
This commit is contained in:
parent
18f306ec61
commit
1b717dc74e
|
@ -227,7 +227,7 @@ CODE_SAMPLE
|
|||
private function refactorUsedVariable(Assign $assign): null|Expr
|
||||
{
|
||||
$parentNode = $assign->getAttribute(AttributeKey::PARENT_NODE);
|
||||
if (! $parentNode instanceof Node) {
|
||||
if (! $parentNode instanceof Expression) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -238,10 +238,7 @@ CODE_SAMPLE
|
|||
if (
|
||||
$assign->var instanceof Variable &&
|
||||
! $this->isUsedInPreviousNode($assign->var) &&
|
||||
! $this->exprUsedInNextNodeAnalyzer->isUsed($assign->var) && $this->isUsedInAssignExpr(
|
||||
$assign->expr,
|
||||
$assign
|
||||
)) {
|
||||
! $this->exprUsedInNextNodeAnalyzer->isUsed($assign->var)) {
|
||||
return $this->cleanCastedExpr($assign->expr);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user