Re: [RFC][Vote] Typed Properties
| From: | Rowan Collins | Date: | Thu, 26 May 2016 16:50:30 +0000 |
| Subject: | Re: [RFC][Vote] Typed Properties | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-93575@lists.php.net to get a copy of this message | ||
On 26/05/2016 17:30, Fleshgrinder wrote:
class O {As I'm sure has already been pointed out (I haven't followed the whole thread) this defeats a large advantage of typed properties - I now can't read from the property without checking if it's null, so I can't do this: class O { public \DateTimeImmutable $d; } echo (new O)->d->format('Y-m-d H:i:s'); There's no ? on the type def, so I ought to be able to trust the type. A TypeError makes more sense here, because it is a programming error for it to be in this state. Regards, Rowan Collins [IMSoP]public int $x;} echo (new O)->x; // null + E_NOTICE