Obligation of callable arguments

This commit is contained in:
Shoghi Cervantes Pueyo 2012-12-26 13:46:09 +01:00
parent 28048db141
commit d90f317590
2 changed files with 6 additions and 9 deletions

View File

@ -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);
}

View File

@ -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;
}