Skip to content

Commit

Permalink
Merge pull request #11 from topyao/master
Browse files Browse the repository at this point in the history
细节修复
  • Loading branch information
bbuugg authored Jul 15, 2022
2 parents a53113e + 8e47d93 commit bef163b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/aop/src/Collectors/AspectCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static function getMethodAspects(string $class, string $method): array
/**
* 返回被收集过的类.
*
* @return AspectInterface[]
* @return string[]
*/
public static function getCollectedClasses(): array
{
Expand Down
2 changes: 2 additions & 0 deletions src/aop/src/Collectors/PropertyAttributeCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public static function getPropertyAttribute(string $class, string $property): ar

/**
* 返回收集过的类.
*
* @return string[]
*/
public static function getCollectedClasses(): array
{
Expand Down
16 changes: 8 additions & 8 deletions src/aop/src/ProxyHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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));
}
}

0 comments on commit bef163b

Please sign in to comment.