Skip to content

Commit ae51b6d

Browse files
committed
Fix method name as it verify not break flow
1 parent 413c45d commit ae51b6d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

rules/EarlyReturn/Rector/If_/RemoveAlwaysElseRector.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function getNodeTypes(): array
7474
*/
7575
public function refactor(Node $node): ?array
7676
{
77-
if ($this->doesLastStatementBreakFlow($node)) {
77+
if ($this->doesNotLastStatementBreakFlow($node)) {
7878
return null;
7979
}
8080

@@ -108,7 +108,7 @@ private function handleElseIfs(If_ $if): array
108108
$currentElseIf = array_shift($if->elseifs);
109109

110110
// If the last statement in the `elseif` breaks flow, merge it into the original `if` and stop processing
111-
if ($this->doesLastStatementBreakFlow($currentElseIf)) {
111+
if ($this->doesNotLastStatementBreakFlow($currentElseIf)) {
112112
$this->updateIfWithElseIf($if, $currentElseIf);
113113
$nodesToReturn = [...$nodesToReturn, $if, ...$this->getStatementsElseIfs($if)];
114114

@@ -132,7 +132,7 @@ private function handleElseIfs(If_ $if): array
132132
if ($originalIf->else instanceof Else_) {
133133
$mergeStmts = true;
134134
foreach ($nodesToReturn as $nodeToReturn) {
135-
if ($this->doesLastStatementBreakFlow($nodeToReturn)) {
135+
if ($this->doesNotLastStatementBreakFlow($nodeToReturn)) {
136136
$nodesToReturn[] = $originalIf->else;
137137
$mergeStmts = false;
138138
break;
@@ -154,7 +154,7 @@ private function getStatementsElseIfs(If_ $if): array
154154
{
155155
$statements = [];
156156
foreach ($if->elseifs as $key => $elseif) {
157-
if ($this->doesLastStatementBreakFlow($elseif) && $elseif->stmts !== []) {
157+
if ($this->doesNotLastStatementBreakFlow($elseif) && $elseif->stmts !== []) {
158158
continue;
159159
}
160160

@@ -165,17 +165,17 @@ private function getStatementsElseIfs(If_ $if): array
165165
return $statements;
166166
}
167167

168-
private function doesLastStatementBreakFlow(If_ | ElseIf_ | Else_ $node): bool
168+
private function doesNotLastStatementBreakFlow(If_ | ElseIf_ | Else_ $node): bool
169169
{
170170
$lastStmt = end($node->stmts);
171171

172172
if ($lastStmt instanceof If_ && $lastStmt->else instanceof Else_) {
173-
if ($this->doesLastStatementBreakFlow($lastStmt) || $this->doesLastStatementBreakFlow($lastStmt->else)) {
173+
if ($this->doesNotLastStatementBreakFlow($lastStmt) || $this->doesNotLastStatementBreakFlow($lastStmt->else)) {
174174
return true;
175175
}
176176

177177
foreach ($lastStmt->elseifs as $elseIf) {
178-
if ($this->doesLastStatementBreakFlow($elseIf)) {
178+
if ($this->doesNotLastStatementBreakFlow($elseIf)) {
179179
return true;
180180
}
181181
}

0 commit comments

Comments
 (0)