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 Flip Coalesce operator mutator #1389
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I didn't do any analytics, but from the first look - agree, sounds like redundant |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about self::A ?? self::B
? And with constants in general. These might be unkillable.
is it a real case? I mean it's strange to use constant in |
It can be any kind of a constant expression. define('TEST_ENVIRONMENT', null);
class B {
const ALLOW_FEATURE_A = TEST_ENVIRONMENT;
} No doubt it's a poor programming style, but shall we punish it? |
Probably I don't understand the real case and that's why don't see an issue here. Any real examples? I just can't remember any cases with such code |
The issue is that you might not be able to test In either case I think this method either not worth the testing, or difficult to test. This makes a useless mutation, a waste of time. |
So what are you suggesting? Do not mutate when the left side is a const? Alternatively, if the user has such a weird case, they can ignore such line of the code, via {
"mutators": {
"global-ignoreSourceCodeByRegex": ["self::.*\\s\\?\\?\\sself::.*"]
}
} |
Yes, I think it's a general enough case to ignore all mutations with a constant fetch on the left by default. It is much cheaper for us to do that now, than for a user to invent complicated (as we can readily see!) regular expression just to avoid a pointless mutation. |
TBH I'm not convinced, as I have never seen such code. But if you did - then ok. |
Let me put this way: in which circumstances do you think running this mutation against a constant on a left will be useful? Again, it is not about this mutation is harmful, it's not, but rather it is not useful. Even annoyingly not useful. One can argue this variant of this mutation isn't useful for most projects just like |
If I learnt something from the |
…or class constant
@sanmai done |
This PR:
Mutates:
Requested in #1387
p.s. From my POV
Infection\Mutator\Operator\Coalesce
mutator is redundant when this PR is merged. Thoughts?