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

Empty diff - Concat swap #1601

Closed
michalbundyra opened this issue Oct 29, 2021 · 1 comment · Fixed by #1602
Closed

Empty diff - Concat swap #1601

michalbundyra opened this issue Oct 29, 2021 · 1 comment · Fixed by #1602

Comments

@michalbundyra
Copy link
Contributor

Question Answer
Infection version 0.25.3
Test Framework version PHPUnit
PHP version 8.0
Platform -
Github Repo -

Related to #1524

https://infection-php.dev/r/lpdl

The same issue as described in #1524, it was closed, but not resolved.
Can we somehow skip this mutation, or I need to change my code (for example using str_repeat...) to pass the infection?

Thanks

@maks-rafalko
Copy link
Member

Hello,

Can we somehow skip this mutation

yes, please see here https://infection.github.io/guide/how-to.html#How-to-disable-Mutators-and-profiles

or I need to change my code (for example using str_repeat...)

good solution, if the goal of the code is to repeat the same string X times


What we can do on Infection side, is to not mutate the code when we see that the variables names are exactly the same on the left and right side of concatenation. So $x . $x won't produce any mutants.

Feel free to make a PR.

michalbundyra added a commit to michalbundyra/infection that referenced this issue Oct 29, 2021
maks-rafalko pushed a commit that referenced this issue Oct 31, 2021
…#1602)

* feat: Concat does not generate mutant when both operands are the same

Closes #1601

* Update ConcatTest.php

* use prettyPrint instead of prettyPrintExpr

* add clone per review suggestion

* suppress psalm issue - ImpureMethodCall

- per @maks-rafalko

* Update Concat.php

* suppress issue in psalm.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants