Re: Re: Typed properties patch
| From: | Dmitry Stogov | Date: | Wed, 13 Apr 2016 06:58:27 +0000 |
| Subject: | Re: Re: Typed properties patch | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-92245@lists.php.net to get a copy of this message | ||
On 04/13/2016 07:33 AM, Stanislav Malyshev wrote:
Hi!Because if you unset() a property it's type is not guaranteed anymore. <?php class Foo () { int $a = 0; } $a = new Foo(); $b = $a->x + 5; /* we know $a->x is "int" and may use optimized code */ unset($a->x); $b = $a->x + 5; /* $a->x is not "int" any more and we can't use optimized code */ ?> As we can't be sure where the property may be unset(), we won't be able to use optimized code at all (even in first place). Thanks. Dmitry.1) nullable propertiesThanks for your time reviewing the patch, appreciated.I think this is an attempt to achieve more type safety than even fully typed languages like Java, and it will only get in the way in PHP. 3) disable unset This sounds very weird. Why I would suddenly unable to unset a property?I agree that we need a way to that, but I would rather see itcovered by nullable types rfc.