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
New mutator proposal: remove item from literal array #597
Comments
I think it is good idea - I believe the challenge here is to decide how many mutations we want to yield from such a mutator. |
Since we are trying to keep balance between the number of generated mutants and the speed of infection, I would say that generating N mutations for an array with N elements is too much. What about generating 1 mutation by default (e.g. removing the first element) and have a setting to enable N mutations if someone needs a hardcore mode? :) {
"mutators": {
"RemoveArrayItem": {
"settings": {
"remove": "first" (first|last|all)
}
}
}
} |
Maybe something like "N mutations for an array with N elements, up to X elements. If there are more than X elements, generate only one mutation for the first element". (Where X could be configured.) |
Perhaps something like using a Then it wouldn't be necessary to have a complicated configuration, but something that applies to all mutators that could potentially yield more than one mutation? Also see #636. |
TL;DR: A "remove item from literal array" mutator would be great.
Is your feature request related to a problem? Please describe.
I'm doing kind of a fingerprinting/checksum thing, like:
I just added a third item to the list of relevant data:
[$item->foo(), $item->bar(), $item->baz()]
. A little later I realized that whenever the output ofbaz()
changes, the output offoo()
changes too. So I could remove the first item and have the (functionally) same thing.Infection didn't check if the array item was required.
Describe the solution you'd like
Infection should warn me that an element in an array literal could be removed with the tests still passing.
The text was updated successfully, but these errors were encountered: