Re: [RFC] [Discussion] Clone with

From: Date: Mon, 12 Jun 2023 18:13:43 +0000
Subject: Re: [RFC] [Discussion] Clone with
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-120559@lists.php.net to get a copy of this message
On Mon, Apr 17, 2023 at 12:32 AM Máté Kocsis <kocsismate90@gmail.com> wrote: > > Hi Everyone, > > Quite some time after mentioning the "clone with" construct the first time > (at the end of the > > https://wiki.php.net/rfc/write_once_properties#run-time_behaviour > section), > finally I managed to create a working implementation for this feature which > would make it possible to properly modify readonly properties > while simplifying how we write "wither" methods: > https://wiki.php.net/rfc/clone_with > > Regards, > Máté Kocsis I apologize if this has been discussed before, as I have fallen very behind on internals discussions. I think it would be helpful to add an example where the object being cloned accesses its properties. Something like this: $b = clone $a with ["count" => $a->count * 2]; If this is not valid, or if it has unexpected behavior or semantics, that should also be included in the RFC.

« previous php.internals (#120559) next »