Skip to content

Commit

Permalink
wrap Expression
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Aug 24, 2023
1 parent 0012df8 commit f54fa71
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Rector/AbstractRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
namespace Rector\Core\Rector;

use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\InlineHTML;
use PhpParser\Node\Stmt\Nop;
use PhpParser\NodeTraverser;
Expand Down Expand Up @@ -320,6 +323,10 @@ private function postRefactorProcess(
return $originalNode;
}

if ($refactoredNode instanceof Expr && $originalNode instanceof Stmt) {
$refactoredNode = new Expression($refactoredNode);
}

$this->refreshScopeNodes($refactoredNode, $filePath, $currentScope);

$this->nodesToReturn[$originalNodeHash] = $refactoredNode;
Expand Down

0 comments on commit f54fa71

Please sign in to comment.