> On Jun 29, 2021, at 9:08 AM, Nikita Popov <nikita....@gmail.com> wrote: > > In any case, I don't want to include changes to cloning in this proposal -- > the topic is related, but also orthogonal to readonly properties. > Unfortunately, it will not be possible to get cloning changes into PHP 8.1 > anymore, due to feature freeze. > > It's okay to vote against this if cloning is a deal breaker. In that case > I'll probably either work on cloning before re-proposing this,
I while back I made a suggestion for cloning which seemed to resolve the cloning issue in a way that no other proposals do. However, no one acknowledged it, so maybe few if any people saw it? https://externals.io/message/114729#114747 <https://externals.io/message/114729#114747> Anyway TL;DR, the approach is to allow specifying a closure on clone, binding $this to it, and then allow modifications to readonly properties while in that context and anything that it calls: $clone_obj = clone $obj fn() => { $this->foo = 'new value'; } Would this not be a viable solution for cloning, for this RFC, or the only you work on if this one fails to pass? -Mike