diff --git a/src/aop/src/Collectors/AspectCollector.php b/src/aop/src/Collectors/AspectCollector.php index f8cd6e39..a916d6af 100644 --- a/src/aop/src/Collectors/AspectCollector.php +++ b/src/aop/src/Collectors/AspectCollector.php @@ -69,7 +69,7 @@ public static function getMethodAspects(string $class, string $method): array /** * 返回被收集过的类. * - * @return AspectInterface[] + * @return string[] */ public static function getCollectedClasses(): array { diff --git a/src/aop/src/Collectors/PropertyAttributeCollector.php b/src/aop/src/Collectors/PropertyAttributeCollector.php index 614a0fa4..d9f1599b 100644 --- a/src/aop/src/Collectors/PropertyAttributeCollector.php +++ b/src/aop/src/Collectors/PropertyAttributeCollector.php @@ -47,6 +47,8 @@ public static function getPropertyAttribute(string $class, string $property): ar /** * 返回收集过的类. + * + * @return string[] */ public static function getCollectedClasses(): array { diff --git a/src/aop/src/ProxyHandler.php b/src/aop/src/ProxyHandler.php index 1203d2f0..2cedb472 100644 --- a/src/aop/src/ProxyHandler.php +++ b/src/aop/src/ProxyHandler.php @@ -16,7 +16,6 @@ use Max\Aop\Collectors\AspectCollector; use Max\Aop\Contracts\AspectInterface; use Max\Di\Reflection; -use Max\Utils\Pipeline; use ReflectionException; trait ProxyHandler @@ -30,13 +29,14 @@ protected static function __callViaProxy(string $method, Closure $callback, arra /** @var AspectInterface $aspect */ $pipeline = array_reduce( array_reverse(AspectCollector::getMethodAspects($class, $method)), - fn($stack, $aspect) => fn(JoinPoint $joinPoint) => $aspect->process($joinPoint, $stack), - fn(JoinPoint $joinPoint) => $joinPoint->process() - ); - return $pipeline( - new JoinPoint($class, $method, new ArrayObject( - array_combine(Reflection::methodParameterNames($class, $method), $parameters) - ), $callback) + fn ($stack, $aspect) => fn (JoinPoint $joinPoint) => $aspect->process($joinPoint, $stack), + fn (JoinPoint $joinPoint) => $joinPoint->process() ); + $funcArgs = new ArrayObject(); + $methodParameters = Reflection::methodParameterNames($class, $method); + foreach ($parameters as $key => $parameter) { + $funcArgs->offsetSet($methodParameters[$key], $parameter); + } + return $pipeline(new JoinPoint($class, $method, $funcArgs, $callback)); } }