-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DeadCode] Skip used in next For_/Foreach_ on RemoveDeadIfForeachForR…
…ector (#5154) * [DeadCode] Skip used in next For_/Foreach_ on RemoveDeadIfForeachForRector * [DeadCode] Skip used in next For_/Foreach_ on RemoveDeadIfForeachForRector
- Loading branch information
1 parent
6d96068
commit 0eb6000
Showing
3 changed files
with
125 additions
and
23 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
.../DeadCode/Rector/For_/RemoveDeadIfForeachForRector/Fixture/skip_used_in_next_stmt.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\For_\RemoveDeadIfForeachForRector\Fixture; | ||
|
||
class SkipUsedInNextStmt | ||
{ | ||
public function run($resultLen, $result, $decimalSep) | ||
{ | ||
for ($i = $resultLen - 1; $i >= 0 && $result[$i] === '0'; $i--) { | ||
; | ||
} | ||
|
||
if ($i >= 0 && $result[$i] === $decimalSep) { | ||
$i--; | ||
} | ||
|
||
$result = substr($result, 0, $i + 1); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...DeadCode/Rector/For_/RemoveDeadIfForeachForRector/Fixture/skip_used_in_next_stmt2.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\For_\RemoveDeadIfForeachForRector\Fixture; | ||
|
||
class SkipUsedInNextStmt2 | ||
{ | ||
public function run($resultLen, $result, $decimalSep) | ||
{ | ||
foreach ($result as $i => $value) { | ||
; | ||
} | ||
|
||
if ($i >= 0 && $result[$i] === $decimalSep) { | ||
$i--; | ||
} | ||
|
||
$result = substr($result, 0, $i + 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters