File tree Expand file tree Collapse file tree
rules-tests/DeadCode/Rector/Stmt/RemoveEmptyArrayConditionReturnRector/Fixture
rules/DeadCode/Rector/Stmt Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \DeadCode \Rector \Stmt \RemoveEmptyArrayConditionReturnRector \Fixture ;
4+
5+ final class AllowAnyType
6+ {
7+ public function run ($ result )
8+ {
9+ if ($ result === []) {
10+ return [];
11+ }
12+
13+ return $ result ;
14+ }
15+ }
16+
17+ ?>
18+ -----
19+ <?php
20+
21+ namespace Rector \Tests \DeadCode \Rector \Stmt \RemoveEmptyArrayConditionReturnRector \Fixture ;
22+
23+ final class AllowAnyType
24+ {
25+ public function run ($ result )
26+ {
27+ return $ result ;
28+ }
29+ }
30+
31+ ?>
Original file line number Diff line number Diff line change 99use PhpParser \Node \Expr \Array_ ;
1010use PhpParser \Node \Expr \BinaryOp \Equal ;
1111use PhpParser \Node \Expr \BinaryOp \Identical ;
12+ use PhpParser \Node \Stmt \If_ ;
1213use PhpParser \Node \Stmt \Return_ ;
1314use Rector \Contract \PhpParser \Node \StmtsAwareInterface ;
1415use Rector \Rector \AbstractRector ;
@@ -74,7 +75,7 @@ public function refactor(Node $node): ?Node
7475 }
7576
7677 foreach ($ node ->stmts as $ key => $ stmt ) {
77- if (! $ stmt instanceof Node \ Stmt \ If_) {
78+ if (! $ stmt instanceof If_) {
7879 continue ;
7980 }
8081
Original file line number Diff line number Diff line change 5353use Rector \DeadCode \Rector \PropertyProperty \RemoveNullPropertyInitializationRector ;
5454use Rector \DeadCode \Rector \Return_ \RemoveDeadConditionAboveReturnRector ;
5555use Rector \DeadCode \Rector \StaticCall \RemoveParentCallWithoutParentRector ;
56+ use Rector \DeadCode \Rector \Stmt \RemoveEmptyArrayConditionReturnRector ;
5657use Rector \DeadCode \Rector \Stmt \RemoveUnreachableStatementRector ;
5758use Rector \DeadCode \Rector \Switch_ \RemoveDuplicatedCaseInSwitchRector ;
5859use Rector \DeadCode \Rector \Ternary \TernaryToBooleanOrFalseToBooleanAndRector ;
@@ -124,6 +125,7 @@ final class DeadCodeLevel
124125 RemoveDeadCatchRector::class,
125126 RemoveDeadTryCatchRector::class,
126127 RemoveDeadIfForeachForRector::class,
128+ RemoveEmptyArrayConditionReturnRector::class,
127129 RemoveDeadStmtRector::class,
128130 UnwrapFutureCompatibleIfPhpVersionRector::class,
129131 RemoveParentCallWithoutParentRector::class,
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ private function includePreloadFilesAndScoperAutoload(): void
7070 if (! class_exists (Version::class, true ) || (int ) Version::id () < 12 ) {
7171 require_once __DIR__ . '/../../../preload.php ' ;
7272 }
73+
7374 // test case in rector split package
7475 } elseif (file_exists (__DIR__ . '/../../../../../../vendor ' )) {
7576 require_once __DIR__ . '/../../../preload-split-package.php ' ;
You can’t perform that action at this time.
0 commit comments