Re: [RFC][Vote] Typed Properties

From: Date: Thu, 26 May 2016 16:20:08 +0000
Subject: Re: [RFC][Vote] Typed Properties
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-93569@lists.php.net to get a copy of this message
On 5/26/16, 11:02 AM, "James Gilliland" <neclimdul@gmail.com> wrote: >Sarcasm aside, I still can't figure out how fundamentally changing how >people interact with uninitialized properties like this improves >developer experience. Can someone explain a case where this is better and >catches a bug or something? Since this is a new feature I would assume >its not covered by "BC" but this seems like a painful gotcha for people >developing across typed and untyped code. Talk of improving developer experiences is too subjective for me. I only want to say that one option we have is to require that a PHP property with a type declaration must also have an initial value declaration. This obviates some confusion, which is a good thing in my opinion. I understand that it will be surprising to some that the lazy old `public $var;` (that initializes to null if it is read before written to) is not available if you insert a type declaration. Such surprise will dissipate quickly if the compiler rejects such cases, one way or the other: either don't declare type or declare type plus initial value. If I'm wrong in this estimation and we in fact need to protect developers from the pain of this experience then I'd prefer to reject typed properties for the time being. Tom

« previous php.internals (#93569) next »