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

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to