Re: [RFC] Clone with v2
| From: | Larry Garfield | Date: | Wed, 14 May 2025 22:04:46 +0000 |
| Subject: | Re: [RFC] Clone with v2 | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-127364@lists.php.net to get a copy of this message | ||
On Wed, May 14, 2025, at 4:00 PM, Tim Düsterhus wrote:
> The internal implementation is roughly equivalent to:
>
> $cloned = clone $object;
> foreach ($withProperties as $key => $value) {
> $cloned->{$key} = $value;
> }
> return $cloned;
>
> Just with the exception that writing readonly properties is allowed on
> the clone (unless already touched by
__clone()).
Subtle point here. If the __clone() method touches a readonly property, does that make the property
inaccessible to the new clone-with? Or is it a separate "unlock scope"? I would expect
the latter. A single unlock block would be confusing to me.
--Larry Garfield