From b6c81b2b78feb74f70bad51d1075a4536da584a5 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 19 Jul 2016 11:15:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=8E=A7=E5=88=B6=E5=99=A8?= =?UTF-8?q?=E7=9A=84=E7=A9=BA=E6=93=8D=E4=BD=9C=E6=96=B9=E6=B3=95=E8=B0=83?= =?UTF-8?q?=E7=94=A8=20=E6=94=B9=E8=BF=9BRest=E6=8E=A7=E5=88=B6=E5=99=A8?= =?UTF-8?q?=E7=9A=84=5Fempty=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/App.php | 7 ++++--- library/think/controller/Rest.php | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/library/think/App.php b/library/think/App.php index 24163372..9ff748df 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -337,9 +337,10 @@ class App } catch (\ReflectionException $e) { // 操作不存在 if (method_exists($instance, '_empty')) { - $method = new \ReflectionMethod($instance, '_empty'); - $data = $method->invokeArgs($instance, [$action, '']); - self::$debug && Log::record('[ RUN ] ' . $method->__toString(), 'info'); + $reflect = new \ReflectionMethod($instance, '_empty'); + $args = self::bindParams($reflect, Request::instance()->param()); + $data = $reflect->invokeArgs($instance, [$action, $args]); + self::$debug && Log::record('[ RUN ] ' . $reflect->__toString(), 'info'); } else { throw new HttpException(404, 'method not exists:' . (new \ReflectionClass($instance))->getName() . '->' . $action); } diff --git a/library/think/controller/Rest.php b/library/think/controller/Rest.php index a58743b3..a5288092 100644 --- a/library/think/controller/Rest.php +++ b/library/think/controller/Rest.php @@ -11,8 +11,8 @@ namespace think\controller; -use think\Response; use think\Request; +use think\Response; abstract class Rest { @@ -38,7 +38,7 @@ abstract class Rest { // 资源类型检测 $request = Request::instance(); - $ext = $request->ext(); + $ext = $request->ext(); if ('' == $ext) { // 自动检测资源类型 $this->type = $request->type(); @@ -76,7 +76,7 @@ abstract class Rest $fun = $method . '_' . $this->method; } if (isset($fun)) { - return $this->$fun(); + return call_user_func_array([$this, $fun], $args); } else { // 抛出异常 throw new \Exception('error action :' . $method);