On 22/04/2022 21:47, Mark Randall wrote:
The rule that anything typed must be initialized, nullable or not, is clearish enough.


It's "clear" in the sense of "it can be described in one sentence". It's not at all "clear" in the sense of "makes any logical sense whatsoever".


You could special case nullable, but then it's an extra rule to learn beyond "typed = needs to be initialized".


I'm more inclined to the opposite: if reading an "undefined" property is going to be an error, maybe reading an "uninitialized" one should be too, even if you don't declare a type for it.

And maybe we should think about exactly what unset() means, and which error you're going to get after you use it - is the property "undefined" or "uninitialized"? Currently, an untyped property becomes "undefined", as though it never existed; but a typed property is still on the object, but "uninitialized". Yet either way, assigning a new value brings back the declared property, not a dynamic one with the same name: https://3v4l.org/nClNs

Regards,

--
Rowan Tommins
[IMSoP]

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

Reply via email to