-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DeadCode] Allow not has side effect duplicate assign on RemoveDouble…
…AssignRector (#679) * [DeadCode] Allow not has side effect duplicat assign on RemoveDoubleAssignRector * skip different args value * do not remove comment first not has side effect func call * add stream_filter_append to impure function * clean up * clean up * skip stream_filter * phpstan * phpstan * clean up * found a bug different scope * fixture * debug * Fixed 🎉
- Loading branch information
1 parent
9dd6d63
commit 85e02fd
Showing
6 changed files
with
81 additions
and
13 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
.../RemoveDoubleAssignRector/Fixture/do_not_remove_comment_if_assignment_not_removed.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,28 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\Assign\RemoveDoubleAssignRector\Fixture; | ||
|
||
class DoNotRemoveCommentIfAssignmentNotRemoved | ||
{ | ||
protected function run(array $data) | ||
{ | ||
foreach ($data as $key => $val) { | ||
|
||
if (rand(0, 1)) { | ||
// a comment | ||
$val = str_replace('a', 'b', $val); | ||
$val = str_replace('b', 'c', $val); | ||
} | ||
|
||
if (rand(0, 1)) { | ||
if (rand(0, 1)) { | ||
// a comment | ||
$val = str_replace('a', 'b', $val); | ||
$val = str_replace('b', 'c', $val); | ||
} | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...Code/Rector/Assign/RemoveDoubleAssignRector/Fixture/not_has_side_effect_func_call.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,16 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\Assign\RemoveDoubleAssignRector\Fixture; | ||
|
||
$value = strlen('test'); | ||
$value = strlen('test'); | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\Assign\RemoveDoubleAssignRector\Fixture; | ||
|
||
$value = strlen('test'); | ||
|
||
?> |
4 changes: 4 additions & 0 deletions
4
...DeadCode/Rector/Assign/RemoveDoubleAssignRector/Fixture/skip_stream_filter_append.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,4 @@ | ||
<?php | ||
|
||
$streamFilter = stream_filter_append(STDOUT, 'AFilter'); | ||
$streamFilter = stream_filter_append(STDERR, 'AFilter'); |
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
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
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