Re: Re: [RFC] Readonly Variables

From: Date: Sun, 01 Mar 2026 12:35:57 +0000
Subject: Re: Re: [RFC] Readonly Variables
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-130207@lists.php.net to get a copy of this message
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

« previous php.internals (#130207) next »