From 070717dbdb59b4790505e672efae044f734e5e7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 15 Dec 2020 17:35:51 +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/Dispatch/Dispatch.php | 4 ++-- HttpServer/Route/Middleware.php | 4 ++-- HttpServer/Route/Node.php | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/HttpServer/Route/Dispatch/Dispatch.php b/HttpServer/Route/Dispatch/Dispatch.php index be0fbc6d..4edc9597 100644 --- a/HttpServer/Route/Dispatch/Dispatch.php +++ b/HttpServer/Route/Dispatch/Dispatch.php @@ -45,9 +45,9 @@ class Dispatch * @return mixed * 执行函数 */ - public function dispatch() + public function dispatch(): mixed { - return call_user_func($this->handler, $this->request); + return call_user_func($this->handler, ...$this->request); } diff --git a/HttpServer/Route/Middleware.php b/HttpServer/Route/Middleware.php index ae45d40b..fd4d9b4f 100644 --- a/HttpServer/Route/Middleware.php +++ b/HttpServer/Route/Middleware.php @@ -51,8 +51,8 @@ class Middleware */ public function getGenerate(Node $node): mixed { - return $node->callback = Reduce::reduce(function ($passable) use ($node) { - return Dispatch::create($node->handler, $passable)->dispatch(); + return $node->callback = Reduce::reduce(function () use ($node) { + return Dispatch::create($node->handler, func_get_args())->dispatch(); }, $this->annotation($node)); } diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index 16bf5697..8954f78f 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -409,6 +409,7 @@ class Node extends Application if (empty($this->handler)) { return $this; } + /** @var Middleware $made */ $made = Snowflake::createObject(Middleware::class); $made->setMiddleWares($this->middleware); $made->getGenerate($this);