.
This commit is contained in:
commit
a5ce423afe
30 changed files with 1807 additions and 0 deletions
34
tests/Aspects/ThrowingAspect.php
Normal file
34
tests/Aspects/ThrowingAspect.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Aspects;
|
||||
|
||||
use Attribute;
|
||||
use RuntimeException;
|
||||
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class ThrowingAspect
|
||||
{
|
||||
public static bool $throwInBefore = false;
|
||||
public static bool $throwInAfter = false;
|
||||
|
||||
public function before(object|string $target, mixed ...$args): void
|
||||
{
|
||||
if (self::$throwInBefore) {
|
||||
throw new RuntimeException('Exception thrown in before()');
|
||||
}
|
||||
}
|
||||
|
||||
public function after(object|string $target, mixed $result): mixed
|
||||
{
|
||||
if (self::$throwInAfter) {
|
||||
throw new RuntimeException('Exception thrown in after()');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function reset(): void
|
||||
{
|
||||
self::$throwInBefore = false;
|
||||
self::$throwInAfter = false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue