Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
biiiiiigmonster committed Jun 9, 2021
1 parent 597e47a commit b904a57
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 27 deletions.
8 changes: 4 additions & 4 deletions src/AspectHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __invoke(Pointer $pointer): mixed

try {
// Execute Around
$pointer->setValue(
$pointer->setReturn(
$around ? $around->invoke($aspectInstance, $pointer) : $pointer->process()
);
} catch (Throwable $throwable) {
Expand All @@ -49,16 +49,16 @@ public function __invoke(Pointer $pointer): mixed
if ($pointer->getThrowable()) {
// Execute AfterThrowing
if ($afterThrowing) {
$pointer->setValue($afterThrowing->invoke($aspectInstance, $pointer->getThrowable(), $pointer));
$pointer->setReturn($afterThrowing->invoke($aspectInstance, $pointer->getThrowable(), $pointer));
} else {
throw $pointer->getThrowable();
}
} else {
// Execute AfterReturning
if ($afterReturning) $pointer->setValue($afterReturning->invoke($aspectInstance, $pointer));
if ($afterReturning) $pointer->setReturn($afterReturning->invoke($aspectInstance, $pointer));
}

return $pointer->getValue();
return $pointer->getReturn();
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/Concerns/AopTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public static function __onion(array $skins): Closure
$through = fn(Closure $stack, array $skin) => function (Pointer $pointer) use ($stack, $skin) {
$aspectHandler = new AspectHandler();
$pointer->into($skin);
$pointer->setHandler($aspectHandler);
$pointer->setTarget($stack);
$aspectHandler($pointer);
};
Expand Down
33 changes: 12 additions & 21 deletions src/Concerns/Pointer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,43 @@

abstract class Pointer
{
protected AspectHandler $handler;
protected Closure $target;
protected mixed $value;
protected array $types;
protected mixed $return;
protected array $returnTypes;
protected ?Throwable $throwable = null;
protected ?object $curAspectInstance = null;// 当前所处切面实例
protected ?object $curAttributeInstance = null;// 当前所处注解实例

/**
* @return mixed
*/
public function getValue(): mixed
public function getReturn(): mixed
{
return $this->value;
return $this->return;
}

/**
* @param mixed $value
* @param mixed $return
*/
public function setValue(mixed $value): void
public function setReturn(mixed $return): void
{
$this->value = $value;
$this->return = $return;
}

/**
* @return array
*/
public function getTypes(): array
public function getReturnTypes(): array
{
return $this->types;
return $this->returnTypes;
}

/**
* @param array $types
* @param array $returnTypes
*/
public function setTypes(array $types): void
public function setReturnTypes(array $returnTypes): void
{
$this->types = $types;
$this->returnTypes = $returnTypes;
}

/**
Expand Down Expand Up @@ -88,14 +87,6 @@ public function setTarget(Closure $target): void
$this->target = $target;
}

/**
* @param AspectHandler $handler
*/
public function setHandler(AspectHandler $handler): void
{
$this->handler = $handler;
}

/**
* @param array $skin
* @return Pointer
Expand Down
2 changes: 1 addition & 1 deletion src/Point/FunctionPointer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(
// Parse ReflectionMethod Data.
$methodRfc = new ReflectionMethod($className, $method);
$this->argsMap = $this->parseArgsMap($methodRfc);
$this->types = $this->parseReturnType($methodRfc);
$this->returnTypes = $this->parseReturnType($methodRfc);
}

/**
Expand Down

0 comments on commit b904a57

Please sign in to comment.