diff --git a/docs/pages/getting_started.md b/docs/pages/getting_started.md index 07ed91b37..344c683b6 100644 --- a/docs/pages/getting_started.md +++ b/docs/pages/getting_started.md @@ -159,12 +159,12 @@ use Doctrine\DBAL\Connection; use Patchlevel\EventSourcing\Attribute\Create; use Patchlevel\EventSourcing\Attribute\Drop; use Patchlevel\EventSourcing\Attribute\Subscribe; -use Patchlevel\EventSourcing\Attribute\Projection; +use Patchlevel\EventSourcing\Attribute\Projector; use Patchlevel\EventSourcing\EventBus\Message; use Patchlevel\EventSourcing\Projection\Projection\ProjectionId; use Patchlevel\EventSourcing\Projection\Projector\ProjectorUtil; -#[Projection('hotel')] +#[Projector('hotel')] final class HotelProjector { use ProjectorUtil; diff --git a/docs/pages/projection.md b/docs/pages/projection.md index c71c6c987..64db04044 100644 --- a/docs/pages/projection.md +++ b/docs/pages/projection.md @@ -18,11 +18,11 @@ use Doctrine\DBAL\Connection; use Patchlevel\EventSourcing\Attribute\Create; use Patchlevel\EventSourcing\Attribute\Drop; use Patchlevel\EventSourcing\Attribute\Subscribe; -use Patchlevel\EventSourcing\Attribute\Projection; +use Patchlevel\EventSourcing\Attribute\Projector; use Patchlevel\EventSourcing\EventBus\Message; use Patchlevel\EventSourcing\Projection\Projector\ProjectorUtil; -#[Projection('profile')] +#[Projector('profile')] final class ProfileProjector { use ProjectorUtil; @@ -81,7 +81,7 @@ final class ProfileProjector Each projector is responsible for a specific projection and version. This combination of information results in the so-called `project ID`. -In order for us to be able to define this, we have to use the `Projection` attribute. +In order for us to be able to define this, we have to use the `Projector` attribute. In our example, the projection is called "profile" and has the version "0" because we did not specify it. So that there is no problems with existing projection, both the name of the projection and the version should be part of the table/collection name. @@ -114,17 +114,17 @@ Several projectors can also listen to the same event. As soon as the structure of a projection changes, the version must be change or increment. Otherwise the projectionist will not recognize that the projection has changed and will not rebuild it. -To do this, you have to change the version in the `Projection` attribute. +To do this, you have to change the version in the `Projector` attribute. ```php use Doctrine\DBAL\Connection; use Patchlevel\EventSourcing\Attribute\Create; use Patchlevel\EventSourcing\Attribute\Drop; use Patchlevel\EventSourcing\Attribute\Handle; -use Patchlevel\EventSourcing\Attribute\Projection; +use Patchlevel\EventSourcing\Attribute\Projector; use Patchlevel\EventSourcing\EventBus\Message; -#[Projection('profile', version: 1)] +#[Projector('profile', version: 1)] final class ProfileProjector { // ... @@ -169,12 +169,12 @@ If something breaks, the projectionist marks the individual projections as fault ## Projection Id A projection id consists of a unique name and a version. -It can be defined using the `Projection` attribute. +It can be defined using the `Projector` attribute. ```php -use Patchlevel\EventSourcing\Attribute\Projection; +use Patchlevel\EventSourcing\Attribute\Projector; -#[Projection('profile', version: 1)] +#[Projector('profile', version: 1)] final class ProfileProjector { // ... diff --git a/src/Attribute/Projection.php b/src/Attribute/Projector.php similarity index 94% rename from src/Attribute/Projection.php rename to src/Attribute/Projector.php index 647894e19..04c3ca079 100644 --- a/src/Attribute/Projection.php +++ b/src/Attribute/Projector.php @@ -7,7 +7,7 @@ use Attribute; #[Attribute(Attribute::TARGET_CLASS)] -final class Projection +final class Projector { public function __construct( private string $name, diff --git a/src/Metadata/Projector/AttributeProjectorMetadataFactory.php b/src/Metadata/Projector/AttributeProjectorMetadataFactory.php index 358028ce2..461f68eca 100644 --- a/src/Metadata/Projector/AttributeProjectorMetadataFactory.php +++ b/src/Metadata/Projector/AttributeProjectorMetadataFactory.php @@ -6,7 +6,7 @@ use Patchlevel\EventSourcing\Attribute\Create; use Patchlevel\EventSourcing\Attribute\Drop; -use Patchlevel\EventSourcing\Attribute\Projection; +use Patchlevel\EventSourcing\Attribute\Projector; use Patchlevel\EventSourcing\Attribute\Subscribe; use ReflectionClass; @@ -26,7 +26,7 @@ public function metadata(string $projector): ProjectorMetadata $reflector = new ReflectionClass($projector); - $attributes = $reflector->getAttributes(Projection::class); + $attributes = $reflector->getAttributes(Projector::class); if ($attributes === []) { throw new ClassIsNotAProjector($projector); diff --git a/tests/Benchmark/BasicImplementation/Projection/ProfileProjector.php b/tests/Benchmark/BasicImplementation/Projection/ProfileProjector.php index 0376c17d7..42c4a1373 100644 --- a/tests/Benchmark/BasicImplementation/Projection/ProfileProjector.php +++ b/tests/Benchmark/BasicImplementation/Projection/ProfileProjector.php @@ -7,14 +7,14 @@ use Doctrine\DBAL\Connection; use Patchlevel\EventSourcing\Attribute\Create; use Patchlevel\EventSourcing\Attribute\Drop; -use Patchlevel\EventSourcing\Attribute\Projection; +use Patchlevel\EventSourcing\Attribute\Projector; use Patchlevel\EventSourcing\Attribute\Subscribe; use Patchlevel\EventSourcing\EventBus\Message; use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\Events\ProfileCreated; use function assert; -#[Projection('dummy', 1)] +#[Projector('dummy', 1)] final class ProfileProjector { public function __construct( diff --git a/tests/Integration/BankAccountSplitStream/Projection/BankAccountProjection.php b/tests/Integration/BankAccountSplitStream/Projection/BankAccountProjection.php index 50de2991c..83aa17e00 100644 --- a/tests/Integration/BankAccountSplitStream/Projection/BankAccountProjection.php +++ b/tests/Integration/BankAccountSplitStream/Projection/BankAccountProjection.php @@ -8,13 +8,13 @@ use Doctrine\DBAL\Schema\Table; use Patchlevel\EventSourcing\Attribute\Create; use Patchlevel\EventSourcing\Attribute\Drop; -use Patchlevel\EventSourcing\Attribute\Projection; +use Patchlevel\EventSourcing\Attribute\Projector; use Patchlevel\EventSourcing\Attribute\Subscribe; use Patchlevel\EventSourcing\EventBus\Message; use Patchlevel\EventSourcing\Tests\Integration\BankAccountSplitStream\Events\BalanceAdded; use Patchlevel\EventSourcing\Tests\Integration\BankAccountSplitStream\Events\BankAccountCreated; -#[Projection('dummy', 1)] +#[Projector('dummy', 1)] final class BankAccountProjection { public function __construct( diff --git a/tests/Integration/BasicImplementation/Projection/ProfileProjection.php b/tests/Integration/BasicImplementation/Projection/ProfileProjection.php index 927c8271a..65c582d40 100644 --- a/tests/Integration/BasicImplementation/Projection/ProfileProjection.php +++ b/tests/Integration/BasicImplementation/Projection/ProfileProjection.php @@ -8,14 +8,14 @@ use Doctrine\DBAL\Schema\Table; use Patchlevel\EventSourcing\Attribute\Create; use Patchlevel\EventSourcing\Attribute\Drop; -use Patchlevel\EventSourcing\Attribute\Projection; +use Patchlevel\EventSourcing\Attribute\Projector; use Patchlevel\EventSourcing\Attribute\Subscribe; use Patchlevel\EventSourcing\EventBus\Message; use Patchlevel\EventSourcing\Tests\Integration\BasicImplementation\Events\ProfileCreated; use function assert; -#[Projection('profile', 1)] +#[Projector('profile', 1)] final class ProfileProjection { public function __construct( diff --git a/tests/Integration/Outbox/Projection/ProfileProjection.php b/tests/Integration/Outbox/Projection/ProfileProjection.php index e4535208b..c33f1a5a9 100644 --- a/tests/Integration/Outbox/Projection/ProfileProjection.php +++ b/tests/Integration/Outbox/Projection/ProfileProjection.php @@ -8,12 +8,12 @@ use Doctrine\DBAL\Schema\Table; use Patchlevel\EventSourcing\Attribute\Create; use Patchlevel\EventSourcing\Attribute\Drop; -use Patchlevel\EventSourcing\Attribute\Projection; +use Patchlevel\EventSourcing\Attribute\Projector; use Patchlevel\EventSourcing\Attribute\Subscribe; use Patchlevel\EventSourcing\EventBus\Message; use Patchlevel\EventSourcing\Tests\Integration\Outbox\Events\ProfileCreated; -#[Projection('dummy', 1)] +#[Projector('dummy', 1)] final class ProfileProjection { public function __construct( diff --git a/tests/Integration/Projectionist/Projection/ProfileProjection.php b/tests/Integration/Projectionist/Projection/ProfileProjection.php index 98a75b1d8..0ae9e6d10 100644 --- a/tests/Integration/Projectionist/Projection/ProfileProjection.php +++ b/tests/Integration/Projectionist/Projection/ProfileProjection.php @@ -8,7 +8,7 @@ use Doctrine\DBAL\Schema\Table; use Patchlevel\EventSourcing\Attribute\Create; use Patchlevel\EventSourcing\Attribute\Drop; -use Patchlevel\EventSourcing\Attribute\Projection; +use Patchlevel\EventSourcing\Attribute\Projector; use Patchlevel\EventSourcing\Attribute\Subscribe; use Patchlevel\EventSourcing\EventBus\Message; use Patchlevel\EventSourcing\Projection\Projector\ProjectorUtil; @@ -17,7 +17,7 @@ use function assert; use function sprintf; -#[Projection('profile', 1)] +#[Projector('profile', 1)] final class ProfileProjection { use ProjectorUtil; diff --git a/tests/Unit/Fixture/Dummy2Projection.php b/tests/Unit/Fixture/Dummy2Projection.php index aef8dbb33..fc0eba19b 100644 --- a/tests/Unit/Fixture/Dummy2Projection.php +++ b/tests/Unit/Fixture/Dummy2Projection.php @@ -6,12 +6,12 @@ use Patchlevel\EventSourcing\Attribute\Create; use Patchlevel\EventSourcing\Attribute\Drop; -use Patchlevel\EventSourcing\Attribute\Projection; +use Patchlevel\EventSourcing\Attribute\Projector; use Patchlevel\EventSourcing\Attribute\Subscribe; use Patchlevel\EventSourcing\EventBus\Message as EventMessage; use Patchlevel\EventSourcing\Projection\Projection\ProjectionId; -#[Projection('dummy2', 1)] +#[Projector('dummy2', 1)] final class Dummy2Projection { public EventMessage|null $handledMessage = null; diff --git a/tests/Unit/Fixture/DummyProjection.php b/tests/Unit/Fixture/DummyProjection.php index 2d28f590b..be1ba5fb5 100644 --- a/tests/Unit/Fixture/DummyProjection.php +++ b/tests/Unit/Fixture/DummyProjection.php @@ -6,12 +6,12 @@ use Patchlevel\EventSourcing\Attribute\Create; use Patchlevel\EventSourcing\Attribute\Drop; -use Patchlevel\EventSourcing\Attribute\Projection; +use Patchlevel\EventSourcing\Attribute\Projector; use Patchlevel\EventSourcing\Attribute\Subscribe; use Patchlevel\EventSourcing\EventBus\Message as EventMessage; use Patchlevel\EventSourcing\Projection\Projection\ProjectionId; -#[Projection('dummy', 1)] +#[Projector('dummy', 1)] final class DummyProjection { public EventMessage|null $handledMessage = null; diff --git a/tests/Unit/Metadata/Projector/AttributeProjectorMetadataFactoryTest.php b/tests/Unit/Metadata/Projector/AttributeProjectorMetadataFactoryTest.php index ff02a17d3..f90d1a607 100644 --- a/tests/Unit/Metadata/Projector/AttributeProjectorMetadataFactoryTest.php +++ b/tests/Unit/Metadata/Projector/AttributeProjectorMetadataFactoryTest.php @@ -6,7 +6,7 @@ use Patchlevel\EventSourcing\Attribute\Create; use Patchlevel\EventSourcing\Attribute\Drop; -use Patchlevel\EventSourcing\Attribute\Projection; +use Patchlevel\EventSourcing\Attribute\Projector; use Patchlevel\EventSourcing\Attribute\Subscribe; use Patchlevel\EventSourcing\Metadata\Projector\AttributeProjectorMetadataFactory; use Patchlevel\EventSourcing\Metadata\Projector\ClassIsNotAProjector; @@ -31,7 +31,7 @@ public function testNotAProjection(): void public function testEmptyProjection(): void { - $projection = new #[Projection('foo', 1)] + $projection = new #[Projector('foo', 1)] class { }; @@ -47,7 +47,7 @@ class { public function testStandardProjection(): void { - $projection = new #[Projection('foo', 1)] + $projection = new #[Projector('foo', 1)] class { #[Subscribe(ProfileVisited::class)] public function handle(): void @@ -79,7 +79,7 @@ public function drop(): void public function testMultipleHandlerOnOneMethod(): void { - $projection = new #[Projection('foo', 1)] + $projection = new #[Projector('foo', 1)] class { #[Subscribe(ProfileVisited::class)] #[Subscribe(ProfileCreated::class)] @@ -104,7 +104,7 @@ public function testDuplicateCreateAttributeException(): void { $this->expectException(DuplicateCreateMethod::class); - $projection = new #[Projection('foo', 1)] + $projection = new #[Projector('foo', 1)] class { #[Create] public function create1(): void @@ -125,7 +125,7 @@ public function testDuplicateDropAttributeException(): void { $this->expectException(DuplicateDropMethod::class); - $projection = new #[Projection('foo', 1)] + $projection = new #[Projector('foo', 1)] class { #[Drop] public function drop1(): void diff --git a/tests/Unit/Projection/Projectionist/DefaultProjectionistTest.php b/tests/Unit/Projection/Projectionist/DefaultProjectionistTest.php index c4497ea93..94986870b 100644 --- a/tests/Unit/Projection/Projectionist/DefaultProjectionistTest.php +++ b/tests/Unit/Projection/Projectionist/DefaultProjectionistTest.php @@ -4,7 +4,7 @@ namespace Patchlevel\EventSourcing\Tests\Unit\Projection\Projectionist; -use Patchlevel\EventSourcing\Attribute\Projection as ProjectionAttribute; +use Patchlevel\EventSourcing\Attribute\Projector as ProjectionAttribute; use Patchlevel\EventSourcing\EventBus\Message; use Patchlevel\EventSourcing\Projection\Projection\Projection; use Patchlevel\EventSourcing\Projection\Projection\ProjectionCollection; diff --git a/tests/Unit/Projection/Projector/MetadataProjectorResolverTest.php b/tests/Unit/Projection/Projector/MetadataProjectorResolverTest.php index b07880c54..278988ae7 100644 --- a/tests/Unit/Projection/Projector/MetadataProjectorResolverTest.php +++ b/tests/Unit/Projection/Projector/MetadataProjectorResolverTest.php @@ -6,7 +6,7 @@ use Patchlevel\EventSourcing\Attribute\Create; use Patchlevel\EventSourcing\Attribute\Drop; -use Patchlevel\EventSourcing\Attribute\Projection; +use Patchlevel\EventSourcing\Attribute\Projector; use Patchlevel\EventSourcing\Attribute\Subscribe; use Patchlevel\EventSourcing\EventBus\Message; use Patchlevel\EventSourcing\Projection\Projector\MetadataProjectorResolver; @@ -21,7 +21,7 @@ final class MetadataProjectorResolverTest extends TestCase { public function testResolveHandleMethod(): void { - $projection = new #[Projection('dummy')] + $projection = new #[Projector('dummy')] class { public static Message|null $handledMessage = null; @@ -51,7 +51,7 @@ public function handleProfileCreated(Message $message): void public function testNotResolveHandleMethod(): void { - $projection = new #[Projection('dummy')] + $projection = new #[Projector('dummy')] class { }; @@ -69,7 +69,7 @@ class { public function testResolveCreateMethod(): void { - $projection = new #[Projection('dummy')] + $projection = new #[Projector('dummy')] class { public static bool $called = false; @@ -92,7 +92,7 @@ public function method(): void public function testNotResolveCreateMethod(): void { - $projection = new #[Projection('dummy')] + $projection = new #[Projector('dummy')] class { }; @@ -104,7 +104,7 @@ class { public function testResolveDropMethod(): void { - $projection = new #[Projection('dummy')] + $projection = new #[Projector('dummy')] class { public static bool $called = false; @@ -127,7 +127,7 @@ public function method(): void public function testNotResolveDropMethod(): void { - $projection = new #[Projection('dummy')] + $projection = new #[Projector('dummy')] class { }; @@ -139,7 +139,7 @@ class { public function testProjectionId(): void { - $projection = new #[Projection('dummy', 1)] + $projection = new #[Projector('dummy', 1)] class { }; diff --git a/tests/Unit/Projection/Projector/ProjectorHelperTest.php b/tests/Unit/Projection/Projector/ProjectorHelperTest.php index 51c29ac95..bd833035a 100644 --- a/tests/Unit/Projection/Projector/ProjectorHelperTest.php +++ b/tests/Unit/Projection/Projector/ProjectorHelperTest.php @@ -4,7 +4,7 @@ namespace Patchlevel\EventSourcing\Tests\Unit\Projection\Projector; -use Patchlevel\EventSourcing\Attribute\Projection; +use Patchlevel\EventSourcing\Attribute\Projector; use Patchlevel\EventSourcing\Projection\Projection\ProjectionId; use Patchlevel\EventSourcing\Projection\Projector\ProjectorHelper; use PHPUnit\Framework\TestCase; @@ -14,7 +14,7 @@ final class ProjectorHelperTest extends TestCase { public function testProjectionName(): void { - $projector = new #[Projection('dummy')] + $projector = new #[Projector('dummy')] class { }; @@ -25,7 +25,7 @@ class { public function testProjectionVersion(): void { - $projector = new #[Projection('dummy', 1)] + $projector = new #[Projector('dummy', 1)] class { }; @@ -36,7 +36,7 @@ class { public function testProjectionId(): void { - $projector = new #[Projection('dummy', 1)] + $projector = new #[Projector('dummy', 1)] class { };