-
-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Strict] Add support string|null|false on BooleanInBooleanNotRuleFixe…
…rRector (#2035) * [Strict] Add support string|null|false on BooleanInBooleanNotRuleFixerRector * fixed 🎉 * test in trat as non empty true as well * add test for string and null only, tested with both TREAT_AS_NON_EMPTY true and false * multi union types on DisallowedEmptyRuleFixerRector
- Loading branch information
1 parent
7666733
commit 9b46906
Showing
8 changed files
with
167 additions
and
30 deletions.
There are no files selected for viewing
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
39 changes: 39 additions & 0 deletions
39
...ector/BooleanNot/BooleanInBooleanNotRuleFixerRector/Fixture/string_null_and_false.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,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector\Fixture; | ||
|
||
class StringNullAndFalse | ||
{ | ||
public function run(string|null|false $name) | ||
{ | ||
if (! $name) { | ||
return 'no name'; | ||
} | ||
|
||
return 'name'; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector\Fixture; | ||
|
||
class StringNullAndFalse | ||
{ | ||
public function run(string|null|false $name) | ||
{ | ||
if ($name === '' || $name === false || $name === null) { | ||
return 'no name'; | ||
} | ||
|
||
return 'name'; | ||
} | ||
} | ||
|
||
?> |
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
39 changes: 39 additions & 0 deletions
39
...t/BooleanInBooleanNotRuleFixerRector/FixtureTreatAsNonEmpty/string_null_and_false.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,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector\FixtureTreatAsNonEmpty; | ||
|
||
class StringNullAndFalse | ||
{ | ||
public function run(string|null|false $name) | ||
{ | ||
if (! $name) { | ||
return 'no name'; | ||
} | ||
|
||
return 'name'; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector\FixtureTreatAsNonEmpty; | ||
|
||
class StringNullAndFalse | ||
{ | ||
public function run(string|null|false $name) | ||
{ | ||
if ($name === '' || $name === false || $name === null) { | ||
return 'no name'; | ||
} | ||
|
||
return 'name'; | ||
} | ||
} | ||
|
||
?> |
39 changes: 39 additions & 0 deletions
39
...leanInBooleanNotRuleFixerRector/FixtureTreatAsNonEmpty/union_with_null_from_param.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,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector\FixtureTreatAsNonEmpty; | ||
|
||
class UnionWithNullFromParam | ||
{ | ||
public function run(string|null $name) | ||
{ | ||
if (! $name) { | ||
return 'no name'; | ||
} | ||
|
||
return 'name'; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector\FixtureTreatAsNonEmpty; | ||
|
||
class UnionWithNullFromParam | ||
{ | ||
public function run(string|null $name) | ||
{ | ||
if ($name === null) { | ||
return 'no name'; | ||
} | ||
|
||
return 'name'; | ||
} | ||
} | ||
|
||
?> |
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