[php-src] Issue #9389: Typed property /w magic __get cannot be uninitialized
| From: | mvorisek | Date: | Sat, 20 Aug 2022 14:41:23 +0000 |
| Subject: | [php-src] Issue #9389: Typed property /w magic __get cannot be uninitialized | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242270@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9389
Author: mvorisek
### Description
demo: https://3v4l.org/lDeXi
Currently, typed property can be "almost uninitialized" by
unset().
But doing such uninitialization unsets the property and allows magic __get to kick in. This is
expected and discussed in https://github.com/php/php-src/issues/9021.
Because of this, non-readonly typed property cannot be uninitialized properly. This is an issue in
cases when the same object is to be restored, reused or cleaned.
To allow an object state to be restore/uninitialized correctly, I propose to add
ReflectionProperty::setUninitialized() method and backport it into PHP 8.0 and above.