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);