From 5cf3596c92d993e18ea393b2028d74389195ce69 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Wed, 21 Apr 2021 01:42:43 +0800 Subject: [PATCH] modify --- System/Aop.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/System/Aop.php b/System/Aop.php index 04945a13..4a843226 100644 --- a/System/Aop.php +++ b/System/Aop.php @@ -47,19 +47,18 @@ class Aop extends Component * @throws ReflectionException * @throws Exception */ - final public function dispatch(): mixed + final public function dispatch($handler, ...$params): mixed { - $get_args = func_get_args(); - if (($close = array_shift($get_args)) instanceof \Closure) { - return call_user_func($close, ...$get_args); + if ($handler instanceof \Closure) { + return call_user_func($handler, ...$params); } - $aopName = get_class($close[0]) . '::' . $close[1]; + $aopName = get_class($handler) . '::' . $handler; if (!isset($this->_aop[$aopName])) { - if (!method_exists($close[0], $close[1])) { + if (!method_exists($handler[0], $handler[1])) { return response()->close(404); } - return call_user_func($close, ...$get_args); + return call_user_func($handler, ...$params); } $reflect = Snowflake::getDi()->getReflect(current($this->_aop[$aopName])); @@ -68,7 +67,7 @@ class Aop extends Component } $method = $reflect->getMethod('invoke'); - return $method->invokeArgs($reflect->newInstance($close), $get_args); + return $method->invokeArgs($reflect->newInstance($handler), $params); }