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
Hooks scoping: accessing the backing value of a property from a method called from a hook on that property must throw an Error, but infinite loop instead.
#18818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
But I expected triggering an error, as said in documentation, instead:
If a hook calls a method that in turn tries to read or write from the property again, that would normally result in an infinite loop. To prevent that, accessing the backing value of a property from a method called from a hook on that property will throw an Error. That is somewhat different than the existing behavior of __get and __set, where such sub-called methods would bypass the magic methods. However, as valid use cases for such circular logic are difficult to identify and there is added risk of confusion with dynamic properties, we have elected to simply block that access entirely.
PHP Version
PHP 8.4.5
Operating System
No response
The text was updated successfully, but these errors were encountered:
Description
The following code:
Resulted in this output (an infinite loop:):
But I expected triggering an error, as said in documentation, instead:
PHP Version
Operating System
No response
The text was updated successfully, but these errors were encountered: