Re: [RFC] [VOTE] Typed properties v2
| From: | Sara Golemon | Date: | Thu, 20 Sep 2018 15:21:21 +0000 |
| Subject: | Re: [RFC] [VOTE] Typed properties v2 | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-103206@lists.php.net to get a copy of this message | ||
On Thu, Sep 20, 2018 at 9:50 AM, Levi Morrison <levim@php.net> wrote:
> This will be my last reply to this thread.
>
This will be my first and, God willing, only reply to this thread.
> Fundamentally:
>
> class User {
> public int $id;
> public string $preferred_name;
> public string $username;
> }
>
> ^ This never permits null properties, and using them without
> initializing them is an error, and you get notified by the runtime
> that such a thing happened. This is good and desirable behavior.
>
This is bad and undesirable behavior.
Deferring the error to on-read makes the properties magic and
unknowable. This is broken by design. The RFC got my vote because
broken never stood in PHP's way, and at the very least, as a library
author, I am empowered to aggressively initialize my properties even
if the runtime gives me insufficient protections from coding errors.
A static analysis engine can pick up the slack where the engine falls
short, so that's my yes vote, but it's not an endorsement of the
fundamentally broken design.
-Sara