Fix Lazy Objects Reflection API: add ReflectionProperty::isLazy()#16342
Fix Lazy Objects Reflection API: add ReflectionProperty::isLazy()#16342arnaud-lb wants to merge 3 commits intophp:PHP-8.4from
Conversation
|
@arnaud-lb seeing it so closely to the |
|
you cannot target 8.4 as we no longer allow any features in RC. |
nicolas-grekas
left a comment
There was a problem hiding this comment.
I missed this in the RFC because I used a hack based on (array). Definitely something that's missing and that'd be great even late in 8.4 🙏
|
@bukka after thinking more about this change, we would like to propose it as an API bug fix since this addresses a flaw in an API introduced in 8.4. @php/release-managers-84 do you accept this to be merged in 8.4 as a bug fix? NB: build failures are unrelated. |
|
Since it seems a polyfill could be used and documented, I'm not sure about rushing it into 8.4. However, it's very simple, self-contained, and fixes a problem with an 8.4 specific feature (as opposed to something general that 8.4 makes more obvious), so I think it should be fine. I'm wondering what the other RMs think. |
I have no objection. |
|
It's a bit questionable whether this is a bug but if others think it is, I don't have objections. |
This is a bug fix for a design flaw in the Lazy Objects Reflection API:
The API provides
ReflectionProperty::setRawValueWithoutLazyInitialization()andReflectionProperty::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.A workaround is to cast the object as array (with
(array) $obj), but this is slower than needed and is used in performance-critical code in Doctrine, for instance.This PR fixes this by adding the method
ReflectionProperty::isLazy(object $obj). It returns true when the property is lazy and accessing it would trigger initialization of the object.