From dbaa7eb73c2a8c7dec2a062601dfd35da7cea957 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Mon, 29 Mar 2021 03:23:05 +0800 Subject: [PATCH] modify --- System/Aop.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/System/Aop.php b/System/Aop.php index 426cf69c..2b07a10d 100644 --- a/System/Aop.php +++ b/System/Aop.php @@ -42,11 +42,13 @@ class Aop extends Component final public function dispatch() { $get_args = func_get_args(); - [$class, $method] = array_shift($get_args); + if (($close = array_shift($get_args)) instanceof \Closure) { + return call_user_func($close, ...$get_args); + } - $aopName = get_class($class) . '::' . $method; + $aopName = get_class($close[0]) . '::' . $close[1]; if (!isset($this->_aop[$aopName])) { - return call_user_func($get_args, ...$get_args); + return call_user_func($close, ...$get_args); } $reflect = new \ReflectionClass($this->_aop[$aopName]); @@ -55,7 +57,7 @@ class Aop extends Component } $method = $reflect->getMethod('invoke'); - $data = $method->invokeArgs($reflect->newInstance([$class, $method]), $get_args); + $data = $method->invokeArgs($reflect->newInstance($close), $get_args); if ($method->getReturnType() !== null) { return $data; }