diff --git a/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_case.php.inc b/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_case.php.inc new file mode 100644 index 00000000000..efa39ebf2cd --- /dev/null +++ b/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_case.php.inc @@ -0,0 +1,34 @@ + +----- + diff --git a/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_catch.php.inc b/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_catch.php.inc new file mode 100644 index 00000000000..0fe5d33a816 --- /dev/null +++ b/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_catch.php.inc @@ -0,0 +1,42 @@ +getMesssage()); + echo 'test'; + } + } +} + +?> +----- +getMesssage()); + } + } +} + +?> diff --git a/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_do.php.inc b/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_do.php.inc new file mode 100644 index 00000000000..8ba086e4c63 --- /dev/null +++ b/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_do.php.inc @@ -0,0 +1,38 @@ + +----- + diff --git a/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_else_if.php.inc b/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_else_if.php.inc new file mode 100644 index 00000000000..ebc6ab154bf --- /dev/null +++ b/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_else_if.php.inc @@ -0,0 +1,40 @@ + +----- + diff --git a/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_finally.php.inc b/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_finally.php.inc new file mode 100644 index 00000000000..e8410fcdd34 --- /dev/null +++ b/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_finally.php.inc @@ -0,0 +1,42 @@ + +----- + diff --git a/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_for.php.inc b/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_for.php.inc new file mode 100644 index 00000000000..b33462c4b5a --- /dev/null +++ b/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_for.php.inc @@ -0,0 +1,36 @@ + +----- + diff --git a/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_try.php.inc b/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_try.php.inc new file mode 100644 index 00000000000..866d55b6705 --- /dev/null +++ b/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_try.php.inc @@ -0,0 +1,40 @@ + +----- + diff --git a/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_while.php.inc b/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_while.php.inc new file mode 100644 index 00000000000..085b2b213f8 --- /dev/null +++ b/rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture/some_while.php.inc @@ -0,0 +1,36 @@ + +----- + diff --git a/rules/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector.php b/rules/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector.php index eab372855fe..bc7ffab06af 100644 --- a/rules/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector.php +++ b/rules/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector.php @@ -5,18 +5,26 @@ namespace Rector\DeadCode\Rector\Stmt; use PhpParser\Node; +use PhpParser\Node\Expr\Closure; use PhpParser\Node\Expr\Exit_; -use PhpParser\Node\FunctionLike; use PhpParser\Node\Stmt; +use PhpParser\Node\Stmt\Case_; +use PhpParser\Node\Stmt\Catch_; +use PhpParser\Node\Stmt\ClassMethod; +use PhpParser\Node\Stmt\Do_; use PhpParser\Node\Stmt\Else_; +use PhpParser\Node\Stmt\ElseIf_; use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Finally_; +use PhpParser\Node\Stmt\For_; use PhpParser\Node\Stmt\Foreach_; +use PhpParser\Node\Stmt\Function_; use PhpParser\Node\Stmt\If_; use PhpParser\Node\Stmt\Nop; use PhpParser\Node\Stmt\Return_; use PhpParser\Node\Stmt\Throw_; use PhpParser\Node\Stmt\TryCatch; +use PhpParser\Node\Stmt\While_; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; @@ -63,11 +71,26 @@ public function run() */ public function getNodeTypes(): array { - return [Foreach_::class, FunctionLike::class, Else_::class, If_::class]; + return [ + For_::class, + Foreach_::class, + Do_::class, + While_::class, + ClassMethod::class, + Function_::class, + Closure::class, + If_::class, + ElseIf_::class, + Else_::class, + Case_::class, + TryCatch::class, + Catch_::class, + Finally_::class, + ]; } /** - * @param Foreach_|FunctionLike|Else_|If_ $node + * @param For_|Foreach_|Do_|While_|ClassMethod|Function_|Closure|If_|ElseIf_|Else_|Case_|TryCatch|Catch_|Finally_ $node */ public function refactor(Node $node): ?Node {