Hi Am 2026-02-25 15:41, schrieb Ilija Tovilo:
- Without runtime tracking of readonly (and the concept of block scoping) every variable name could only be declared once in a function.
After thinking about the RFC for a few days, Ilija is making a good point here:
I find “block scoping” a necessary prerequisite to have local readonly variables (and also local typed variables). Being able to define a readonly variable within an `if()` and thus making it *conditionally* readonly (or conditionally typed) is going to invite confusion. It is the obviously correct behavior with the current semantics of PHP, though.
I nevertheless appreciate the effort that went into the RFC, particular with the attention to detail pointing out all “edge cases”. It made it really easy to think about the proposal, because there was no need to make assumptions about how it's supposed to work.
Best regards Tim Düsterhus
