Skip to content

Commit

Permalink
[CodingStyle] Remove parent attribute on NewlineAfterStatementRector (#…
Browse files Browse the repository at this point in the history
…3967)

Since we use StmtsAwareInterface, different parent with next stmt should not happened.
  • Loading branch information
samsonasik committed May 25, 2023
1 parent d279f71 commit d99713c
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private function processAddNewLine(
continue;
}

if ($this->isRemoved($nextStmt, $stmt)) {
if ($this->isRemoved($stmt)) {
continue;
}

Expand Down Expand Up @@ -204,16 +204,9 @@ private function hasNoComment(?array $comments): bool
return ! isset($comments[0]);
}

private function isRemoved(Stmt $nextStmt, Stmt $stmt): bool
private function isRemoved(Stmt $stmt): bool
{
if ($this->nodesToRemoveCollector->isNodeRemoved($stmt)) {
return true;
}

$parentCurrentNode = $stmt->getAttribute(AttributeKey::PARENT_NODE);
$parentnextStmt = $nextStmt->getAttribute(AttributeKey::PARENT_NODE);

return $parentnextStmt !== $parentCurrentNode;
return $this->nodesToRemoveCollector->isNodeRemoved($stmt);
}

private function shouldSkip(Stmt $stmt): bool
Expand Down

0 comments on commit d99713c

Please sign in to comment.