Skip to content

Commit

Permalink
修复handler调用method时方法不存在时抛出异常等级过低问题
Browse files Browse the repository at this point in the history
  • Loading branch information
anoxia committed Mar 14, 2019
1 parent 947de76 commit aa9c6cc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,17 @@ public function getRoutePattern(): string
* @param $application
* @param mixed $parameters
* @return mixed
* @throws Exception
*/
public function callMethod($application, $parameters = null)
{
$class = new $this->handler[0];
$class->setApp($application);

return call_user_func([$class, $this->handler[1]], $parameters);
if (method_exists($class, $this->handler[1])) {
$class->setApp($application);
return call_user_func([$class, $this->handler[1]], $parameters);
}

throw new Exception("Call to undefined method {$this->handler[0]}::{$this->handler[1]}()");
}
}

0 comments on commit aa9c6cc

Please sign in to comment.