Re: Behaviour of ReflectionClass::getStaticPropertyValue() for uninitialized typed properties
| From: | Ilija Tovilo | Date: | Sun, 26 Jan 2025 23:10:13 +0000 |
| Subject: | Re: Behaviour of ReflectionClass::getStaticPropertyValue() for uninitialized typed properties | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-126225@lists.php.net to get a copy of this message | ||
Hi Niels
On Sun, Jan 26, 2025 at 7:43 PM Niels Dossche <dossche.niels@gmail.com> wrote:
>
> I'm looking for feedback on a bugfix for
> https://github.com/php/php-src/issues/12856.
> Fix PR: https://github.com/php/php-src/pull/17590
>
> So the alternative idea, the one implemented in my PR, would be this:
>
> - If the property is uninitialized, and $def_value is not provided, then throw a
> ReflectionException with message "Property ... is not initialized and no default was
> provided".
> - If the property is uninitialized, and $def_value IS provided, then return $def_value.
> - In all other cases, the behaviour stays the same as it was.
I agree that this is the right approach. The proposed behavior is also
in line with native property access, with or without ??.
https://3v4l.org/S3mf8
Ilija