Skip to content

Commit 5f35406

Browse files
authored
[PHPStan] Use NodeVisitor::* on RectorInterface::refactor() @return method and update rules to use specific of its constant (#7409)
* [PHPStan] Use NodeVisitor::* on RectorInterface::refactor() @return method and update rules to use specific of its constant * [PHPStan] Use NodeVisitor::* on RectorInterface::refactor() @return method and update rules to use specific of its constant
1 parent 7506334 commit 5f35406

File tree

10 files changed

+11
-11
lines changed

10 files changed

+11
-11
lines changed

rules/CodeQuality/Rector/FuncCall/SetTypeToCastRector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public function getNodeTypes(): array
9595

9696
/**
9797
* @param FuncCall|Expression|Assign|ArrayItem|Node\Arg $node
98+
* @return null|NodeVisitor::DONT_TRAVERSE_CHILDREN|Expression|Assign|Cast
9899
*/
99100
public function refactor(Node $node): null|int|Expression|Assign|Cast
100101
{

rules/Php55/Rector/String_/StringClassNameToClassConstantRector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public function getNodeTypes(): array
9999

100100
/**
101101
* @param String_|FuncCall|ClassConst $node
102+
* @return Concat|ClassConstFetch|null|NodeVisitor::DONT_TRAVERSE_CHILDREN
102103
*/
103104
public function refactor(Node $node): Concat|ClassConstFetch|null|int
104105
{

rules/Php70/Rector/Break_/BreakNotInLoopOrSwitchToReturnRector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public function getNodeTypes(): array
8787

8888
/**
8989
* @param Switch_|Break_ $node
90+
* @return Return_|null|NodeVisitor::REMOVE_NODE
9091
*/
9192
public function refactor(Node $node): Return_|null|int
9293
{

rules/Php72/Rector/Unset_/UnsetCastRector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function getNodeTypes(): array
5555

5656
/**
5757
* @param Unset_|Assign|Expression $node
58+
* @return NodeVisitor::REMOVE_NODE|Node|null
5859
*/
5960
public function refactor(Node $node): int|null|Node
6061
{

rules/Php81/Rector/Array_/FirstClassCallableRector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public function getNodeTypes(): array
8888

8989
/**
9090
* @param Property|ClassConst|Array_ $node
91+
* @return StaticCall|MethodCall|null|NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN
9192
*/
9293
public function refactor(Node $node): int|null|StaticCall|MethodCall
9394
{

rules/Renaming/Rector/Name/RenameClassRector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public function getNodeTypes(): array
9595

9696
/**
9797
* @param ClassConstFetch|FunctionLike|FullyQualified|Name|ClassLike|Expression|Property|If_ $node
98+
* @return null|NodeVisitor::DONT_TRAVERSE_CHILDREN|Node
9899
*/
99100
public function refactor(Node $node): int|null|Node
100101
{
@@ -125,6 +126,7 @@ public function configure(array $configuration): void
125126

126127
/**
127128
* @param array<string, string> $oldToNewClasses
129+
* @return null|NodeVisitor::DONT_TRAVERSE_CHILDREN
128130
*/
129131
private function processClassConstFetch(ClassConstFetch $classConstFetch, array $oldToNewClasses): int|null
130132
{

rules/Transform/Rector/FuncCall/WrapFuncCallWithPhpVersionIdCheckerRector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function getNodeTypes(): array
6868

6969
/**
7070
* @param StmtsAwareInterface $node
71+
* @return null|Node|NodeVisitor::DONT_TRAVERSE_CHILDREN
7172
*/
7273
public function refactor(Node $node): null|Node|int
7374
{

src/Contract/Rector/RectorInterface.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,7 @@ public function getNodeTypes(): array;
2020

2121
/**
2222
* Process Node of matched type
23-
* @return Node|Node[]|null|int
24-
*
25-
* For int return, choose:
26-
*
27-
* ✔️ To decorate current node and its children to not be traversed on current rule, return one of:
28-
* - NodeVisitor::DONT_TRAVERSE_CHILDREN
29-
* - NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN
30-
*
31-
* ✔️ To remove node of Node\Stmt or Node\Param, return:
32-
* - NodeVisitor::REMOVE_NODE
23+
* @return Node|Node[]|null|NodeVisitor::*
3324
*/
3425
public function refactor(Node $node);
3526
}

src/Rector/AbstractRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ final public function enterNode(Node $node): int|Node|null
188188
}
189189

190190
if ($isIntRefactoredNode) {
191-
// @see NodeTraverser::* codes, e.g. removal of node of stopping the traversing
191+
// @see NodeVisitor::* codes, e.g. removal of node of stopping the traversing
192192
if ($refactoredNode === NodeVisitor::REMOVE_NODE) {
193193
// log here, so we can remove the node in leaveNode() method
194194
$this->toBeRemovedNodeId = spl_object_id($originalNode);

tests/Issues/InfiniteLoop/Rector/MethodCall/InfinityLoopRector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function getNodeTypes(): array
2626

2727
/**
2828
* @param Assign|MethodCall $node
29+
* @return Assign|int|null|NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN
2930
*/
3031
public function refactor(Node $node): Assign|null|int
3132
{

0 commit comments

Comments
 (0)