File tree Expand file tree Collapse file tree 4 files changed +29
-3
lines changed
rules-tests/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector/Fixture Expand file tree Collapse file tree 4 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ parameters:
1010
1111 # see https://phpstan.org/writing-php-code/phpdoc-types#global-type-aliases
1212 typeAliases :
13- StmtsAware : \PhpParser\Node\Stmt\Block | \PhpParser\Node\Expr\Closure | \PhpParser\Node\Stmt\Case_ | \PhpParser\Node\Stmt\Catch_ | \PhpParser\Node\Stmt\ClassMethod | \PhpParser\Node\Stmt\Do_ | \PhpParser\Node\Stmt\Else_ | \PhpParser\Node\Stmt\ElseIf_ | \PhpParser\Node\Stmt\Finally_ | \PhpParser\Node\Stmt\For_ | \PhpParser\Node\Stmt\Foreach_ | \PhpParser\Node\Stmt\Function_ | \PhpParser\Node\Stmt\If_ | \PhpParser\Node\Stmt\Namespace_ | \PhpParser\Node\Stmt\TryCatch | \PhpParser\Node\Stmt\While_ | \Rector\PhpParser\Node\FileNode
13+ StmtsAware : \PhpParser\Node\Stmt\Block | \PhpParser\Node\Expr\Closure | \PhpParser\Node\Stmt\Case_ | \PhpParser\Node\Stmt\Catch_ | \PhpParser\Node\Stmt\ClassMethod | \PhpParser\Node\Stmt\Do_ | \PhpParser\Node\Stmt\Else_ | \PhpParser\Node\Stmt\ElseIf_ | \PhpParser\Node\Stmt\Finally_ | \PhpParser\Node\Stmt\For_ | \PhpParser\Node\Stmt\Foreach_ | \PhpParser\Node\Stmt\Function_ | \PhpParser\Node\Stmt\If_ | \PhpParser\Node\Stmt\Namespace_ | \PhpParser\Node\Stmt\TryCatch | \PhpParser\Node\Stmt\While_ | \Rector\PhpParser\Node\FileNode | \PhpParser\Node\Stmt\Declare_
1414
1515 # requires exact closure types
1616 checkMissingCallableSignature : true
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \DeadCode \Rector \Stmt \RemoveUnreachableStatementRector \Fixture ;
4+
5+ declare (ticks=1 ) {
6+ echo 'test ' ;
7+
8+ throw new \Exception ();
9+
10+ echo 'unreachable ' ;
11+ }
12+
13+ ?>
14+ -----
15+ <?php
16+
17+ namespace Rector \Tests \DeadCode \Rector \Stmt \RemoveUnreachableStatementRector \Fixture ;
18+
19+ declare (ticks=1 ) {
20+ echo 'test ' ;
21+
22+ throw new \Exception ();
23+ }
24+
25+ ?>
Original file line number Diff line number Diff line change 1515use PhpParser \Node \FunctionLike ;
1616use PhpParser \Node \Stmt \ClassLike ;
1717use PhpParser \Node \Stmt \ClassMethod ;
18- use PhpParser \Node \Stmt \Declare_ ;
1918use PhpParser \Node \Stmt \Function_ ;
2019use PhpParser \Node \Stmt \If_ ;
2120use PhpParser \Node \Stmt \Switch_ ;
@@ -66,7 +65,7 @@ public static function reIndexNodeAttributes(Node $node): ?Node
6665
6766 private static function reIndexStmtsKeys (Node $ node ): ?Node
6867 {
69- if (! NodeGroup::isStmtAwareNode ($ node ) && ! $ node instanceof ClassLike && ! $ node instanceof Declare_ ) {
68+ if (! NodeGroup::isStmtAwareNode ($ node ) && ! $ node instanceof ClassLike) {
7069 return null ;
7170 }
7271
Original file line number Diff line number Diff line change 1212use PhpParser \Node \Stmt \Class_ ;
1313use PhpParser \Node \Stmt \ClassConst ;
1414use PhpParser \Node \Stmt \ClassMethod ;
15+ use PhpParser \Node \Stmt \Declare_ ;
1516use PhpParser \Node \Stmt \Do_ ;
1617use PhpParser \Node \Stmt \Else_ ;
1718use PhpParser \Node \Stmt \ElseIf_ ;
@@ -56,6 +57,7 @@ final class NodeGroup
5657 TryCatch::class,
5758 While_::class,
5859 FileNode::class,
60+ Declare_::class,
5961 ];
6062
6163 /**
You can’t perform that action at this time.
0 commit comments