From aa9c6cc919fa5a0952302d9c51f2d59a09beefba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=97=E5=B1=B1=E5=90=B4=E5=BD=A6=E7=A5=96?= Date: Thu, 14 Mar 2019 15:49:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dhandler=E8=B0=83=E7=94=A8meth?= =?UTF-8?q?od=E6=97=B6=E6=96=B9=E6=B3=95=E4=B8=8D=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E6=97=B6=E6=8A=9B=E5=87=BA=E5=BC=82=E5=B8=B8=E7=AD=89=E7=BA=A7?= =?UTF-8?q?=E8=BF=87=E4=BD=8E=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Handler.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Handler.php b/src/Handler.php index 60a9456..c12826b 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -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]}()"); } }