sstalle/php7cc

Need clarification on foreach loop warning

dmitry-varennikov-eventbase opened this issue · 1 comments

HI,

I was curious what exactly "Nested by-reference foreach loop, make sure there is no iteration over the same array" warning mean?

Hello.

There are very subtle backward incompatible changes when the array that is iterated over is modified inside the foreach loop. Here is an example that demonstrates the difference (taken from the foreach RFC).

The warning is poorly worded. It should probably say something along the lines of: "Nested by-reference foreach loop, make sure that array modifications (if any) are safe