Re: [RFC][Vote] Typed Properties

From: Date: Thu, 26 May 2016 00:11:22 +0000
Subject: Re: [RFC][Vote] Typed Properties
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-93548@lists.php.net to get a copy of this message
> Am 25.05.2016 um 23:56 schrieb Stanislav Malyshev <smalyshev@gmail.com>: > > Hi! > >> var_dump($a->w); // Fatal error, uninitialized... > > This means every read access to a property should be checked for it > being typed, and every access to a typed property should be checked for > it being initialized. I'm concerned there might be a performance hit for > this. > > Also, this means no access for a property - even defined one - is safe, > and if you want to avoid fatal errors, you need to check every access, > at least if you suspect typed properties may be involved. And, of > course, there's no function in the RFC to actually check it. > -- > Stas Malyshev > smalyshev@gmail.com Hey Stas, this is pretty much a non-issue (perf-wise) as we anyway need to check against IS_UNDEF to emit a notice and return null, even with normal properties. Also, property access never was safe. Consider: $obj = new class { public $foo; function __construct() { unset($this->foo); } function __get($prop) { throw new Exception("No $prop for you today!"); } }; var_dump($obj->foo); // exception. isset() checks will continue to work. It's just about getting a *value*. (and to check whether it's a typed property, there's Reflection support in the RFC.) This definitely is no problem. Bob

« previous php.internals (#93548) next »