Re: [RFC] [Discussion] Clone with

From: Date: Mon, 29 May 2023 18:38:09 +0000
Subject: Re: [RFC] [Discussion] Clone with
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-120435@lists.php.net to get a copy of this message
On 29.05.2023 14:12, Aleksander Machniak wrote:
In "Property name expressions" section's first code example I think you intended to do clone $self (not clone $this) inside the foreach() loop. Also, I have a feeling that it would be better to implement `clone $object with $properties` syntax first and if that is accepted think about expressions support. It's not a strong feeling though.
Actually, with some more thought, my opinion now is that introduction of property name expressions is not justified. And will be a reason for me to vote No. I'm still not decided about which syntax I'd prefer, maybe you should do a poll with these basic options. Sorry, if there was one and I missed it. 1) clone $object with $properties; 2) clone($object, $properties); 3) clone($object, prop1: $var1, prop2: $var2); 4) clone($object, function ($clone) use ($properties) {
       foreach ($properties as $name => $value) {
           $clone->{$name} = $value;
       }
}); 5) clone $obj with (prop1: $var1, prop2: $var2); note: $properties is iterable note: in 2-4) brackets are potentially optional. note: imho, 5) is similar to 3), but worse. -- Aleksander Machniak Kolab Groupware Developer [https://kolab.org] Roundcube Webmail Developer [https://roundcube.net] ---------------------------------------------------- PGP: 19359DC1 # Blog: https://kolabian.wordpress.com

« previous php.internals (#120435) next »