Re: [RFC] Property hooks, nee accessors
| From: | Larry Garfield | Date: | Mon, 15 May 2023 18:45:37 +0000 |
| Subject: | Re: [RFC] Property hooks, nee accessors | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120297@lists.php.net to get a copy of this message | ||
Missed one...
On Mon, May 15, 2023, at 8:14 AM, Hendra Gunawan wrote:
> Can the engine detect these logical errors?
> ```
> public string $fullName = "hendra gunawan" => $this->first . " " .
> $this->last;
>
> // or with my proposal:
> public string $fullName = "hendra gunawan" get => $this->first . " "
> .
> $this->last;
>
> // or even this one:
> public string $fullName = "hendra gunawan" {
> get => $this->first . " " . $this->last;
> set => [$this->first, $this->last] = explode(" ", $value);
> ```
>
> Explanation:
> There is no automatic backing store value created to store the default value.
>
> Terima Kasih.
Those would be compile-time syntax errors, yes. (Or possibly link time, if inheritance is involved,
but still before execution time.)
--Larry Garfield