Skip to content

Commit f5640c1

Browse files
committed
Updated Rector to commit 5e5681d9edbb438b5782b45fde6e88650aa3843f
rectorphp/rector-src@5e5681d [NodeRemover] Use return null after ->removeNode() (#3558)
1 parent 123448a commit f5640c1

File tree

13 files changed

+23
-22
lines changed

13 files changed

+23
-22
lines changed

rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function refactor(Node $node) : ?Node
125125
return $this->cleanCastedExpr($node->expr);
126126
}
127127
$this->removeNode($node);
128-
return $node;
128+
return null;
129129
}
130130
private function cleanCastedExpr(Expr $expr) : Expr
131131
{

rules/DeadCode/Rector/ClassMethod/RemoveEmptyClassMethodRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function refactor(Node $node) : ?Node
8989
return null;
9090
}
9191
$this->removeNode($node);
92-
return $node;
92+
return null;
9393
}
9494
private function shouldSkipNonFinalNonPrivateClassMethod(Class_ $class, ClassMethod $classMethod) : bool
9595
{

rules/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function refactor(Node $node) : ?Node
8484
return null;
8585
}
8686
$this->removeNode($node);
87-
return $node;
87+
return null;
8888
}
8989
private function shouldSkip(ClassMethod $classMethod) : bool
9090
{

rules/DeadCode/Rector/For_/RemoveDeadLoopRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ public function refactor(Node $node) : ?Node
5454
return null;
5555
}
5656
$this->removeNode($node);
57-
return $node;
57+
return null;
5858
}
5959
}

rules/DeadCode/Rector/MethodCall/RemoveEmptyMethodCallRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function refactor(Node $node) : ?Node
122122
return null;
123123
}
124124
$this->removeNode($node);
125-
return $node;
125+
return null;
126126
}
127127
private function resolveClassLike(MethodCall $methodCall) : ?ClassLike
128128
{

rules/DeadCode/Rector/TryCatch/RemoveDeadTryCatchRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function refactor(Node $node)
6363
}
6464
if ($this->isEmpty($node->stmts)) {
6565
$this->removeNode($node);
66-
return $node;
66+
return null;
6767
}
6868
if (\count($node->catches) !== 1) {
6969
return null;

rules/Php70/Rector/Break_/BreakNotInLoopOrSwitchToReturnRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,6 @@ public function refactor(Node $node) : ?Node
8585
return new Return_();
8686
}
8787
$this->removeNode($node);
88-
return $node;
88+
return null;
8989
}
9090
}

rules/Php73/Rector/FuncCall/ArrayKeyFirstLastRector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public function refactor(Node $node) : ?Node
101101
$newName = self::PREVIOUS_TO_NEW_FUNCTIONS[$this->getName($node)];
102102
$keyFuncCall->name = new Name($newName);
103103
$this->removeNode($node);
104+
// change next node before remove, so it needs to return the Node
104105
return $node;
105106
}
106107
public function provideMinPhpVersion() : int

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = '3cbf7104d0b81ba1b930ce9a4cd3456e1c082b43';
22+
public const PACKAGE_VERSION = '5e5681d9edbb438b5782b45fde6e88650aa3843f';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2023-04-02 21:40:41';
27+
public const RELEASE_DATE = '2023-04-04 00:15:55';
2828
/**
2929
* @var int
3030
*/

src/Rector/AbstractRector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ abstract class AbstractRector extends NodeVisitorAbstract implements PhpRectorIn
5050
private const EMPTY_NODE_ARRAY_MESSAGE = <<<CODE_SAMPLE
5151
Array of nodes cannot be empty. Ensure "%s->refactor()" returns non-empty array for Nodes.
5252
53-
A) Return null for no change:
53+
A) Direct return null for no change:
5454
5555
return null;
5656
5757
B) Remove the Node:
5858
5959
\$this->removeNode(\$node);
60-
return \$node;
60+
return null;
6161
CODE_SAMPLE;
6262
/**
6363
* @var \Rector\NodeNameResolver\NodeNameResolver
@@ -218,7 +218,7 @@ public final function enterNode(Node $node)
218218
$this->changedNodeScopeRefresher->reIndexNodeAttributes($node);
219219
}
220220
$refactoredNode = $this->refactor($node);
221-
// nothing to change → continue
221+
// nothing to change or just removed via removeNode() → continue
222222
if ($refactoredNode === null) {
223223
return null;
224224
}

0 commit comments

Comments
 (0)