[php-src] PR #16527: Fix Lazy Objects Reflection API: add ReflectionProperty::getRawValueWithoutLazyInitialization()
| From: | arnaud-lb | Date: | Mon, 21 Oct 2024 12:41:08 +0000 |
| Subject: | [php-src] PR #16527: Fix Lazy Objects Reflection API: add ReflectionProperty::getRawValueWithoutLazyInitialization() | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-29329@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/16527
Author: arnaud-lb
This is a bug fix for a design flaw in the Lazy Objects Reflection API:
The API provides
ReflectionProperty::setRawValueWithoutLazyInitialization() and
ReflectionProperty::skipLazyInitialization(), but does not provide any way to fetch the
value of a property without triggering initialization, or to check if a property is lazy.
This flaw makes lazy objects unusable in Doctrine, for instance.
This PR fixes this by adding the method getRawValueWithoutLazyInitialization(object $obj,
&$isLazy). Its behavior is as follows:
- If the property is not lazy, it's the same as getRawValue(), and
$isLazy is set to false
- If the property is lazy, NULL is returned and $isLazy is set to
true
Alternative like adding an isLazy() method, or returning an array [$value,
$isLazy] from getRawValueWithoutLazyInitialization() were considered, but were
slower.