> From: Marco Pivetta <ocram...@gmail.com> > Sent: Thursday, June 21, 2018 01:10 > To: Nikita Popov <nikita....@gmail.com> > Cc: PHP Internals List <internals@lists.php.net> > Subject: Re: [PHP-DEV] [RFC] Typed Properties > > Hi Nikita, Bob, > > On Wed, 20 Jun 2018, 23:59 Nikita Popov, <nikita....@gmail.com> wrote: > > > Hi internals, > > > > Bob and I would like to present a new typed properties proposal for > > your > > consideration: > > > > > > > https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki > > > .php.net%2Frfc%2Ftyped_properties_v2&data=02%7C01%7C%7Ca414560298 > 8f413 > > > 3a54808d5d7031564%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C6 > 366513 > > > 30591392793&sdata=M70Asi8WqXbP6icXeVsdsBuI1GiK9UjgHj9EoZHX4%2Bg > %3D&res > > erved=0 > > > > 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 > > > > This is awesome news! I skimmed over the proposal and it is extremely well > thought out, and almost everything that was causing a -1 on the previous RFC > is gone: kudos! > > The last bit that is missing is the `__get` kink, mostly because `__get()` is > "squishy by design". Still, the fact that references are properly typed > mitigates the issue for my shady use-cases (I've got a reputation there), so > I'm quite happy with an implicit magic type check. One thing I couldn't find > is > whether this magic check is also enforced when calling `__get()` explicitly, > and not via the guards in the engine. > > Is the current development branch usable for testing something locally? I > can't see any obvious mistakes here, but I just wanted to try this out with > some of the more obscure libraries that touch property state at the level that > is covered by this RFC.
__get() is a very normal function - the special semantics are generally only applied if called for overloaded properties. So obviously, there is no check applied if you call it directly. The dev branch is stable for testing, yes. Would appreciate reports about any bugs you find. Bob