Hi Aleksander

>> https://wiki.php.net/rfc/pass_scope_to_magic_accessors
> 
> Why not a new function, e.g. func_call_scope()? It could work 
> everywhere, not only in magic methods.
> 
> I guess it would be tricky with calls to the parent magic method when 
> you need the "outer calling scope", but I'd like to see some reasoning 
> in the RFC.
> 
> -- 
> Aleksander Machniak

This has been suggested before and we're consider it. Here's a
comparable PHP implementation.

https://3v4l.org/6Ua8t

This would only work when called directly from the magic method but that
seems appropriate given that you'd also have to pass $callingScope to
any function requiring it.

Nicolas has noted that this would make it impossible to pass something
other than the actual calling scope to parent::__get(). It's not clear
yet whether there's a use case for that.

---

Hi Marco

> Not just that, but `debug_backtrace()` already exists for that purpose.

As mentioned in the RFC and the last e-mail, yes this can be achieved
via debug_backtrace(). However, as demonstrated by the 3v4l, it's not
exactly trivial. It also requires the full stack trace, as well as all
frame objects and arguments. That's not going to be great for
performance. So saying debug_backtrace() exists for this purpose is
misleading, to say the least.

Ilija

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to