Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ternary operator mutator #1390

Merged
merged 2 commits into from Oct 30, 2020
Merged

Add Ternary operator mutator #1390

merged 2 commits into from Oct 30, 2020

Conversation

sidz
Copy link
Member

@sidz sidz commented Oct 29, 2020

This PR:

Mutates:

- isset($b) ? 'B' : 'C';
+ isset($b) ? 'C' : 'B';
$foo = 'foo';
- $foo ?: 'bar';
+ $foo ? 'bar' : $foo;

@sidz sidz added the Mutator label Oct 29, 2020
sidz added a commit to infection/site that referenced this pull request Oct 29, 2020
PHP
];

if (PHP_VERSION_ID < 80000) {
Copy link
Member Author

@sidz sidz Oct 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PrettyPrinter from PhpParser generates nested ternary operators instead of wrap them up in braces. Fixed in nikic/PHP-Parser@eff72ee and hope will be in the next release so we will be able to remove this condition.

Nested ternary is deprecated since 7.4 and dropped in 8.0

Copy link
Member

@maks-rafalko maks-rafalko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

tests/phpunit/Mutator/Operator/TernaryTest.php Outdated Show resolved Hide resolved
@maks-rafalko maks-rafalko added this to the 0.20.0 milestone Oct 29, 2020
@sidz sidz merged commit 6fcf9c8 into master Oct 30, 2020
@sidz sidz deleted the ternary-operator-mutator branch October 30, 2020 10:23
sidz added a commit to infection/site that referenced this pull request Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants