Re: [RFC] [Discussion] Clone with

From: Date: Mon, 29 May 2023 09:18:02 +0000
Subject: Re: [RFC] [Discussion] Clone with
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-120424@lists.php.net to get a copy of this message
Hi Everyone, In the meanwhile, I changed my proposal to use [] instead of {} after the "with" clause due to its better receptance. Additionally, I removed support for the shorthand "property assignment" syntax (clone $this with [property1: "foo"]) in favor the more powerful one where the left-hand side supports expressions (clone $this with ["property1" => "foo"]) so that we have more time to decide whether the former one is really needed.. After talking with Nicolas and Alexandru off-list (I accidentally didn't click "Reply All" in my response), we identified that their "clone callback" proposal could also be a future-scope of the current RFC with the following syntax: clone $this with function (object $clone): void { $this->property1 = "foo"; } In my opinion, this syntax is OK, albeit it's a bit long to write and a bit difficult to decipher its meaning (maybe it's just me). That's the main reason I prefer my originally proposed syntax. Apart from this, I don't see a big issue with it, neither conceptually, nor with the implementation. Regards, Máté

« previous php.internals (#120424) next »