before params as associative array

This commit is contained in:
icefox 2026-01-07 12:06:14 -03:00
parent d35c3df06d
commit 6946059f07
No known key found for this signature in database
11 changed files with 154 additions and 8 deletions

View file

@ -0,0 +1,35 @@
<?php
namespace Tests\Aspects;
use Attribute;
use IceFox\Aspect\AspectContext;
#[Attribute(Attribute::TARGET_METHOD)]
class ParameterKeyAspect
{
public static array $capturedKeys = [];
public static array $capturedArgs = [];
public function __construct(
private readonly AspectContext $context,
) {
}
public function before(array $args): void
{
self::$capturedKeys = array_keys($args);
self::$capturedArgs = $args;
}
public function after(mixed $result): mixed
{
return $result;
}
public static function reset(): void
{
self::$capturedKeys = [];
self::$capturedArgs = [];
}
}