Skip to content

Commit

Permalink
[PSR4] Remove clone $node on PseudoNamespaceToNamespaceRector (#3554)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Apr 2, 2023
1 parent 141f1b0 commit f9aa52a
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,24 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$processNode = clone $node;
$this->newNamespace = null;

if ($processNode instanceof FileWithoutNamespace) {
$changedStmts = $this->refactorStmts($processNode->stmts);
if ($node instanceof FileWithoutNamespace) {
$changedStmts = $this->refactorStmts($node->stmts);
if ($changedStmts === null) {
return null;
}

$processNode->stmts = $changedStmts;
$node->stmts = $changedStmts;

// add a new namespace?
if ($this->newNamespace !== null) {
return new Namespace_(new Name($this->newNamespace), $changedStmts);
}
}

if ($processNode instanceof Namespace_) {
return $this->refactorNamespace($processNode);
if ($node instanceof Namespace_) {
return $this->refactorNamespace($node);
}

return null;
Expand Down

0 comments on commit f9aa52a

Please sign in to comment.