Re: [RFC][Vote] Typed Properties

From: Date: Thu, 26 May 2016 12:24:17 +0000
Subject: Re: [RFC][Vote] Typed Properties
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  Groups: php.internals 
Request: Send a blank email to internals+get-93562@lists.php.net to get a copy of this message
On 5/26/2016 1:57 PM, Rowan Collins wrote: > I am definitely in favour of this from a language point of view. The > notice is warning about *initialization*, not *declaration*, so it makes > sense to warn on "var $foo" and not "var $foo = null". > > The only thing I'm not sure is what the impact would have on the > internals, which may be why it doesn't already work that way. With a > simple variable the notice can be easily raised based on the variable > name not being in the current symbol table; with an object property, the > name *is* in the relevant table, because it's been *declared* even > though it hasn't been *initialized*. Thus you need some extra flag to > track that a declared property exists but has never been written to. > > But it sounds like typed properties require adding some such overhead > anyway... > > Regards, Looking at zend_object_handlers.c and zend_std_read_property there is the line: retval = &EG(uninitialized_zval); This is what gives us the default null of our properties if I interpret everything correctly. This is also the place where the undefined property error comes from. We need help here from people who know the PHP source better. -- Richard "Fleshgrinder" Fussenegger

Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
« previous php.internals (#93562) next »