From d90f317590e6f24db1f6797f865c57de371c54bc Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Wed, 26 Dec 2012 13:46:09 +0100 Subject: [PATCH] Obligation of callable arguments --- classes/API/ConsoleAPI.php | 2 +- classes/PocketMinecraftServer.class.php | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/classes/API/ConsoleAPI.php b/classes/API/ConsoleAPI.php index 685e50c3d..939214c79 100644 --- a/classes/API/ConsoleAPI.php +++ b/classes/API/ConsoleAPI.php @@ -221,7 +221,7 @@ class ConsoleAPI{ } } - public function register($cmd, $help, $callback){ + public function register($cmd, $help,callable $callback){ $this->help[strtolower(trim($cmd))] = array($help, $callback); } diff --git a/classes/PocketMinecraftServer.class.php b/classes/PocketMinecraftServer.class.php index 358fb1ee9..2fa72426a 100644 --- a/classes/PocketMinecraftServer.class.php +++ b/classes/PocketMinecraftServer.class.php @@ -86,8 +86,8 @@ class PocketMinecraftServer extends stdClass{ } public function loadEvents(){ - $this->event("server.chat", "eventHandler", true); - $this->event("player.new", "eventHandler", true); + $this->event("server.chat", array($this, "eventHandler")); + $this->event("player.new", array($this, "eventHandler")); $this->action(500000, '$this->time += (int) ($this->timePerSecond / 2);$this->trigger("server.time.change", $this->time);'); $this->action(5000000, 'if($this->difficulty < 2){$this->trigger("server.regeneration", 1);}'); @@ -181,7 +181,7 @@ class PocketMinecraftServer extends stdClass{ } - public function addHandler($event, $callable, $priority = 5){ + public function addHandler($event, callable $callable, $priority = 5){ if(!is_callable($callable)){ return false; } @@ -475,7 +475,7 @@ class PocketMinecraftServer extends stdClass{ return false; } - public function schedule($ticks, $callback, $data = array(), $repeat = false, $eventName = "server.schedule"){ + public function schedule($ticks, callable $callback, $data = array(), $repeat = false, $eventName = "server.schedule"){ if(!is_callable($callback)){ return false; } @@ -516,10 +516,7 @@ class PocketMinecraftServer extends stdClass{ $this->preparedSQL->updateActions->execute(); } - public function event($event, $func, $in = false){ - if($in === true){ - $func = array($this, $func); - } + public function event($event,callable $func){ if(!is_callable($func)){ return false; }