-foreach ($results as $index => $result) {
+foreach ($results as $result) {
_Originally posted by @theofidry in https://github.com/infection/infection/pull/1242_
Q:
this mutation will in most cases be killed because of "undefined variable", no?
A:
That, unless
$indexis unused.
So, in my opinion (although I didn't do any real checks) this can lead to killed mutants in majority of the cases.
We should not do this mutation _if the variable is used_, but at the moment Infection has no such knowledge about variables. As I said many times before, probably we need to integrate PHPStan's engine to track variables usages & types to accomplish it.
For what its worth, i found those unused variables with help of the 'find dead code' feature from psalm.
So i'm not convinced this is something that should be part of infection, but rather it should be part of a static analysis tool.
Most helpful comment
For what its worth, i found those unused variables with help of the 'find dead code' feature from psalm.
So i'm not convinced this is something that should be part of infection, but rather it should be part of a static analysis tool.