Hi

On 2026-11-27 21:05, Piotr Ziarek wrote:
is not intended to replace for, foreach or while, but to provide a simpler alternative for a common use case

The “common use case” is a claim that I'm not sure holds up in practice. My gut feeling is that of those three a `for()` loop is by far my least used loop in PHP with `foreach()` being the most widely used one. `do-while()` would likely below `for()`.

Searching the company code base for `for (`, `while (`, `foreach (`, excluding tests:

- for: 50 results across 32 files.
- while: 70 results across 47 files.
- foreach: 1418 results across 492 files.

So the “by far” does not hold up, but the relative order does. A single digit number of the `for()` loops were not using the iteration variable within the loop itself, mostly those in debug code outside of test files.

I agree with Kamil that this requires much more evidence-based justification to become a discussable proposal.

Best regards
Tim Düsterhus

Reply via email to