Skip to content

Commit 1ca7c16

Browse files
committed
skip direct on while and do cond
1 parent 0c65912 commit 1ca7c16

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

rules/DowngradePhp80/Rector/FuncCall/DowngradeSubstrFalsyRector.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
use PhpParser\Node\Expr\MethodCall;
2020
use PhpParser\Node\Expr\StaticCall;
2121
use PhpParser\Node\Expr\Ternary;
22+
use PhpParser\Node\Stmt\Do_;
2223
use PhpParser\Node\Stmt\If_;
24+
use PhpParser\Node\Stmt\While_;
2325
use PHPStan\Reflection\FunctionReflection;
2426
use PHPStan\Reflection\MethodReflection;
2527
use PHPStan\Type\Constant\ConstantIntegerType;
@@ -73,12 +75,14 @@ public function getNodeTypes(): array
7375
StaticCall::class,
7476
AssignOp::class,
7577
If_::class,
78+
While_::class,
79+
Do_::class,
7680
FuncCall::class,
7781
];
7882
}
7983

8084
/**
81-
* @param Cast|Empty_|BooleanNot|Ternary|Identical|Concat|MethodCall|StaticCall|AssignOp|If_|FuncCall $node
85+
* @param Cast|Empty_|BooleanNot|Ternary|Identical|Concat|MethodCall|StaticCall|AssignOp|If_|While_|Do_|FuncCall $node
8286
*/
8387
public function refactor(Node $node): ?Node
8488
{
@@ -113,7 +117,7 @@ public function refactor(Node $node): ?Node
113117
return null;
114118
}
115119

116-
if ($node instanceof If_) {
120+
if ($node instanceof If_ || $node instanceof While_ || $node instanceof Do_) {
117121
$node->cond->setAttribute(self::IS_UNCASTABLE, true);
118122
return null;
119123
}

0 commit comments

Comments
 (0)