-
-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DeadCode] Handle bool var if cond return true next return bool var o…
…n RemoveDuplicatedIfReturnRector (#1136) Co-authored-by: GitHub Action <action@github.com>
- Loading branch information
1 parent
c86a6ea
commit 37ade3f
Showing
4 changed files
with
119 additions
and
12 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
.../FunctionLike/RemoveDuplicatedIfReturnRector/Fixture/bool_var_if_cond_return_true.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,31 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\FunctionLike\RemoveDuplicatedIfReturnRector\Fixture; | ||
|
||
class BoolVarIfCondReturnTrueNextReturnBoolVar | ||
{ | ||
public function run(bool $value) | ||
{ | ||
if ($value) { | ||
return true; | ||
} | ||
|
||
return $value; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\FunctionLike\RemoveDuplicatedIfReturnRector\Fixture; | ||
|
||
class BoolVarIfCondReturnTrueNextReturnBoolVar | ||
{ | ||
public function run(bool $value) | ||
{ | ||
return $value; | ||
} | ||
} | ||
|
||
?> |
15 changes: 15 additions & 0 deletions
15
...tionLike/RemoveDuplicatedIfReturnRector/Fixture/skip_negation_if_cond_return_true.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,15 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\FunctionLike\RemoveDuplicatedIfReturnRector\Fixture; | ||
|
||
class SkipNegationIfCondReturnReturnTrueNextReturnCond | ||
{ | ||
public function run(bool $value) | ||
{ | ||
if (! $value) { | ||
return true; | ||
} | ||
|
||
return $value; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
.../Rector/FunctionLike/RemoveDuplicatedIfReturnRector/Fixture/skip_non_bool_if_cond.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,15 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\FunctionLike\RemoveDuplicatedIfReturnRector\Fixture; | ||
|
||
class SkipNonBoolIfCond | ||
{ | ||
public function run(stdClass $value) | ||
{ | ||
if ($value) { | ||
return true; | ||
} | ||
|
||
return $value; | ||
} | ||
} |
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