-
-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeQuality] Handle not identical return false then true on Simplify…
…IfReturnBoolRector (#1969) Co-authored-by: GitHub Action <action@github.com>
- Loading branch information
1 parent
6f61a09
commit 82656ad
Showing
6 changed files
with
67 additions
and
18 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...ector/If_/SimplifyIfReturnBoolRector/Fixture/not_identical_return_false_then_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,37 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector\Fixture; | ||
|
||
use PhpCsFixer\Tokenizer\Token; | ||
|
||
class NotIdenticalReturnFalseThenTrue | ||
{ | ||
public function run() | ||
{ | ||
$docToken = new Token([]); | ||
if (strpos($docToken->getContent(), "\n") !== false) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector\Fixture; | ||
|
||
use PhpCsFixer\Tokenizer\Token; | ||
|
||
class NotIdenticalReturnFalseThenTrue | ||
{ | ||
public function run() | ||
{ | ||
$docToken = new Token([]); | ||
return strpos($docToken->getContent(), "\n") === false; | ||
} | ||
} | ||
|
||
?> |
17 changes: 17 additions & 0 deletions
17
...fyIfReturnBoolRector/Fixture/skip_not_identical_return_false_then_return_in_array.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,17 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector\Fixture; | ||
|
||
class SkipNotIdenticalReturnFalseThenReturnInArray | ||
{ | ||
private const POSSIBLE_DELIMITERS = ['#', '~', '/']; | ||
|
||
public function run($firstChar, $lastChar) | ||
{ | ||
if ($firstChar !== $lastChar) { | ||
return false; | ||
} | ||
|
||
return in_array($firstChar, self::POSSIBLE_DELIMITERS, true); | ||
} | ||
} |
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
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