Re: [RFC] Property write visibility

From: Date: Wed, 01 Jul 2020 12:35:13 +0000
Subject: Re: [RFC] Property write visibility
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-110800@lists.php.net to get a copy of this message
On Wed, Jul 1, 2020 at 12:58 PM André Rømcke <andre.romcke@gmail.com> wrote: > > "Attempting to pass a property value outside of allowed writable scope >> as a reference, results in an error." > > > ... we definitely shouldn't do this, because it goes against existing > language semantics. You can take a reference to a normal private property > (i.e. private get, private set), pass it outside the class and then modify > it. > > > > This was copied from some other source actually. I’m all for staying as > close as possible to how the language behaves on this, changing it should > be different RFC. > > Should I just remove this section or do you have suggestions for what we > need to specify when it comes references? > I think the only thing worth mentioning where references are concerned is that "$x =& $this->prop" is considered a write of $this->prop, not a read, so it is subject to the write visibility. But once the reference is acquired, visibility no longer factors into the behavior. Nikita

« previous php.internals (#110800) next »