Is it possible to get method who called an function for example: PHP: public function sendName(Player $player){ // line 1$player->sendMessage('Your name is: '.$this->getPlayerName($player));}public function getPlayerName(Player $player){return $player->getName();echo __CALLER__;// __CALLER__ ... Is function from where this function was called from. // outputs ex: Main::sendName(Player $player), at line: 1}
Sometimes in events i got error that is in other method not in $this - scope! i want to know what event has used that function where it crashed. I hope you can understand it
PHP: public function onDeath(...){$player = $event->getPlayer()->getName(); // I get string to make an error$this->owner->isInTeam($player); // Where the error will be shown}class Main {public function isInTeam($player){ // not (Player $player)return in_array($player->getName(), $this->game, true); // ERROR_SOURCE}
http://stackoverflow.com/questions/2110732/how-to-get-name-of-calling-function-method-in-php You can use similar method to get the arguments in them. Yet, it is extremely bad practice to do so. It is also possible to store the current processing player object into a field and get it from your function, but I believe this is more trouble than convenience.