On 16-03-2021 02:37, Katie Volz wrote: > I was able to get a proof of concept of the following at > https://github.com/iggyvolz/hooks:
That looks like a nice starting point to explore how this could work. I use decorators a lot in Python code and would love to see something similar in PHP. One thing I am wondering though: How does this affect the debugging experience of PHP code? Suppose that I am step debugging and I step into a function call. When that function happens to be decorated, I can imagine two possible scenarios: 1. The debugger enters the decorator function, not the called function. 2. The debugger jumps to the entry point of the called function first, then to the decorator function. When exiting the decorator function, it jumps back to the entry point of the called function again. I guess that using an observer results in scenario 1. This would yield a confusing debugging experience. At the call site, you cannot see that the function is decorated. You expect to enter the called function but the debugger will jump some place else. Even worse when multiple decorators are stacked. Note that Python decorators also make the debugger jump straight into the decorator. While this is not nice, it is expected because a Python decorator actually replaces the original function at run time. A PHP implementation would probably not do that, so maybe it could actually work like in scenario 2? Regards, Dik Takken -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php