Re: [RFC Discussion] Typed Properties
| From: | Andrey Andreev | Date: | Thu, 17 Mar 2016 11:46:16 +0000 |
| Subject: | Re: [RFC Discussion] Typed Properties | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-91735@lists.php.net to get a copy of this message | ||
Hi,
On Thu, Mar 17, 2016 at 1:02 PM, Matt Prelude <me@mprelu.de> wrote:
I'd support borrowing the "?" nullable annotation from HackLang for
> people who want a less strict behavior:
>
> public ?string $name;
>
> This means that $name can either be a string or the NULL value.
>
Or, do it like with parameter type hinting:
public string $name = null;
Although I'm all for limiting NULL to only being the default value:
$this->name = null; // this should throw a TypeError
Cheers,
Andrey.