.
This commit is contained in:
commit
a5ce423afe
30 changed files with 1807 additions and 0 deletions
32
tests/Classes/ConfigurableClass.php
Normal file
32
tests/Classes/ConfigurableClass.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Classes;
|
||||
|
||||
use Tests\Aspects\ConfigurableAspect;
|
||||
|
||||
class ConfigurableClass
|
||||
{
|
||||
#[ConfigurableAspect(prefix: 'PREFIX:', multiplier: 10)]
|
||||
public function customConfigMethod(): string
|
||||
{
|
||||
return 'value';
|
||||
}
|
||||
|
||||
#[ConfigurableAspect(prefix: 'BEFORE_', multiplier: 5)]
|
||||
public function anotherMethod(): int
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
#[ConfigurableAspect(enabled: false)]
|
||||
public function disabledMethod(): string
|
||||
{
|
||||
return 'should not be modified';
|
||||
}
|
||||
|
||||
#[ConfigurableAspect] // Uses default values
|
||||
public function defaultConfigMethod(): int
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
26
tests/Classes/ModifyingClass.php
Normal file
26
tests/Classes/ModifyingClass.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Classes;
|
||||
|
||||
use Tests\Aspects\ModifyingAspect;
|
||||
|
||||
class ModifyingClass
|
||||
{
|
||||
#[ModifyingAspect]
|
||||
public function getValue(): int
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
|
||||
#[ModifyingAspect]
|
||||
public function getString(): string
|
||||
{
|
||||
return 'original';
|
||||
}
|
||||
|
||||
#[ModifyingAspect]
|
||||
public function getArray(): array
|
||||
{
|
||||
return ['key' => 'value'];
|
||||
}
|
||||
}
|
||||
66
tests/Classes/ParameterTypesClass.php
Normal file
66
tests/Classes/ParameterTypesClass.php
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Classes;
|
||||
|
||||
use Tests\Aspects\TrackingAspect;
|
||||
|
||||
class ParameterTypesClass
|
||||
{
|
||||
#[TrackingAspect]
|
||||
public function withNullable(?string $value): ?string
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
#[TrackingAspect]
|
||||
public function withVariadic(string ...$items): array
|
||||
{
|
||||
return $items;
|
||||
}
|
||||
|
||||
#[TrackingAspect]
|
||||
public function withReference(int &$counter): void
|
||||
{
|
||||
$counter++;
|
||||
}
|
||||
|
||||
#[TrackingAspect]
|
||||
public function withUnionType(int|string $value): int|string
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
#[TrackingAspect]
|
||||
public function withMixed(mixed $data): mixed
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
|
||||
#[TrackingAspect]
|
||||
public function withArray(array $data): array
|
||||
{
|
||||
return array_merge($data, ['processed' => true]);
|
||||
}
|
||||
|
||||
#[TrackingAspect]
|
||||
public function withDefaultValues(string $name = 'default', int $age = 0): string
|
||||
{
|
||||
return "$name:$age";
|
||||
}
|
||||
|
||||
#[TrackingAspect]
|
||||
public function voidReturn(): void
|
||||
{
|
||||
}
|
||||
|
||||
#[TrackingAspect]
|
||||
protected function protectedMethod(string $value): string
|
||||
{
|
||||
return strtoupper($value);
|
||||
}
|
||||
|
||||
public function callProtected(string $value): string
|
||||
{
|
||||
return $this->protectedMethod($value);
|
||||
}
|
||||
}
|
||||
33
tests/Classes/StackedAspectsClass.php
Normal file
33
tests/Classes/StackedAspectsClass.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Classes;
|
||||
|
||||
use Tests\Aspects\BasicAspect;
|
||||
use Tests\Aspects\LoggingAspect;
|
||||
|
||||
class StackedAspectsClass
|
||||
{
|
||||
#[BasicAspect]
|
||||
#[LoggingAspect]
|
||||
public function multipleAspects(int $value, object $tracker): int
|
||||
{
|
||||
return $value * 2;
|
||||
}
|
||||
|
||||
#[BasicAspect]
|
||||
public function onlyBasic(int $value, object $tracker): int
|
||||
{
|
||||
return $value + 1;
|
||||
}
|
||||
|
||||
#[LoggingAspect]
|
||||
public function onlyLogging(string $message): string
|
||||
{
|
||||
return strtoupper($message);
|
||||
}
|
||||
|
||||
public function noAspects(): string
|
||||
{
|
||||
return 'plain';
|
||||
}
|
||||
}
|
||||
14
tests/Classes/ThrowingClass.php
Normal file
14
tests/Classes/ThrowingClass.php
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Classes;
|
||||
|
||||
use Tests\Aspects\ThrowingAspect;
|
||||
|
||||
class ThrowingClass
|
||||
{
|
||||
#[ThrowingAspect]
|
||||
public function methodWithAspect(): string
|
||||
{
|
||||
return 'success';
|
||||
}
|
||||
}
|
||||
14
tests/Classes/WrappedClass.php
Normal file
14
tests/Classes/WrappedClass.php
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Classes;
|
||||
|
||||
use Tests\Aspects\BasicAspect;
|
||||
|
||||
class WrappedClass
|
||||
{
|
||||
#[BasicAspect]
|
||||
public function wrappedMethod(int $a, int $b, object $sideEffect): int
|
||||
{
|
||||
return $a + $b;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue