Re: [RFC] [Discussion] Clone with
| From: | Alexandru Pătrănescu | Date: | Mon, 17 Apr 2023 07:43:50 +0000 |
| Subject: | Re: [RFC] [Discussion] Clone with | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120049@lists.php.net to get a copy of this message | ||
On Mon, Apr 17, 2023, 07:32 Máté Kocsis <kocsismate90@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
>