Bug Report
| Subject |
Details |
| Rector version |
2.1.0 |
I know it's not the best written code, but just wanted to report that if the developper has reused the foreach variable later, all the ForeachToArray* rector are breaking the code.
Minimal PHP Code Causing Issue
https://getrector.com/demo/b44622d0-2a83-49f9-88a4-6cc22bef9312
https://onlinephp.io/c/445115
vs
https://onlinephp.io/c/76d65
The echo is not executed anymore.
Expected Behaviour
If the foreach variables are used later in the code, the foreach shouldn't be replaced ; that works for
- ForeachToArrayFindRector
- ForeachToArrayAllRector
- ForeachToArrayAnyRector
- ForeachToArrayFindKeyRector
with both key and value.