Skip to content

Commit

Permalink
[DeadCode] Mirror comment on assign method call on RemoveUnusedVariab…
Browse files Browse the repository at this point in the history
…leAssignRector (#5195)

* [DeadCode] Mirror comment on assign method call on RemoveUnusedVariableAssignRector

* Fix

* Fix
  • Loading branch information
samsonasik committed Oct 24, 2023
1 parent 3e505e5 commit f2c8967
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
@@ -0,0 +1,29 @@
<?php

namespace Rector\Tests\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector\Fixture;

final class MirrorCommentAssignMethodCall
{
public function run($db)
{
// execute query
$value = $db->query();
}
}

?>
-----
<?php

namespace Rector\Tests\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector\Fixture;

final class MirrorCommentAssignMethodCall
{
public function run($db)
{
// execute query
$db->query();
}
}

?>
Expand Up @@ -109,7 +109,9 @@ public function refactorWithScope(Node $node, Scope $scope): ?ClassMethod
if ($this->hasCallLikeInAssignExpr($assign, $scope)) {
// clean safely
$cleanAssignedExpr = $this->cleanCastedExpr($assign->expr);
$node->stmts[$stmtPosition] = new Expression($cleanAssignedExpr);
$newExpression = new Expression($cleanAssignedExpr);
$this->mirrorComments($newExpression, $currentStmt);
$node->stmts[$stmtPosition] = $newExpression;
} else {
unset($node->stmts[$stmtPosition]);
}
Expand Down

0 comments on commit f2c8967

Please sign in to comment.