From 69e41f459702d7cb40e1accc5c94c22aeca68ca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 12 Jul 2021 18:54:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpServer/Route/Node.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index d7778fbd..41d485db 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -126,12 +126,14 @@ class Node extends HttpService */ public function createDispatch(): Closure { - return static function () { + $application = $this; + return static function () use ($application) { $dispatchParam = Context::getContext('dispatch-param', [\request()]); - if (empty($this->_aop) || $this->handler instanceof Closure) { - return call_user_func($this->handler, ...$dispatchParam); + if (empty($application->_aop) || $application->handler instanceof Closure) { + return call_user_func($application->handler, ...$dispatchParam); } - return call_user_func($this->_aop[0], $this->_aop[1], $dispatchParam); + $application->_aop[] = $dispatchParam; + return call_user_func(...$application->_aop); }; } @@ -148,10 +150,10 @@ class Node extends HttpService return; } $reflect = $aop->getAop($this->handler); - - $method = $reflect->getMethod('invoke'); - - $this->_aop = [[$method, 'invokeArgs'], $reflect->newInstance($this->handler)]; + $this->_aop = [ + [$reflect->getMethod('invoke'), 'invokeArgs'], + $reflect->newInstance($this->handler) + ]; }