-
-
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 recursive on LogicalToBooleanRector (#808)
* fix: recursively call rector until no node is a LogicalOr or LogicalAnd * added fixture for mixed logical and binary * phpstan * inline instanceof checks * fix: recursively call rector until no node is a LogicalOr or LogicalAnd * phpstan * inline instanceof checks * rebase + apply rector * fix: recursively call rector until no node is a LogicalOr or LogicalAnd * added fixture for mixed logical and binary * phpstan * inline instanceof checks * rebase + apply rector * move refactor logic into new function * move refactor logic into new function * eol Co-authored-by: Bl00D4NGEL <kuhlesdominik@gmx.de>
- Loading branch information
1 parent
511a076
commit 0f9e4f8
Showing
4 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
rules-tests/CodeQuality/Rector/LogicalAnd/LogicalToBooleanRector/Fixture/mixed.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,53 @@ | ||
<?php | ||
|
||
function run($val1, $val2, $val3, $val4) | ||
{ | ||
if ( | ||
( | ||
1 === $val1 or | ||
1 === $val2 || | ||
1 === $val3 or | ||
1 === $val4 | ||
) | ||
) { | ||
//code | ||
} | ||
|
||
if ( | ||
( | ||
1 === $val1 and | ||
1 === $val2 && | ||
1 === $val3 and | ||
1 === $val4 | ||
) | ||
) { | ||
//code | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
function run($val1, $val2, $val3, $val4) | ||
{ | ||
if ( | ||
( | ||
1 === $val1 || (1 === $val2 || | ||
1 === $val3) || 1 === $val4 | ||
) | ||
) { | ||
//code | ||
} | ||
|
||
if ( | ||
( | ||
1 === $val1 && (1 === $val2 && | ||
1 === $val3) && 1 === $val4 | ||
) | ||
) { | ||
//code | ||
} | ||
} | ||
|
||
?> |
32 changes: 32 additions & 0 deletions
32
rules-tests/CodeQuality/Rector/LogicalAnd/LogicalToBooleanRector/Fixture/multi_and.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,32 @@ | ||
<?php | ||
|
||
function run($val1, $val2, $val3, $val4) | ||
{ | ||
if ( | ||
( | ||
1 === $val1 and | ||
1 === $val2 and | ||
1 === $val3 and | ||
1 === $val4 | ||
) | ||
) { | ||
//code | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
function run($val1, $val2, $val3, $val4) | ||
{ | ||
if ( | ||
( | ||
1 === $val1 && 1 === $val2 && 1 === $val3 && 1 === $val4 | ||
) | ||
) { | ||
//code | ||
} | ||
} | ||
|
||
?> |
32 changes: 32 additions & 0 deletions
32
rules-tests/CodeQuality/Rector/LogicalAnd/LogicalToBooleanRector/Fixture/multi_or.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,32 @@ | ||
<?php | ||
|
||
function run($val1, $val2, $val3, $val4) | ||
{ | ||
if ( | ||
( | ||
1 === $val1 or | ||
1 === $val2 or | ||
1 === $val3 or | ||
1 === $val4 | ||
) | ||
) { | ||
//code | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
function run($val1, $val2, $val3, $val4) | ||
{ | ||
if ( | ||
( | ||
1 === $val1 || 1 === $val2 || 1 === $val3 || 1 === $val4 | ||
) | ||
) { | ||
//code | ||
} | ||
} | ||
|
||
?> |
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