diff --git a/composer.json b/composer.json index 551f0c99e..65c6b62fd 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "php": "~8.1.0 || ~8.2.0 || ~8.3.0", "doctrine/dbal": "^3.8.1|^4.0.0", "doctrine/migrations": "^3.3.2", - "patchlevel/hydrator": "^1.3.1", + "patchlevel/hydrator": "^1.4.1", "patchlevel/worker": "^1.2.0", "psr/cache": "^2.0.0|^3.0.0", "psr/clock": "^1.0", diff --git a/composer.lock b/composer.lock index 27fc4f95a..497468893 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6ac54e076f078f9ce7d647a05b58076e", + "content-hash": "ac6d06cc1614552b242cde2ec2ff3b60", "packages": [ { "name": "brick/math", @@ -416,16 +416,16 @@ }, { "name": "patchlevel/hydrator", - "version": "1.4.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/patchlevel/hydrator.git", - "reference": "824959c564c8c4fb22e861724a5fd590e760a41c" + "reference": "0386ca29388c5c9d3f8b7b328826d16521313d91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/patchlevel/hydrator/zipball/824959c564c8c4fb22e861724a5fd590e760a41c", - "reference": "824959c564c8c4fb22e861724a5fd590e760a41c", + "url": "https://api.github.com/repos/patchlevel/hydrator/zipball/0386ca29388c5c9d3f8b7b328826d16521313d91", + "reference": "0386ca29388c5c9d3f8b7b328826d16521313d91", "shasum": "" }, "require": { @@ -475,9 +475,9 @@ ], "support": { "issues": "https://github.com/patchlevel/hydrator/issues", - "source": "https://github.com/patchlevel/hydrator/tree/1.4.0" + "source": "https://github.com/patchlevel/hydrator/tree/1.4.1" }, - "time": "2024-07-03T12:22:27+00:00" + "time": "2024-07-09T08:06:23+00:00" }, { "name": "patchlevel/worker", @@ -2706,16 +2706,16 @@ }, { "name": "dflydev/dot-access-data", - "version": "v3.0.2", + "version": "v3.0.3", "source": { "type": "git", "url": "https://github.com/dflydev/dflydev-dot-access-data.git", - "reference": "f41715465d65213d644d3141a6a93081be5d3549" + "reference": "a23a2bf4f31d3518f3ecb38660c95715dfead60f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dflydev/dflydev-dot-access-data/zipball/f41715465d65213d644d3141a6a93081be5d3549", - "reference": "f41715465d65213d644d3141a6a93081be5d3549", + "url": "https://api.github.com/repos/dflydev/dflydev-dot-access-data/zipball/a23a2bf4f31d3518f3ecb38660c95715dfead60f", + "reference": "a23a2bf4f31d3518f3ecb38660c95715dfead60f", "shasum": "" }, "require": { @@ -2775,9 +2775,9 @@ ], "support": { "issues": "https://github.com/dflydev/dflydev-dot-access-data/issues", - "source": "https://github.com/dflydev/dflydev-dot-access-data/tree/v3.0.2" + "source": "https://github.com/dflydev/dflydev-dot-access-data/tree/v3.0.3" }, - "time": "2022-10-27T11:44:00+00:00" + "time": "2024-07-08T12:26:09+00:00" }, { "name": "dnoegel/php-xdg-base-dir", @@ -5672,16 +5672,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.25", + "version": "10.5.26", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "831bf82312be6037e811833ddbea0b8de60ea314" + "reference": "42e2f13ceaa2e34461bc89bea75407550b40b2aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/831bf82312be6037e811833ddbea0b8de60ea314", - "reference": "831bf82312be6037e811833ddbea0b8de60ea314", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/42e2f13ceaa2e34461bc89bea75407550b40b2aa", + "reference": "42e2f13ceaa2e34461bc89bea75407550b40b2aa", "shasum": "" }, "require": { @@ -5753,7 +5753,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.25" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.26" }, "funding": [ { @@ -5769,7 +5769,7 @@ "type": "tidelift" } ], - "time": "2024-07-03T05:49:17+00:00" + "time": "2024-07-08T05:30:46+00:00" }, { "name": "psalm/plugin-phpunit", diff --git a/deptrac-baseline.yaml b/deptrac-baseline.yaml index bf6fd70df..97559a96c 100644 --- a/deptrac-baseline.yaml +++ b/deptrac-baseline.yaml @@ -1,5 +1,11 @@ deptrac: skip_violations: + Patchlevel\EventSourcing\Aggregate\AggregateRootId: + - Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer + Patchlevel\EventSourcing\Aggregate\CustomId: + - Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer + Patchlevel\EventSourcing\Aggregate\Uuid: + - Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer Patchlevel\EventSourcing\Attribute\Processor: - Patchlevel\EventSourcing\Subscription\RunMode Patchlevel\EventSourcing\Attribute\Projector: diff --git a/docs/pages/aggregate.md b/docs/pages/aggregate.md index 75e9257a0..cf8494c95 100644 --- a/docs/pages/aggregate.md +++ b/docs/pages/aggregate.md @@ -91,20 +91,16 @@ final class CreateProfileHandler In order that an aggregate is actually saved, at least one event must exist in the DB. For our aggregate we create the Event `ProfileRegistered` with an ID and a name. -Since the ID is a complex data type and cannot be easily serialized, we need to define a normalizer for the ID. -We do this with the `IdNormalizer` attribute. We also give the event a unique name using the `Event` attribute. ```php use Patchlevel\EventSourcing\Aggregate\Uuid; use Patchlevel\EventSourcing\Attribute\Event; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; #[Event('profile.registered')] final class ProfileRegistered { public function __construct( - #[IdNormalizer] public readonly Uuid $profileId, public readonly string $name, ) { @@ -114,7 +110,6 @@ final class ProfileRegistered !!! note You can find out more about events [here](./events.md). - And for normalizer [here](./normalizer.md). After we have defined the event, we have to adapt the profile aggregate: @@ -489,7 +484,8 @@ final class NameChanged ``` !!! warning - The payload must be serializable and unserializable as json. + You need to create a normalizer for the `Name` value object. + So the payload must be serializable and unserializable as json. !!! note diff --git a/docs/pages/aggregate_id.md b/docs/pages/aggregate_id.md index ce9c05d31..c4c336be4 100644 --- a/docs/pages/aggregate_id.md +++ b/docs/pages/aggregate_id.md @@ -25,21 +25,14 @@ use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot; use Patchlevel\EventSourcing\Aggregate\Uuid; use Patchlevel\EventSourcing\Attribute\Aggregate; use Patchlevel\EventSourcing\Attribute\Id; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; #[Aggregate('profile')] final class Profile extends BasicAggregateRoot { #[Id] - #[IdNormalizer] private Uuid $id; } ``` -!!! note - - If you want to use snapshots, then you have to make sure that the aggregate id are normalized. - You can find how to do this [here](normalizer.md). - You have multiple options for generating an uuid: ```php @@ -63,13 +56,11 @@ use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot; use Patchlevel\EventSourcing\Aggregate\CustomId; use Patchlevel\EventSourcing\Attribute\Aggregate; use Patchlevel\EventSourcing\Attribute\Id; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; #[Aggregate('profile')] final class Profile extends BasicAggregateRoot { #[Id] - #[IdNormalizer] private CustomId $id; } ``` @@ -79,11 +70,6 @@ final class Profile extends BasicAggregateRoot you need to change the `aggregate_id_type` to `string` in the store configuration. More information can be found [here](store.md). -!!! note - - If you want to use snapshots, then you have to make sure that the aggregate id are normalized. - You can find how to do this [here](normalizer.md). - So you can use any string as an id: ```php @@ -124,21 +110,14 @@ So you can use it like this: use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot; use Patchlevel\EventSourcing\Attribute\Aggregate; use Patchlevel\EventSourcing\Attribute\Id; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; #[Aggregate('profile')] final class Profile extends BasicAggregateRoot { #[Id] - #[IdNormalizer] private ProfileId $id; } ``` -!!! note - - If you want to use snapshots, then you have to make sure that the aggregate id are normalized. - You can find how to do this [here](normalizer.md). - We also offer you some traits, so that you don't have to implement the `AggregateRootId` interface yourself. Here for the uuid: @@ -167,4 +146,3 @@ class ProfileId implements AggregateRootId * [How to create an aggregate](aggregate.md) * [How to create an event](events.md) * [How to test an aggregate](testing.md) -* [How to normalize value objects](normalizer.md) diff --git a/docs/pages/events.md b/docs/pages/events.md index ff843ed6a..c0a564219 100644 --- a/docs/pages/events.md +++ b/docs/pages/events.md @@ -83,6 +83,11 @@ final class ProfileCreated } } ``` +!!! tip + + Built-in normalizers like `IdNormalizer` and `DateTimeImmutableNormalizer` can be inferred from the type hint + and so you don't have to specify them. If you want to configure the Normalizer, you still have to do it. + !!! note You can find out more about normalizer [here](normalizer.md). diff --git a/docs/pages/getting_started.md b/docs/pages/getting_started.md index f3c427513..a347db0e3 100644 --- a/docs/pages/getting_started.md +++ b/docs/pages/getting_started.md @@ -12,13 +12,11 @@ A hotel can be created with a `name` and a `id`: ```php use Patchlevel\EventSourcing\Aggregate\Uuid; use Patchlevel\EventSourcing\Attribute\Event; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; #[Event('hotel.created')] final class HotelCreated { public function __construct( - #[IdNormalizer] public readonly Uuid $hotelId, public readonly string $hotelName, ) { diff --git a/docs/pages/normalizer.md b/docs/pages/normalizer.md index 47e655e5c..c798a0f22 100644 --- a/docs/pages/normalizer.md +++ b/docs/pages/normalizer.md @@ -1,9 +1,8 @@ # Normalizer Sometimes you also want to add more complex data in events as payload or in aggregates for the snapshots. -For example DateTime, enums or value objects. You can do that too. -However, you must define a normalizer for this so that the library knows -how to write this data to the database and load it again. +For example DateTime, enums or value objects. +Here you can use the normalizer to define how the data should be saved and loaded. !!! note @@ -12,7 +11,30 @@ how to write this data to the database and load it again. ## Usage -You have to set the normalizer to the properties using the specific normalizer class. +You have a lot of options to use the normalizer. +First of all and simplest, you can let guess the normalizer from the type hint. + +```php +final class DTO +{ + public DateTimeImmutable $date; +} +``` +Most built-in normalizers can be inferred from the type hint: + +* `DateTimeImmutable` => `DateTimeImmutableNormalizer` +* `DateTime` => `DateTimeNormalizer` +* `DateTimeZone` => `DateTimeZoneNormalizer` +* `Enum` => `EnumNormalizer` +* `AggregateRootId` => `IdNormalizer` + +!!! note + + `ObjectNormalizer` will not be inferred. You have to specify it yourself. + This should prevent you from accidentally serializing objects that you don't want to serialize. + +The other way is to specify the normalizer to the properties directly. +This example is equivalent to the previous one. ```php use Patchlevel\Hydrator\Normalizer\DateTimeImmutableNormalizer; @@ -23,7 +45,7 @@ final class DTO public DateTimeImmutable $date; } ``` -The whole thing also works with property promotion and readonly properties. +And the whole thing also works with property promotion and readonly properties too. ```php use Patchlevel\Hydrator\Normalizer\DateTimeImmutableNormalizer; @@ -37,9 +59,25 @@ final class DTO } } ``` -!!! tip +If you have child entities or value objects, then you can also define the normalizer on class level. +So you don't have to specify it for each property. - If you have personal data, you can use [crypto-shredding](personal_data.md). +```php +use Patchlevel\Hydrator\Normalizer\ObjectNormalizer; + +#[ObjectNormalizer] +final class Item +{ + public function __construct( + public readonly int $number, + public readonly DateTimeImmutable $addedAt, + ) { + } +} +``` +!!! note + + With the `ObjectNormalizer`, you can seraialize and deserialize recursively. ### Event @@ -61,6 +99,10 @@ final class CreateHotel } } ``` +!!! note + + If you have personal data, you can use [crypto-shredding](personal_data.md). + ### Aggregate For the aggregates it is very similar to the events. However, the normalizer is only used for the snapshots. @@ -126,6 +168,10 @@ final class DTO public DateTimeImmutable $date; } ``` +!!! tip + + You can let the hydrator guess the normalizer from the type hint. + You can also define the format. Either describe it yourself as a string or use one of the existing constants. The default is `DateTimeImmutable::ATOM`. @@ -155,6 +201,10 @@ final class DTO public DateTime $date; } ``` +!!! tip + + You can let the hydrator guess the normalizer from the type hint. + You can also specify the format here. The default is `DateTime::ATOM`. ```php @@ -188,6 +238,10 @@ final class DTO public DateTimeZone $timeZone; } ``` +!!! tip + + You can let the hydrator guess the normalizer from the type hint. + ### Enum Backed enums can also be normalized. @@ -201,6 +255,10 @@ final class DTO public Status $status; } ``` +!!! tip + + You can let the hydrator guess the normalizer from the type hint. + You can also specify the enum class. ```php @@ -226,6 +284,10 @@ final class DTO public Uuid $id; } ``` +!!! tip + + You can let the hydrator guess the normalizer from the type hint. + Optional you can also define the type of the id. ```php @@ -295,7 +357,7 @@ Finally, you have to allow the normalizer to be used as an attribute. use Patchlevel\Hydrator\Normalizer\InvalidArgument; use Patchlevel\Hydrator\Normalizer\Normalizer; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_CLASS)] class NameNormalizer implements Normalizer { public function normalize(mixed $value): string @@ -338,6 +400,15 @@ final class DTO Every normalizer, including the custom normalizer, can be used both for the events and for the snapshots. +Or define it on class level, so you don't have to specify it for each property. + +```php +#[NameNormalizer] +final class Name +{ + /* name logic... */ +} +``` ## Normalized Name By default, the property name is used to name the field in the normalized result. diff --git a/docs/pages/snapshots.md b/docs/pages/snapshots.md index 5b8d2e65e..30b9c1842 100644 --- a/docs/pages/snapshots.md +++ b/docs/pages/snapshots.md @@ -86,18 +86,14 @@ use Patchlevel\EventSourcing\Aggregate\Uuid; use Patchlevel\EventSourcing\Attribute\Aggregate; use Patchlevel\EventSourcing\Attribute\Id; use Patchlevel\EventSourcing\Attribute\Snapshot; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; -use Patchlevel\Hydrator\Normalizer\DateTimeImmutableNormalizer; #[Aggregate('profile')] #[Snapshot('default')] final class Profile extends BasicAggregateRoot { #[Id] - #[IdNormalizer] public Uuid $id; public string $name; - #[DateTimeImmutableNormalizer] public DateTimeImmutable $createdAt; // ... diff --git a/docs/pages/split_stream.md b/docs/pages/split_stream.md index 648ba0a69..e1237160f 100644 --- a/docs/pages/split_stream.md +++ b/docs/pages/split_stream.md @@ -56,14 +56,12 @@ For that you can use the `#[SplitStream]` attribute. ```php use Patchlevel\EventSourcing\Attribute\Event; use Patchlevel\EventSourcing\Attribute\SplitStream; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; #[Event('bank_account.balance_reported')] #[SplitStream] final class BalanceReported { public function __construct( - #[IdNormalizer] public BankAccountId $bankAccountId, public int $year, public int $balanceInCents, diff --git a/src/Aggregate/AggregateRootId.php b/src/Aggregate/AggregateRootId.php index 5bbb66491..9ce6c2d6c 100644 --- a/src/Aggregate/AggregateRootId.php +++ b/src/Aggregate/AggregateRootId.php @@ -4,6 +4,9 @@ namespace Patchlevel\EventSourcing\Aggregate; +use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; + +#[IdNormalizer] interface AggregateRootId { public function toString(): string; diff --git a/src/Serializer/Normalizer/IdNormalizer.php b/src/Serializer/Normalizer/IdNormalizer.php index 5a59c9ad8..f70be7650 100644 --- a/src/Serializer/Normalizer/IdNormalizer.php +++ b/src/Serializer/Normalizer/IdNormalizer.php @@ -15,7 +15,7 @@ use function is_string; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_CLASS)] final class IdNormalizer implements Normalizer, ReflectionTypeAwareNormalizer { public function __construct( diff --git a/tests/Benchmark/BasicImplementation/Events/EmailChanged.php b/tests/Benchmark/BasicImplementation/Events/EmailChanged.php index 3177185d5..a7c3743cc 100644 --- a/tests/Benchmark/BasicImplementation/Events/EmailChanged.php +++ b/tests/Benchmark/BasicImplementation/Events/EmailChanged.php @@ -5,7 +5,6 @@ namespace Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\Events; use Patchlevel\EventSourcing\Attribute\Event; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\ProfileId; use Patchlevel\Hydrator\Attribute\DataSubjectId; use Patchlevel\Hydrator\Attribute\PersonalData; @@ -14,7 +13,6 @@ final class EmailChanged { public function __construct( - #[IdNormalizer] #[DataSubjectId] public ProfileId $profileId, #[PersonalData] diff --git a/tests/Benchmark/BasicImplementation/Events/ProfileCreated.php b/tests/Benchmark/BasicImplementation/Events/ProfileCreated.php index bd47f28da..7dcea07da 100644 --- a/tests/Benchmark/BasicImplementation/Events/ProfileCreated.php +++ b/tests/Benchmark/BasicImplementation/Events/ProfileCreated.php @@ -5,7 +5,6 @@ namespace Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\Events; use Patchlevel\EventSourcing\Attribute\Event; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\ProfileId; use Patchlevel\Hydrator\Attribute\DataSubjectId; use Patchlevel\Hydrator\Attribute\PersonalData; @@ -14,7 +13,6 @@ final class ProfileCreated { public function __construct( - #[IdNormalizer] #[DataSubjectId] public ProfileId $profileId, public string $name, diff --git a/tests/Benchmark/BasicImplementation/Events/Reborn.php b/tests/Benchmark/BasicImplementation/Events/Reborn.php index 78c2a9a58..8d25a5aa9 100644 --- a/tests/Benchmark/BasicImplementation/Events/Reborn.php +++ b/tests/Benchmark/BasicImplementation/Events/Reborn.php @@ -6,7 +6,6 @@ use Patchlevel\EventSourcing\Attribute\Event; use Patchlevel\EventSourcing\Attribute\SplitStream; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\ProfileId; #[Event('profile.reborn')] @@ -14,7 +13,6 @@ final class Reborn { public function __construct( - #[IdNormalizer] public ProfileId $profileId, public string $name, ) { diff --git a/tests/Benchmark/BasicImplementation/Processor/SendEmailProcessor.php b/tests/Benchmark/BasicImplementation/Processor/SendEmailProcessor.php index 31bc2a107..170d3bfe7 100644 --- a/tests/Benchmark/BasicImplementation/Processor/SendEmailProcessor.php +++ b/tests/Benchmark/BasicImplementation/Processor/SendEmailProcessor.php @@ -7,8 +7,8 @@ use Patchlevel\EventSourcing\Attribute\Processor; use Patchlevel\EventSourcing\Attribute\Subscribe; use Patchlevel\EventSourcing\Message\Message; -use Patchlevel\EventSourcing\Tests\Integration\BasicImplementation\Events\ProfileCreated; -use Patchlevel\EventSourcing\Tests\Integration\BasicImplementation\SendEmailMock; +use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\Events\ProfileCreated; +use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\SendEmailMock; #[Processor('send_email')] final class SendEmailProcessor diff --git a/tests/Benchmark/BasicImplementation/Profile.php b/tests/Benchmark/BasicImplementation/Profile.php index 4e36c52ef..3a9cfd486 100644 --- a/tests/Benchmark/BasicImplementation/Profile.php +++ b/tests/Benchmark/BasicImplementation/Profile.php @@ -9,7 +9,6 @@ use Patchlevel\EventSourcing\Attribute\Apply; use Patchlevel\EventSourcing\Attribute\Id; use Patchlevel\EventSourcing\Attribute\Snapshot; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\Events\EmailChanged; use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\Events\NameChanged; use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\Events\ProfileCreated; @@ -20,7 +19,6 @@ final class Profile extends BasicAggregateRoot { #[Id] - #[IdNormalizer] private ProfileId $id; private string $name; private string|null $email; diff --git a/tests/Integration/BankAccountSplitStream/Events/BalanceAdded.php b/tests/Integration/BankAccountSplitStream/Events/BalanceAdded.php index f166b0536..d0d95e070 100644 --- a/tests/Integration/BankAccountSplitStream/Events/BalanceAdded.php +++ b/tests/Integration/BankAccountSplitStream/Events/BalanceAdded.php @@ -5,14 +5,12 @@ namespace Patchlevel\EventSourcing\Tests\Integration\BankAccountSplitStream\Events; use Patchlevel\EventSourcing\Attribute\Event; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; use Patchlevel\EventSourcing\Tests\Integration\BankAccountSplitStream\AccountId; #[Event('bank_account.balance_added')] final class BalanceAdded { public function __construct( - #[IdNormalizer] public AccountId $accountId, /** @var positive-int */ public int $balanceInCents, diff --git a/tests/Integration/BankAccountSplitStream/Events/BankAccountCreated.php b/tests/Integration/BankAccountSplitStream/Events/BankAccountCreated.php index 651c2947e..a0df90bf7 100644 --- a/tests/Integration/BankAccountSplitStream/Events/BankAccountCreated.php +++ b/tests/Integration/BankAccountSplitStream/Events/BankAccountCreated.php @@ -5,14 +5,12 @@ namespace Patchlevel\EventSourcing\Tests\Integration\BankAccountSplitStream\Events; use Patchlevel\EventSourcing\Attribute\Event; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; use Patchlevel\EventSourcing\Tests\Integration\BankAccountSplitStream\AccountId; #[Event('bank_account.created')] final class BankAccountCreated { public function __construct( - #[IdNormalizer] public AccountId $accountId, public string $name, ) { diff --git a/tests/Integration/BankAccountSplitStream/Events/MonthPassed.php b/tests/Integration/BankAccountSplitStream/Events/MonthPassed.php index be04547f1..94351a20f 100644 --- a/tests/Integration/BankAccountSplitStream/Events/MonthPassed.php +++ b/tests/Integration/BankAccountSplitStream/Events/MonthPassed.php @@ -6,7 +6,6 @@ use Patchlevel\EventSourcing\Attribute\Event; use Patchlevel\EventSourcing\Attribute\SplitStream; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; use Patchlevel\EventSourcing\Tests\Integration\BankAccountSplitStream\AccountId; #[Event('bank_account.month_passed')] @@ -14,7 +13,6 @@ final class MonthPassed { public function __construct( - #[IdNormalizer] public AccountId $accountId, public string $name, public int $balanceInCents, diff --git a/tests/Integration/BasicImplementation/Events/ProfileCreated.php b/tests/Integration/BasicImplementation/Events/ProfileCreated.php index 6ce7ef6d8..1536fbdeb 100644 --- a/tests/Integration/BasicImplementation/Events/ProfileCreated.php +++ b/tests/Integration/BasicImplementation/Events/ProfileCreated.php @@ -5,14 +5,12 @@ namespace Patchlevel\EventSourcing\Tests\Integration\BasicImplementation\Events; use Patchlevel\EventSourcing\Attribute\Event; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; use Patchlevel\EventSourcing\Tests\Integration\BasicImplementation\ProfileId; #[Event('profile.created')] final class ProfileCreated { public function __construct( - #[IdNormalizer] public ProfileId $profileId, public string $name, ) { diff --git a/tests/Integration/BasicImplementation/Profile.php b/tests/Integration/BasicImplementation/Profile.php index 2809ceaf4..b855af98a 100644 --- a/tests/Integration/BasicImplementation/Profile.php +++ b/tests/Integration/BasicImplementation/Profile.php @@ -9,7 +9,6 @@ use Patchlevel\EventSourcing\Attribute\Apply; use Patchlevel\EventSourcing\Attribute\Id; use Patchlevel\EventSourcing\Attribute\Snapshot; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; use Patchlevel\EventSourcing\Tests\Integration\BasicImplementation\Events\ProfileCreated; #[Aggregate('profile')] @@ -17,7 +16,6 @@ final class Profile extends BasicAggregateRoot { #[Id] - #[IdNormalizer] private ProfileId $id; private string $name; diff --git a/tests/Integration/PersonalData/Events/NameChanged.php b/tests/Integration/PersonalData/Events/NameChanged.php index c758aa2da..22c18482d 100644 --- a/tests/Integration/PersonalData/Events/NameChanged.php +++ b/tests/Integration/PersonalData/Events/NameChanged.php @@ -5,7 +5,6 @@ namespace Patchlevel\EventSourcing\Tests\Integration\PersonalData\Events; use Patchlevel\EventSourcing\Attribute\Event; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; use Patchlevel\EventSourcing\Tests\Integration\PersonalData\ProfileId; use Patchlevel\Hydrator\Attribute\DataSubjectId; use Patchlevel\Hydrator\Attribute\PersonalData; @@ -15,7 +14,6 @@ final class NameChanged { public function __construct( #[DataSubjectId] - #[IdNormalizer] public readonly ProfileId $aggregateId, #[PersonalData(fallback: 'unknown')] public readonly string $name, diff --git a/tests/Integration/PersonalData/Events/ProfileCreated.php b/tests/Integration/PersonalData/Events/ProfileCreated.php index a9a6c59f8..82b1dd0b8 100644 --- a/tests/Integration/PersonalData/Events/ProfileCreated.php +++ b/tests/Integration/PersonalData/Events/ProfileCreated.php @@ -5,7 +5,6 @@ namespace Patchlevel\EventSourcing\Tests\Integration\PersonalData\Events; use Patchlevel\EventSourcing\Attribute\Event; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; use Patchlevel\EventSourcing\Tests\Integration\PersonalData\ProfileId; use Patchlevel\Hydrator\Attribute\DataSubjectId; use Patchlevel\Hydrator\Attribute\PersonalData; @@ -14,7 +13,6 @@ final class ProfileCreated { public function __construct( - #[IdNormalizer] #[DataSubjectId] public ProfileId $profileId, #[PersonalData(fallback: 'unknown')] diff --git a/tests/Integration/PersonalData/Profile.php b/tests/Integration/PersonalData/Profile.php index a750c06f4..5fd17312d 100644 --- a/tests/Integration/PersonalData/Profile.php +++ b/tests/Integration/PersonalData/Profile.php @@ -9,7 +9,6 @@ use Patchlevel\EventSourcing\Attribute\Apply; use Patchlevel\EventSourcing\Attribute\Id; use Patchlevel\EventSourcing\Attribute\Snapshot; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; use Patchlevel\EventSourcing\Tests\Integration\PersonalData\Events\NameChanged; use Patchlevel\EventSourcing\Tests\Integration\PersonalData\Events\PersonalDataRemoved; use Patchlevel\EventSourcing\Tests\Integration\PersonalData\Events\ProfileCreated; @@ -21,7 +20,6 @@ final class Profile extends BasicAggregateRoot { #[Id] - #[IdNormalizer] #[DataSubjectId] private ProfileId $id; diff --git a/tests/Integration/Store/Events/ProfileCreated.php b/tests/Integration/Store/Events/ProfileCreated.php index 4304c4878..be96775fe 100644 --- a/tests/Integration/Store/Events/ProfileCreated.php +++ b/tests/Integration/Store/Events/ProfileCreated.php @@ -5,14 +5,12 @@ namespace Patchlevel\EventSourcing\Tests\Integration\Store\Events; use Patchlevel\EventSourcing\Attribute\Event; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; use Patchlevel\EventSourcing\Tests\Integration\Store\ProfileId; #[Event('profile.created')] final class ProfileCreated { public function __construct( - #[IdNormalizer] public ProfileId $profileId, public string $name, ) { diff --git a/tests/Integration/Store/Profile.php b/tests/Integration/Store/Profile.php index 92fed2765..d1ea5fce9 100644 --- a/tests/Integration/Store/Profile.php +++ b/tests/Integration/Store/Profile.php @@ -8,7 +8,6 @@ use Patchlevel\EventSourcing\Attribute\Aggregate; use Patchlevel\EventSourcing\Attribute\Apply; use Patchlevel\EventSourcing\Attribute\Id; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; use Patchlevel\EventSourcing\Tests\Integration\Subscription\Events\ProfileCreated; use Patchlevel\EventSourcing\Tests\Integration\Subscription\ProfileId; @@ -16,7 +15,6 @@ final class Profile extends BasicAggregateRoot { #[Id] - #[IdNormalizer] private ProfileId $id; private string $name; diff --git a/tests/Integration/Subscription/Events/ProfileCreated.php b/tests/Integration/Subscription/Events/ProfileCreated.php index b4489452d..939609366 100644 --- a/tests/Integration/Subscription/Events/ProfileCreated.php +++ b/tests/Integration/Subscription/Events/ProfileCreated.php @@ -5,14 +5,12 @@ namespace Patchlevel\EventSourcing\Tests\Integration\Subscription\Events; use Patchlevel\EventSourcing\Attribute\Event; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; use Patchlevel\EventSourcing\Tests\Integration\Subscription\ProfileId; #[Event('profile.created')] final class ProfileCreated { public function __construct( - #[IdNormalizer] public ProfileId $profileId, public string $name, ) { diff --git a/tests/Integration/Subscription/Profile.php b/tests/Integration/Subscription/Profile.php index 53b870101..8a4342a0c 100644 --- a/tests/Integration/Subscription/Profile.php +++ b/tests/Integration/Subscription/Profile.php @@ -8,7 +8,6 @@ use Patchlevel\EventSourcing\Attribute\Aggregate; use Patchlevel\EventSourcing\Attribute\Apply; use Patchlevel\EventSourcing\Attribute\Id; -use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; use Patchlevel\EventSourcing\Tests\Integration\Subscription\Events\AdminPromoted; use Patchlevel\EventSourcing\Tests\Integration\Subscription\Events\NameChanged; use Patchlevel\EventSourcing\Tests\Integration\Subscription\Events\ProfileCreated; @@ -17,7 +16,6 @@ final class Profile extends BasicAggregateRoot { #[Id] - #[IdNormalizer] private ProfileId $id; private string $name;