Re: [RFC][Vote] Typed Properties

From: Date: Thu, 26 May 2016 13:38:06 +0000
Subject: Re: [RFC][Vote] Typed Properties
References: 1 2 3 4 5 6 7 8 9 10 11 12  Groups: php.internals 
Request: Send a blank email to internals+get-93565@lists.php.net to get a copy of this message
On 5/25/16 6:03 PM, Stanislav Malyshev wrote:
Hi! Andrea already said that we would not use it for untyped properties, hence, no BC. Again, it's not that simple. Properties are not local. That means any code that can deal with a class that may have typed properties (which may be library class, for example, so you don't even know what it has inside) has to deal with the possibility of it being of the new type. So if the old code uses is_null($object->foo) as means to check if the value wasn't initialized, and it's no longer null, then that code is broken and needs to be rewritten. That's a BC break. Yes, it will never happen if you never use typed properties, and never use any libraries that might use typed properties, but then what's the point of the whole thing? The point of BC is that if you don't use new features, you don't have to change your code and it will keep working. With the proposed solution, it won't be the case.
If you want, you can easily write a backwards-compatible new class that uses declared type properties with
    public int $property = null;
I don't think loss of the (as yet hypothetical) lazy shortcut to write the same thing:
    public int $property;
is BC break. Tom

« previous php.internals (#93565) next »