From 017a5b19dc13a2f39aca6092c2eb73b15876a230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 20 Apr 2021 11:56:01 +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 | 8 ++++---- HttpServer/Route/Reduce.php | 7 +------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index 206e10cb..40c7b508 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -529,14 +529,14 @@ class Node extends HttpService private function httpFilter(): mixed { try { - $dispatchParams = func_num_args(); + $dispatchParams = func_get_args(); if (empty($dispatchParams)) { - $dispatchParams = \request(); + $dispatchParams = [\request()]; } if ($this->handler instanceof Closure) { - return call_user_func($this->handler, $dispatchParams); + return call_user_func($this->handler, ...$dispatchParams); } - return $this->runWith($this->callback, $dispatchParams); + return $this->runWith($this->callback, ...$dispatchParams); return $this->runFilter(...$dispatchParams); } catch (Throwable $throwable) { $this->addError($throwable, 'throwable'); diff --git a/HttpServer/Route/Reduce.php b/HttpServer/Route/Reduce.php index b8b81452..010dd67c 100644 --- a/HttpServer/Route/Reduce.php +++ b/HttpServer/Route/Reduce.php @@ -6,7 +6,6 @@ namespace HttpServer\Route; use Closure; use HttpServer\IInterface\After; -use HttpServer\IInterface\Middleware; use Snowflake\Core\Json; class Reduce @@ -53,11 +52,7 @@ class Reduce { return function ($stack, $pipe) { return function ($passable) use ($stack, $pipe) { - if ($pipe instanceof Middleware) { - return $pipe->onHandler($passable, $stack); - } else { - return call_user_func($pipe, $passable, $stack); - } + return call_user_func($pipe, $passable, $stack); }; }; }