Le jeu. 21 juin 2018 à 00:00, Nikita Popov <nikita....@gmail.com> a écrit :
> Hi internals, > > Bob and I would like to present a new typed properties proposal for your > consideration: > > https://wiki.php.net/rfc/typed_prwould some benefitsoperties_v2 > <https://wiki.php.net/rfc/typed_properties_v2> > > The proposal allows you to annotate properties with types, which are > enforced at runtime. Unlike the previous RFC on this topic, the new > proposal also supports typed static properties and references to typed > properties. > > Please note that next to the main body, the RFC also contains an > "Alternatives" section, which explores the problem space and considers > trade-offs of different behaviors in some detail. > > Finally, while this RFC currently targets PHP 7.3, this is a large and > complex proposal and we may not be able to meet the deadline, in which case > this feature will go into the next PHP version. > > Regards, > Nikita > Hi Nikita, Bob, Congrats for the awesome job! It looks very good. My only concern is about regular variables, not bound to any classes. Isn't that a little bit inconsistent that classes properties could be typed, but not a regular variable in the middle of a function/method/plain "script" file? I would see some benefit doing something like: string $content = file_get_contents("/foo/bar"); (Sorry if this has been raised already in the past) Patrick