Hi Stas,
Stanislav Malyshev wrote:
Hi!
* uninitialised - the constructor (or indeed, other code) is yet to set it
* null - the property is left intentionally empty
For declared properties, this always has been the same, and I'm not sure
why would we want to change that. This also has a potential to be a huge
BC break if we change it not to be the same, since pretty much all the
code assumes it is the same. We'd essentially have to invent another
null, which is exactly the same as null but isn't null. I don't see a
reason to do this.
It'd be a BC break if we changed untyped properties' behaviour, yeah. We
wouldn't be inventing a new null, though, we'd be leaving the property
undefined until it's initialised, which we already have support for
(properties, and indeed all variables can be unset()).
* some other value - the property is intentionally given a value
A simple example might be a Lisp-style linked list cell:
class LinkedList
{
public int $head;
public ?LinkedList $tail;
}
In a properly initialised LinkedList, the $head is some value, and the
$tail is either another linked list (the remainder of the list), or null
(we're at the end of the list).
This is a very weird list, as it can't be empty.
The empty list is represented by null in this arrangement.
Thanks.
--
Andrea Faulds
https://ajf.me/
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php