This commit is contained in:
as2252258@163.com
2021-03-29 03:23:05 +08:00
parent 796b819fe5
commit dbaa7eb73c
+6 -4
View File
@@ -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;
}