reference caller object

From: Date: Wed, 16 Sep 2009 20:59:16 +0000
Subject: reference caller object
Groups: php.internals 
Request: Send a blank email to internals+get-45580@lists.php.net to get a copy of this message
(Please direct me elsewhere if necessary, this is a feature request) It would be handy to allow a method to behave differently based on who is calling it. the function I am looking for would essentially do this: function getCaller(){ $bt = debug_backtrace(); return $bt[2]['object']; } But of course, there is a lot of uneccessary processing with that call. Perhaps it could be implimented similar to "self" and "parent" (actualy more like "static") keywords. So you could do: public function registerMe() { if( ! (caller instanceof 'my_interface')) throw new dev_execption(); if( ! ($this->authenticateMod(caller))) throw new admin_exception('module not active'); $this->loadedMods[caller->module_id()] = caller; return caller->onLoad(); } Chris Trahey Web Applications Developer Database Administrator CSISD [Technology]

« previous php.internals (#45580) next »