Skip to content

Commit 90067ca

Browse files
committed
skip remove node, only allowed
1 parent 880bc8a commit 90067ca

File tree

5 files changed

+36
-13
lines changed

5 files changed

+36
-13
lines changed

phpstan.neon

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,3 +387,14 @@ parameters:
387387
-
388388
path: rules/TypeDeclaration/Rector/StmtsAwareInterface/IncreaseDeclareStrictTypesRector.php
389389
identifier: rector.noOnlyNullReturnInRefactor
390+
391+
-
392+
identifier: rector.noIntegerRefactorReturn
393+
paths:
394+
- rules/Transform/Rector/ArrayDimFetch/ArrayDimFetchToMethodCallRector.php
395+
396+
# valid, as use REMOVE_NODE
397+
- rules/DeadCode/Rector/Expression/RemoveDeadStmtRector.php
398+
- rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php
399+
- rules/DeadCode/Rector/ConstFetch/RemovePhpVersionIdCheckRector.php
400+
- rules/DeadCode/Rector/If_/UnwrapFutureCompatibleIfPhpVersionRector.php

rules/DeadCode/Rector/ConstFetch/RemovePhpVersionIdCheckRector.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function getNodeTypes(): array
8080

8181
/**
8282
* @param If_ $node
83-
* @return null|int|Stmt[]
83+
* @return null|NodeVisitor::REMOVE_NODE|Stmt[]
8484
*/
8585
public function refactor(Node $node): null|array|int
8686
{
@@ -112,7 +112,7 @@ public function refactor(Node $node): null|array|int
112112
}
113113

