On Mon, Apr 17, 2023, 07:32 Máté Kocsis <kocsismat...@gmail.com> wrote:

> 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


Hey Máté,

How about just allowing a block of code after the clone statement that
would execute it in the same context as the clone context, allowing to
modify once readonly variables.
Allows better flexibility compared with clone with syntax or clone metho:

    public function withStatus($code, $reasonPhrase = ''): Response
    {
        return clone $this {
            $this->statusCode = $code;

           $this->reasonPhrase = $reasonPhrase;

};

Regards,
Alex


>

Reply via email to