Re: Re: [RFC] Readonly properties

From: Date: Mon, 28 Jun 2021 16:22:17 +0000
Subject: Re: Re: [RFC] Readonly properties
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-115179@lists.php.net to get a copy of this message
On Mon, Jun 28, 2021, at 11:17 AM, Nicolas Grekas wrote: > > > I'd like to open the discussion on readonly properties: > > > https://wiki.php.net/rfc/readonly_properties_v2 > > > > > > This proposal is similar to the > > > https://wiki.php.net/rfc/write_once_properties RFC > > > that has been > > declined > > > previously. One significant difference is that the new RFC limits the > > scope > > > of initializing assignments. I think a key mistake of the previous RFC > > was > > > the confusing "write-once" framing, which is both technically correct and > > > quite irrelevant. > > > > > > Please see the rationale section ( > > > > > > https://wiki.php.net/rfc/readonly_properties_v2#rationale) for how > > > this > > > proposal relates to other RFCs and alternatives. > > > > > > > I plan to open voting on this RFC soon. I don't think there's anything > > technical left to address here, the discussion mostly comes down to a value > > judgement. I think everyone has made their position regarding that clear... > > > > Actually, we talked off the list about a way to possibly make this work > with __clone(): > > We could allow __clone to have one argument, the object being cloned. And > when the signature declares this argument, then all readonly properties > would be set as uninitialized on $this. > > A typical __clone function would look like this with readonly properties: > function __clone(object $original) > { > $this->readonlyProp = clone $original->readonlyProp; > } > > That would turn my vote into a +1 if that could be made to work! That sounds like it would support deep cloning, but not with-er methods. There's no way to provide a changed value. It also would mean a lot of work on larger objects to transfer across all the properties. I don't really see what this would add. --Larry Garfield

« previous php.internals (#115179) next »