RE: [PHP-DEV] Use "caller" keyword, to access object caller.
| From: | François Laupretre | Date: | Fri, 30 Jan 2015 06:51:12 +0000 |
| Subject: | RE: [PHP-DEV] Use "caller" keyword, to access object caller. | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-81404@lists.php.net to get a copy of this message | ||
> De : Larry Garfield [mailto:larry@garfieldtech.com]
>
> Having an object that behaves differently depending on an implicit
> relationship with where it happened to be called from is full of all
> kinds of impossible to debug magic. I don't even know how you'd unit
> test it. I can think of no use case where this wouldn't cause only
> problems.
The only use case I can think of is to enforce access restriction (an alternative to
'friend' classes), faster than using debug_backtrace(). But I would prefer really
implementing friend classes/namespaces.
@S.A.N: you can already determine the caller using debug_backtrace(). Slow and inconvenient, but it
works.
Regards
François