114114
/**
115-
* @return null|Stmt[]|int
115+
* @return null|Stmt[]|NodeVisitor::REMOVE_NODE
116116
*/
117117
private function refactorSmaller(ConstFetch $constFetch, Smaller $smaller, If_ $if): null|array|int
118118
{
@@ -128,7 +128,7 @@ private function refactorSmaller(ConstFetch $constFetch, Smaller $smaller, If_ $
128128
}
129129

130130
/**
131-
* @return null|int|Stmt[]
131+
* @return null|NodeVisitor::REMOVE_NODE|Stmt[]
132132
*/
133133
private function processGreaterOrEqual(
134134
ConstFetch $constFetch,
@@ -146,6 +146,9 @@ private function processGreaterOrEqual(
146146
return null;
147147
}
148148

149+
/**
150+
* @return null|NodeVisitor::REMOVE_NODE
151+
*/
149152
private function refactorSmallerLeft(Smaller $smaller): ?int
150153
{
151154
$value = $smaller->right;
@@ -161,7 +164,7 @@ private function refactorSmallerLeft(Smaller $smaller): ?int
161164
}
162165

163166
/**
164-
* @return null|Stmt[]|int
167+
* @return null|Stmt[]|NodeVisitor::REMOVE_NODE
165168
*/
166169
private function refactorSmallerRight(Smaller $smaller, If_ $if): null|array|int
167170
{
@@ -182,7 +185,7 @@ private function refactorSmallerRight(Smaller $smaller, If_ $if): null|array|int
182185
}
183186

184187
/**
185-
* @return null|Stmt[]|int
188+
* @return null|Stmt[]|NodeVisitor::REMOVE_NODE
186189
*/
187190
private function refactorGreaterOrEqualLeft(GreaterOrEqual $greaterOrEqual, If_ $if): null|array|int
188191
{
@@ -202,6 +205,9 @@ private function refactorGreaterOrEqualLeft(GreaterOrEqual $greaterOrEqual, If_
202205
return $if->stmts;
203206
}
204207

208+
/**
209+
* @return NodeVisitor::REMOVE_NODE|null
210+
*/
205211
private function refactorGreaterOrEqualRight(GreaterOrEqual $greaterOrEqual): ?int
206212
{
207213
$value = $greaterOrEqual->left;
@@ -217,7 +223,7 @@ private function refactorGreaterOrEqualRight(GreaterOrEqual $greaterOrEqual): ?i
217223
}
218224

219225
/**
220-
* @return null|Stmt[]|int
226+
* @return null|Stmt[]|NodeVisitor::REMOVE_NODE
221227
*/
222228
private function refactorGreater(ConstFetch $constFetch, Greater $greater, If_ $if): null|array|int
223229
{
@@ -233,7 +239,7 @@ private function refactorGreater(ConstFetch $constFetch, Greater $greater, If_ $
233239
}
234240

235241
/**
236-
* @return null|Stmt[]|int
242+
* @return null|Stmt[]|NodeVisitor::REMOVE_NODE
237243
*/
238244
private function refactorGreaterLeft(Greater $greater, If_ $if): null|array|int
239245
{
@@ -253,6 +259,9 @@ private function refactorGreaterLeft(Greater $greater, If_ $if): null|array|int
253259
return $if->stmts;
254260
}
255261

262+
/**
263+
* @return NodeVisitor::REMOVE_NODE|null
264+
*/
256265
private function refactorGreaterRight(Greater $greater): ?int
257266
{
258267
$value = $greater->left;
@@ -268,7 +277,7 @@ private function refactorGreaterRight(Greater $greater): ?int
268277
}
269278

270279
/**
271-
* @return null|Stmt[]|int
280+
* @return null|Stmt[]|NodeVisitor::REMOVE_NODE
272281
*/
273282
private function refactorConstFetch(ConstFetch $constFetch, If_ $if, BinaryOp $binaryOp): null|array|int
274283
{

rules/DeadCode/Rector/Expression/RemoveDeadStmtRector.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function getNodeTypes(): array
5959

6060
/**
6161
* @param Expression $node
62-
* @return Node[]|Node|null|int
62+
* @return Node[]|Node|null|NodeVisitor::REMOVE_NODE
6363
*/
6464
public function refactor(Node $node): array|Node|null|int
6565
{
@@ -106,6 +106,9 @@ private function hasGetMagic(Expression $expression): bool
106106
return ! $phpPropertyReflection instanceof PhpPropertyReflection;
107107
}
108108

109+
/**
110+
* @return NodeVisitor::REMOVE_NODE|Node
111+
*/
109112
private function removeNodeAndKeepComments(Expression $expression): int|Node
110113
{
111114
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($expression);

rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function getNodeTypes(): array
7474

7575
/**
7676
* @param If_ $node
77-
* @return Stmt[]|null|int|If_
77+
* @return Stmt[]|null|NodeVisitor::REMOVE_NODE|If_
7878
*/
7979
public function refactor(Node $node): array|null|int|If_
8080
{
@@ -98,7 +98,7 @@ public function refactor(Node $node): array|null|int|If_
9898
}
9999

100100
/**
101-
* @return null|Stmt[]|int
101+
* @return null|Stmt[]|NodeVisitor::REMOVE_NODE
102102
*/
103103
private function refactorStmtAndInstanceof(If_ $if, Instanceof_ $instanceof): null|array|int
104104
{

rules/DeadCode/Rector/If_/UnwrapFutureCompatibleIfPhpVersionRector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function getNodeTypes(): array
6161

6262
/**
6363
* @param If_ $node
64-
* @return Stmt[]|null|int
64+
* @return Stmt[]|null|NodeVisitor::REMOVE_NODE
6565
*/
6666
public function refactor(Node $node): array|int|null
6767
{
@@ -104,7 +104,7 @@ private function refactorIsMatch(If_ $if): ?array
104104
}
105105

106106
/**
107-
* @return Stmt[]|int
107+
* @return Stmt[]|NodeVisitor::REMOVE_NODE
108108
*/
109109
private function refactorIsNotMatch(If_ $if): array|int
110110
{

0 commit comments

Comments
 (0)