Re: Re: Typed properties patch

From: 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!
     Thanks for your time reviewing the patch, appreciated.
1) nullable properties
     I agree that we need a way to that, but I would rather see it
covered by nullable types rfc.
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?
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.


« previous php.internals (#92245) next »