Theoretical question that perhaps does not make any sense but still, maybe there is a clever answer.
I want to iterate through array and get its keys and to somethin
It's valid PHP code, don't fix the code, but fix PHP MD. There is a config in PHP MD 2.2 And needs this rule: