You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Adapters rely on unset() of Reflection $name/$class, which php-src calls undefined behaviour #1589
I have an open php-src PR, php/php-src#24153, that makes the $name and $class properties of Reflection objects throw a ReflectionException on compound assignment, ++/-- and by-reference writes. Plain assignment already throws today. It targets master only.
The PR leaves unset() alone, so nothing changes for BetterReflection yet. But the adapters unset these properties in their constructors and serve them through __get, for example:
The same pattern is in ReflectionMethod, ReflectionClassConstant, ReflectionFunction, ReflectionParameter, ReflectionAttribute, ReflectionObject, ReflectionEnum and the enum case adapters.
During review, ndossche mentioned that BetterReflection depends on this, and kamil-tekiela replied that unsetting these properties is undefined behaviour and BetterReflection should move away from it. So a later php-src change may restrict unset() as well, and these constructors would then fail.
Opening this so you hear about it early. If you want to move the adapters off this trick, I'm happy to help with a PR.
Note: it may be possible to try and use PHP 8.4 proxies to work around the current logic, but it's just experimentation, and there's no clear path forward known upfront
Activity
kukulich commentedon Oct 18, 2026
@lazerg Thank you for the info.
The reason fot the use is descripted here: #673
Ocramius commentedon Oct 18, 2026
No, it is well defined behavior, for which I introduced tests in PHP-SRC over a decade ago.
Additionally,
unset()behavior is regularly discussed on RFCs pertinent to property access logic.Ocramius commentedon Oct 18, 2026
Note: it may be possible to try and use PHP 8.4 proxies to work around the current logic, but it's just experimentation, and there's no clear path forward known upfront
lazerg commentedon Oct 19, 2026
Closing this. The php-src PR that prompted it is closed, so nothing changes for BetterReflection. Sorry for the noise.