Le lun. 28 juin 2021 à 18:22, Larry Garfield <la...@garfieldtech.com> a
écrit :

> 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.
>

Can you elaborate about the lack of support for withers? Having some work
to do doesn't look like an issue to me, especially when there is no
alternative to compare that too.

Reply via email to