.
This commit is contained in:
commit
a5ce423afe
30 changed files with 1807 additions and 0 deletions
24
tests/Aspects/ModifyingAspect.php
Normal file
24
tests/Aspects/ModifyingAspect.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Aspects;
|
||||
|
||||
use Attribute;
|
||||
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class ModifyingAspect
|
||||
{
|
||||
public static mixed $modifier = null;
|
||||
|
||||
public function after(object|string $target, mixed $result): mixed
|
||||
{
|
||||
if (self::$modifier !== null) {
|
||||
return (self::$modifier)($result);
|
||||
}
|
||||
return $result; // Return original value when not modifying
|
||||
}
|
||||
|
||||
public static function reset(): void
|
||||
{
|
||||
self::$modifier = null;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue