On 22/04/2022 18:12, Mark Randall wrote:
Accessing an unset property, which currently emits a warning, will instead throw an Error.

[...]

Re: Case 4, an untyped property without its own initializer is effectively defaulted to null.


Imagine you're a new user, learning PHP 9.0, and learning that "public $foo" defaults to null; and if you call unset(), it's deleted from the object, and then accessing it is an error. But then you change it to "public ?string $foo" and it doesn't default to null, even though it's nullable, and accessing it will give you a different error; and calling unset() on that doesn't delete it from the object, but does mean you get an error reading it. Also, there's this non-standard class called "stdClass", which unlike standard classes, you can read and write any property you like without declaring it, and even if you use unset(), you'll never get an error.

Do you not have even a little bit of hope that we could make that less confusing, since we're breaking everyone's old code anyway?

Regards,

--
Rowan Tommins
[IMSoP]

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

Reply via email to