I would like to know from where a global function or public method is being called. I guess I could do it by inspecting debug_backtrace but I'd rather use a lighterweight mechanism if one exists. Any suggestions?
For example something like so, if you imagine the get_callee() function and constant existing:
function doSomething() {
if(get_callee() == 'PHP_GLOBAL') { throw new IllegalAccessException(); }
...
}