AspectContext

This commit is contained in:
icefox 2026-01-06 11:41:55 -03:00
parent 6050e3bb72
commit d35c3df06d
No known key found for this signature in database
8 changed files with 70 additions and 19 deletions

View file

@ -3,18 +3,24 @@
namespace Tests\Aspects;
use Attribute;
use IceFox\Aspect\AspectContext;
#[Attribute(Attribute::TARGET_METHOD)]
class TrackingAspect
{
public static array $calls = [];
public function before(object|string $target, mixed ...$args): void
public function __construct(
private readonly AspectContext $context,
) {
}
public function before(mixed ...$args): void
{
self::$calls[] = ['event' => 'before', 'args' => $args];
}
public function after(object|string $target, mixed $result): mixed
public function after(mixed $result): mixed
{
self::$calls[] = ['event' => 'after', 'result' => $result];
return $result;