From d399fff29b2ab54457ff49bd065c4a46d7cbc930 Mon Sep 17 00:00:00 2001 From: David Badura Date: Tue, 12 Dec 2023 12:47:29 +0100 Subject: [PATCH] update codestyle --- src/Aggregate/AggregateRoot.php | 6 +- src/Aggregate/ApplyMethodNotFound.php | 4 +- src/Attribute/Aggregate.php | 5 +- src/Attribute/Apply.php | 16 +--- src/Attribute/Event.php | 5 +- src/Attribute/Handle.php | 14 +-- src/Attribute/NormalizedName.php | 5 +- src/Attribute/Snapshot.php | 13 +-- src/Attribute/SuppressMissingApply.php | 8 +- src/Clock/FrozenClock.php | 4 +- src/Console/Command/DatabaseCreateCommand.php | 10 +- src/Console/Command/DatabaseDropCommand.php | 10 +- src/Console/Command/DebugCommand.php | 8 +- src/Console/Command/OutboxConsumeCommand.php | 18 ++-- src/Console/Command/OutboxInfoCommand.php | 10 +- src/Console/Command/ProjectionCommand.php | 28 ++---- .../Command/ProjectionCreateCommand.php | 2 +- src/Console/Command/ProjectionDropCommand.php | 2 +- .../Command/ProjectionRebuildCommand.php | 12 +-- .../Command/ProjectionistBootCommand.php | 2 +- src/Console/Command/ProjectionistCommand.php | 18 ++-- .../ProjectionistReactivateCommand.php | 2 +- .../Command/ProjectionistRemoveCommand.php | 2 +- .../Command/ProjectionistRunCommand.php | 16 ++-- .../Command/ProjectionistStatusCommand.php | 6 +- .../Command/ProjectionistTeardownCommand.php | 2 +- src/Console/Command/SchemaCreateCommand.php | 10 +- src/Console/Command/SchemaDropCommand.php | 10 +- src/Console/Command/SchemaUpdateCommand.php | 10 +- src/Console/Command/ShowCommand.php | 14 +-- src/Console/Command/WatchCommand.php | 12 +-- src/Console/DoctrineHelper.php | 26 ++--- src/Console/InputHelper.php | 4 +- src/Console/InvalidArgumentGiven.php | 10 +- src/Console/Worker/Bytes.php | 2 +- src/Console/Worker/DefaultWorker.php | 2 +- .../Worker/Event/WorkerRunningEvent.php | 2 +- .../Worker/Event/WorkerStartedEvent.php | 2 +- .../Worker/Event/WorkerStoppedEvent.php | 2 +- .../StopWorkerOnIterationLimitListener.php | 12 +-- .../StopWorkerOnMemoryLimitListener.php | 8 +- .../StopWorkerOnSigtermSignalListener.php | 6 +- .../StopWorkerOnTimeLimitListener.php | 12 +-- src/Console/Worker/Worker.php | 4 +- .../Decorator/ChainMessageDecorator.php | 6 +- .../Decorator/RecordedOnDecorator.php | 2 +- src/EventBus/DefaultEventBus.php | 10 +- src/EventBus/DuplicateHandleMethod.php | 4 +- src/EventBus/Message.php | 54 +++-------- src/EventBus/Subscriber.php | 4 +- src/EventBus/SymfonyEventBus.php | 11 +-- src/Lock/DoctrineDbalStoreSchemaAdapter.php | 2 +- .../AggregateRoot/AggregateRootMetadata.php | 6 +- .../AggregateRootMetadataFactory.php | 4 +- .../AggregateRootNameNotRegistered.php | 2 +- .../AggregateRootPropertyMetadata.php | 2 +- .../AggregateRoot/AggregateRootRegistry.php | 20 +--- .../AggregateRootRegistryFactory.php | 4 +- .../AttributeAggregateRootMetadataFactory.php | 24 ++--- .../AttributeAggregateRootRegistryFactory.php | 4 +- .../AggregateRoot/DuplicateApplyMethod.php | 4 +- .../DuplicateEmptyApplyAttribute.php | 2 +- .../MixedApplyAttributeUsage.php | 2 +- .../AggregateRoot/NoAggregateRoot.php | 4 +- .../Event/AttributeEventMetadataFactory.php | 14 +-- .../Event/AttributeEventRegistryFactory.php | 4 +- src/Metadata/Event/EventMetadataFactory.php | 4 +- src/Metadata/Event/EventNameNotRegistered.php | 2 +- src/Metadata/Event/EventPropertyMetadata.php | 2 +- src/Metadata/Event/EventRegistry.php | 16 +--- src/Metadata/Event/EventRegistryFactory.php | 4 +- .../AttributeProjectionMetadataFactory.php | 12 +-- .../Projection/DuplicateCreateMethod.php | 6 +- .../Projection/DuplicateDropMethod.php | 6 +- .../Projection/DuplicateHandleMethod.php | 4 +- .../Projection/ProjectionMetadata.php | 4 +- .../Projection/ProjectionMetadataFactory.php | 4 +- src/Outbox/OutboxConsumer.php | 2 +- src/Outbox/StoreOutboxConsumer.php | 2 +- src/Pipeline/Middleware/ChainMiddleware.php | 10 +- .../ExcludeArchivedEventMiddleware.php | 4 +- .../Middleware/ExcludeEventMiddleware.php | 14 +-- .../Middleware/FilterEventMiddleware.php | 8 +- .../Middleware/IncludeEventMiddleware.php | 14 +-- src/Pipeline/Middleware/Middleware.php | 4 +- .../OnlyArchivedEventMiddleware.php | 4 +- .../RecalculatePlayheadMiddleware.php | 4 +- .../Middleware/ReplaceEventMiddleware.php | 14 +-- .../Middleware/UntilEventMiddleware.php | 9 +- src/Pipeline/Pipeline.php | 12 +-- src/Pipeline/Source/InMemorySource.php | 14 +-- src/Pipeline/Source/Source.php | 4 +- src/Pipeline/Source/StoreSource.php | 11 +-- src/Pipeline/Target/InMemoryTarget.php | 4 +- .../Target/ProjectionHandlerTarget.php | 9 +- src/Pipeline/Target/ProjectionTarget.php | 8 +- .../Target/ProjectorRepositoryTarget.php | 2 +- src/Pipeline/Target/ProjectorTarget.php | 2 +- src/Pipeline/Target/StoreTarget.php | 5 +- .../MetadataAwareProjectionHandler.php | 18 +--- src/Projection/Projection.php | 4 +- src/Projection/Projection/Projection.php | 2 +- .../Projection/ProjectionCollection.php | 22 ++--- .../Projection/ProjectionCriteria.php | 10 +- src/Projection/Projection/ProjectionId.php | 6 +- .../Projection/Store/DoctrineStore.php | 18 ++-- src/Projection/ProjectionHandler.php | 4 +- src/Projection/ProjectionListener.php | 9 +- .../Projectionist/DefaultProjectionist.php | 42 ++++---- .../Projectionist/Projectionist.php | 8 +- .../Projector/InMemoryProjectorRepository.php | 8 +- .../Projector/MetadataProjectorResolver.php | 8 +- src/Projection/Projector/ProjectorHelper.php | 2 +- .../Projector/ProjectorRepository.php | 4 +- .../Projector/ProjectorResolver.php | 6 +- src/Repository/DefaultRepository.php | 55 ++++------- src/Repository/DefaultRepositoryManager.php | 22 ++--- src/Repository/InvalidAggregateClass.php | 8 +- src/Repository/PlayheadMismatch.php | 2 +- src/Repository/Repository.php | 12 +-- src/Repository/SnapshotRebuildFailed.php | 21 +--- src/Repository/WrongAggregate.php | 2 +- src/Schema/ChainSchemaConfigurator.php | 6 +- .../DoctrineMigrationSchemaProvider.php | 2 +- src/Schema/DoctrineSchemaDirector.php | 12 +-- src/Schema/DoctrineSchemaManager.php | 16 +--- src/Schema/DoctrineSchemaSubscriber.php | 8 +- src/Schema/DryRunSchemaDirector.php | 12 +-- src/Schema/DryRunSchemaManager.php | 16 +--- src/Schema/MigrationSchemaProvider.php | 6 +- src/Schema/SchemaManager.php | 4 +- src/Schema/StoreNotSupported.php | 12 +-- src/Serializer/DefaultEventSerializer.php | 35 ++----- src/Serializer/Encoder/DecodeNotPossible.php | 10 +- src/Serializer/Encoder/EncodeNotPossible.php | 17 +--- src/Serializer/EventSerializer.php | 8 +- .../Hydrator/AggregateRootHydrator.php | 4 +- .../Hydrator/DenormalizationFailure.php | 4 +- src/Serializer/Hydrator/EventHydrator.php | 4 +- .../MetadataAggregateRootHydrator.php | 12 +-- .../Hydrator/MetadataEventHydrator.php | 15 +-- .../Hydrator/NormalizationFailure.php | 4 +- src/Serializer/Hydrator/TypeMismatch.php | 10 +- src/Serializer/Normalizer/ArrayNormalizer.php | 12 +-- .../DateTimeImmutableNormalizer.php | 6 +- .../Normalizer/DateTimeNormalizer.php | 6 +- .../Normalizer/DateTimeZoneNormalizer.php | 4 +- src/Serializer/Normalizer/EnumNormalizer.php | 4 +- src/Serializer/Normalizer/Normalizer.php | 8 +- src/Serializer/SerializedEvent.php | 2 +- src/Serializer/Upcast/Upcast.php | 14 +-- src/Serializer/Upcast/UpcasterChain.php | 6 +- .../Adapter/InMemorySnapshotAdapter.php | 8 +- src/Snapshot/Adapter/Psr16SnapshotAdapter.php | 17 +--- src/Snapshot/Adapter/Psr6SnapshotAdapter.php | 13 +-- src/Snapshot/Adapter/SnapshotAdapter.php | 4 +- src/Snapshot/Adapter/SnapshotNotFound.php | 4 +- src/Snapshot/AdapterNotFound.php | 2 +- src/Snapshot/DefaultSnapshotStore.php | 24 ++--- src/Snapshot/Snapshot.php | 21 +--- src/Snapshot/SnapshotNotConfigured.php | 8 +- src/Snapshot/SnapshotNotFound.php | 10 +- src/Snapshot/SnapshotVersionInvalid.php | 4 +- src/Store/CorruptedMetadata.php | 4 +- src/Store/DoctrineStore.php | 30 +++--- src/Store/MultiTableStore.php | 34 +++---- src/Store/OutboxStore.php | 6 +- src/Store/PipelineStore.php | 4 +- src/Store/SingleTableStore.php | 30 ++---- src/Store/SplitEventstreamStore.php | 4 +- src/Store/Store.php | 4 +- src/Store/StreamableStore.php | 4 +- .../PhpNativeMessageSerializer.php | 11 +-- src/WatchServer/SocketWatchServer.php | 8 +- src/WatchServer/SocketWatchServerClient.php | 15 +-- src/WatchServer/WatchListener.php | 7 +- src/WatchServer/WatchServer.php | 4 +- .../Events/NameChanged.php | 2 +- .../Events/ProfileCreated.php | 2 +- .../Normalizer/ProfileIdNormalizer.php | 2 +- .../BasicImplementation/ProfileId.php | 5 +- .../Projection/ProfileProjector.php | 7 +- tests/Benchmark/LoadEventsBench.php | 4 +- .../LoadEventsWithSnapshotsBench.php | 4 +- tests/Benchmark/WriteEventsBench.php | 6 +- .../BankAccountSplitStream/AccountId.php | 5 +- .../Aggregate/BankAccount.php | 4 +- .../IntegrationTest.php | 22 ++--- .../Normalizer/AccountIdNormalizer.php | 2 +- .../Projection/BankAccountProjection.php | 9 +- .../BasicIntegrationTest.php | 42 ++++---- .../Events/ProfileCreated.php | 2 +- .../Normalizer/ProfileIdNormalizer.php | 2 +- .../BasicImplementation/ProfileId.php | 5 +- .../Projection/ProfileProjection.php | 7 +- .../Outbox/Events/ProfileCreated.php | 2 +- .../Outbox/Normalizer/ProfileIdNormalizer.php | 2 +- tests/Integration/Outbox/OutboxTest.php | 12 +-- tests/Integration/Outbox/ProfileId.php | 5 +- .../Outbox/Projection/ProfileProjection.php | 7 +- .../EventNormalizer/ProfileIdNormalizer.php | 2 +- .../Pipeline/Events/NewVisited.php | 2 +- .../Pipeline/Events/OldVisited.php | 2 +- .../Pipeline/Events/PrivacyAdded.php | 2 +- .../Pipeline/Events/ProfileCreated.php | 2 +- .../Pipeline/PipelineChangeStoreTest.php | 14 ++- tests/Integration/Pipeline/ProfileId.php | 5 +- .../Projectionist/Events/ProfileCreated.php | 2 +- .../Normalizer/ProfileIdNormalizer.php | 2 +- tests/Integration/Projectionist/ProfileId.php | 5 +- .../Projection/ProfileProjection.php | 9 +- .../Projectionist/ProjectionistTest.php | 18 ++-- tests/Unit/Aggregate/AggregateRootTest.php | 4 +- .../Aggregate/ApplyMethodNotFoundTest.php | 2 +- .../Command/DatabaseCreateCommandTest.php | 8 +- .../Command/DatabaseDropCommandTest.php | 10 +- .../Unit/Console/Command/DebugCommandTest.php | 2 +- .../Console/Command/OutboxInfoCommandTest.php | 4 +- .../Command/ProjectionCreateCommandTest.php | 4 +- .../Command/ProjectionDropCommandTest.php | 4 +- .../Command/ProjectionRebuildCommandTest.php | 24 +++-- .../Command/SchemaCreateCommandTest.php | 6 +- .../Console/Command/SchemaDropCommandTest.php | 10 +- .../Command/SchemaUpdateCommandTest.php | 10 +- .../Unit/Console/Command/ShowCommandTest.php | 26 ++--- .../Unit/Console/Command/WatchCommandTest.php | 2 +- tests/Unit/Console/OutputStyleTest.php | 2 +- tests/Unit/Console/Worker/BytesTest.php | 8 +- .../Unit/Console/Worker/DefaultWorkerTest.php | 2 +- .../Decorator/ChainMessageDecoratorTest.php | 4 +- tests/Unit/EventBus/DefaultEventBusTest.php | 52 +++++----- tests/Unit/EventBus/MessageTest.php | 16 ++-- tests/Unit/EventBus/SubscriberTest.php | 36 +++---- tests/Unit/EventBus/SymfonyEventBusTest.php | 18 ++-- tests/Unit/Fixture/Dummy2Projection.php | 2 +- tests/Unit/Fixture/DummyProjection.php | 2 +- tests/Unit/Fixture/Email.php | 5 +- tests/Unit/Fixture/EmailNormalizer.php | 2 +- tests/Unit/Fixture/Message.php | 17 +--- tests/Unit/Fixture/MessageDeleted.php | 2 +- tests/Unit/Fixture/MessageId.php | 5 +- tests/Unit/Fixture/MessageNormalizer.php | 8 +- tests/Unit/Fixture/MessagePublished.php | 2 +- tests/Unit/Fixture/NameChanged.php | 2 +- .../Fixture/NotNormalizedProfileCreated.php | 2 +- tests/Unit/Fixture/Profile.php | 4 +- tests/Unit/Fixture/ProfileId.php | 5 +- tests/Unit/Fixture/ProfileIdNormalizer.php | 2 +- tests/Unit/Fixture/ProfileVisited.php | 2 +- .../Fixture/ProfileWithBrokenApplyNoType.php | 4 +- tests/Unit/Fixture/ProfileWithSnapshot.php | 6 +- tests/Unit/Fixture/SimpleEvent.php | 2 +- tests/Unit/Fixture/WrongNormalizerEvent.php | 2 +- .../AttributeAggregateMetadataFactoryTest.php | 6 +- .../AttributeEventMetadataFactoryTest.php | 23 +++-- ...AttributeProjectionMetadataFactoryTest.php | 4 +- tests/Unit/Outbox/OutboxEventBusTest.php | 12 +-- tests/Unit/Outbox/StoreOutboxConsumerTest.php | 8 +- .../Middleware/ChainMiddlewareTest.php | 4 +- .../ExcludeArchivedEventMiddlewareTest.php | 8 +- .../Middleware/ExcludeEventMiddlewareTest.php | 8 +- .../Middleware/FilterEventMiddlewareTest.php | 8 +- .../Middleware/IncludeEventMiddlewareTest.php | 8 +- .../OnlyArchivedEventMiddlewareTest.php | 8 +- .../RecalculatePlayheadMiddlewareTest.php | 4 +- .../Middleware/ReplaceEventMiddlewareTest.php | 16 ++-- .../Middleware/UntilEventMiddlewareTest.php | 8 +- tests/Unit/Pipeline/PipelineTest.php | 26 +++-- .../Pipeline/Source/InMemorySourceTest.php | 4 +- .../Unit/Pipeline/Source/StoreSourceTest.php | 4 +- .../Pipeline/Target/InMemoryTargetTest.php | 2 +- .../Target/ProjectionHandlerTargetTest.php | 2 +- .../Pipeline/Target/ProjectionTargetTest.php | 4 +- .../Unit/Pipeline/Target/StoreTargetTest.php | 2 +- tests/Unit/Projection/DummyStore.php | 4 +- .../MetadataAwareProjectionHandlerTest.php | 16 ++-- .../Projection/ProjectionCollectionTest.php | 6 +- .../Projection/ProjectionIdTest.php | 26 ++--- .../Projection/Projection/ProjectionTest.php | 10 +- .../Projection/ProjectionListenerTest.php | 4 +- .../DefaultProjectionistTest.php | 58 +++++------ .../RunProjectionistEventBusWrapperTest.php | 2 +- .../MetadataProjectorResolverTest.php | 10 +- .../Projector/ProjectorHelperTest.php | 12 +-- .../Projector/SyncProjectorListenerTest.php | 16 ++-- .../DefaultRepositoryManagerTest.php | 6 +- .../Unit/Repository/DefaultRepositoryTest.php | 96 +++++++++---------- .../Schema/DoctrineSchemaDirectorTest.php | 12 +-- .../Unit/Schema/DoctrineSchemaManagerTest.php | 8 +- .../Serializer/DefaultEventSerializerTest.php | 26 ++--- .../Serializer/Encoder/JsonEncoderTest.php | 4 +- .../MetadataAggregateRootHydratorTest.php | 6 +- .../Hydrator/MetadataEventHydratorTest.php | 14 +-- tests/Unit/Serializer/Upcast/UpcastTest.php | 4 +- .../Serializer/Upcast/UpcasterChainTest.php | 2 +- .../Snapshot/DefaultSnapshotStoreTest.php | 14 +-- tests/Unit/Snapshot/SnapshotTest.php | 2 +- tests/Unit/Store/MultiTableStoreTest.php | 30 +++--- tests/Unit/Store/SingleTableStoreTest.php | 30 +++--- .../PhpNativeMessageSerializerTest.php | 6 +- 300 files changed, 1043 insertions(+), 1746 deletions(-) diff --git a/src/Aggregate/AggregateRoot.php b/src/Aggregate/AggregateRoot.php index dd7104d1d..48cfa1c2c 100644 --- a/src/Aggregate/AggregateRoot.php +++ b/src/Aggregate/AggregateRoot.php @@ -12,7 +12,7 @@ abstract class AggregateRoot { - private static ?AggregateRootMetadataFactory $metadataFactory = null; + private static AggregateRootMetadataFactory|null $metadataFactory = null; /** @var list */ private array $uncommittedEvents = []; @@ -63,9 +63,7 @@ final public function catchUp(array $events): void } } - /** - * @return list - */ + /** @return list */ final public function releaseEvents(): array { $events = $this->uncommittedEvents; diff --git a/src/Aggregate/ApplyMethodNotFound.php b/src/Aggregate/ApplyMethodNotFound.php index 2b91f2789..9b25b1ac6 100644 --- a/src/Aggregate/ApplyMethodNotFound.php +++ b/src/Aggregate/ApplyMethodNotFound.php @@ -18,8 +18,8 @@ public function __construct(string $aggregate, string $event) sprintf( 'Apply method in "%s" could not be found for the event "%s"', $aggregate, - $event - ) + $event, + ), ); } } diff --git a/src/Attribute/Aggregate.php b/src/Attribute/Aggregate.php index 335eb030a..c79ede787 100644 --- a/src/Attribute/Aggregate.php +++ b/src/Attribute/Aggregate.php @@ -9,11 +9,8 @@ #[Attribute(Attribute::TARGET_CLASS)] final class Aggregate { - private string $name; - - public function __construct(string $name) + public function __construct(private string $name) { - $this->name = $name; } public function name(): string diff --git a/src/Attribute/Apply.php b/src/Attribute/Apply.php index 48108a93b..55716b032 100644 --- a/src/Attribute/Apply.php +++ b/src/Attribute/Apply.php @@ -9,21 +9,13 @@ #[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] final class Apply { - /** @var class-string|null */ - private ?string $eventClass; - - /** - * @param class-string|null $eventClass - */ - public function __construct(?string $eventClass = null) + /** @param class-string|null $eventClass */ + public function __construct(private string|null $eventClass = null) { - $this->eventClass = $eventClass; } - /** - * @return class-string|null - */ - public function eventClass(): ?string + /** @return class-string|null */ + public function eventClass(): string|null { return $this->eventClass; } diff --git a/src/Attribute/Event.php b/src/Attribute/Event.php index 9caf82e7c..fe171191f 100644 --- a/src/Attribute/Event.php +++ b/src/Attribute/Event.php @@ -9,11 +9,8 @@ #[Attribute(Attribute::TARGET_CLASS)] final class Event { - private string $name; - - public function __construct(string $name) + public function __construct(private string $name) { - $this->name = $name; } public function name(): string diff --git a/src/Attribute/Handle.php b/src/Attribute/Handle.php index 3561de2c1..23b0c453c 100644 --- a/src/Attribute/Handle.php +++ b/src/Attribute/Handle.php @@ -9,20 +9,12 @@ #[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] final class Handle { - /** @var class-string */ - private string $eventClass; - - /** - * @param class-string $eventClass - */ - public function __construct(string $eventClass) + /** @param class-string $eventClass */ + public function __construct(private string $eventClass) { - $this->eventClass = $eventClass; } - /** - * @return class-string - */ + /** @return class-string */ public function eventClass(): string { return $this->eventClass; diff --git a/src/Attribute/NormalizedName.php b/src/Attribute/NormalizedName.php index 7062af7e3..e79f52fd6 100644 --- a/src/Attribute/NormalizedName.php +++ b/src/Attribute/NormalizedName.php @@ -9,11 +9,8 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class NormalizedName { - private string $name; - - public function __construct(string $name) + public function __construct(private string $name) { - $this->name = $name; } public function name(): string diff --git a/src/Attribute/Snapshot.php b/src/Attribute/Snapshot.php index 90fcc1f5c..090ac5f0f 100644 --- a/src/Attribute/Snapshot.php +++ b/src/Attribute/Snapshot.php @@ -9,15 +9,8 @@ #[Attribute(Attribute::TARGET_CLASS)] final class Snapshot { - private string $name; - private ?int $batch; - private ?string $version; - - public function __construct(string $name, ?int $batch = null, ?string $version = null) + public function __construct(private string $name, private int|null $batch = null, private string|null $version = null) { - $this->name = $name; - $this->batch = $batch; - $this->version = $version; } public function name(): string @@ -25,12 +18,12 @@ public function name(): string return $this->name; } - public function batch(): ?int + public function batch(): int|null { return $this->batch; } - public function version(): ?string + public function version(): string|null { return $this->version; } diff --git a/src/Attribute/SuppressMissingApply.php b/src/Attribute/SuppressMissingApply.php index 477708c19..0abd54a1b 100644 --- a/src/Attribute/SuppressMissingApply.php +++ b/src/Attribute/SuppressMissingApply.php @@ -15,9 +15,7 @@ final class SuppressMissingApply private array $suppressEvents = []; private bool $suppressAll = false; - /** - * @param list|self::ALL $suppress - */ + /** @param list|self::ALL $suppress */ public function __construct(string|array $suppress) { if ($suppress === self::ALL) { @@ -29,9 +27,7 @@ public function __construct(string|array $suppress) $this->suppressEvents = $suppress; } - /** - * @return list - */ + /** @return list */ public function suppressEvents(): array { return $this->suppressEvents; diff --git a/src/Clock/FrozenClock.php b/src/Clock/FrozenClock.php index 38fab7230..2c73974ca 100644 --- a/src/Clock/FrozenClock.php +++ b/src/Clock/FrozenClock.php @@ -24,9 +24,7 @@ public function update(DateTimeImmutable $frozenDateTime): void $this->frozenDateTime = $frozenDateTime; } - /** - * @param positive-int $seconds - */ + /** @param positive-int $seconds */ public function sleep(int $seconds): void { $this->frozenDateTime = $this->frozenDateTime->modify(sprintf('+%s seconds', $seconds)); diff --git a/src/Console/Command/DatabaseCreateCommand.php b/src/Console/Command/DatabaseCreateCommand.php index 9670fd04a..72f024c25 100644 --- a/src/Console/Command/DatabaseCreateCommand.php +++ b/src/Console/Command/DatabaseCreateCommand.php @@ -20,19 +20,13 @@ #[AsCommand( 'event-sourcing:database:create', - 'create eventstore database' + 'create eventstore database', )] final class DatabaseCreateCommand extends Command { - private Store $store; - private DoctrineHelper $helper; - - public function __construct(Store $store, DoctrineHelper $helper) + public function __construct(private Store $store, private DoctrineHelper $helper) { parent::__construct(); - - $this->store = $store; - $this->helper = $helper; } protected function configure(): void diff --git a/src/Console/Command/DatabaseDropCommand.php b/src/Console/Command/DatabaseDropCommand.php index 0c7f67f09..68c8680f6 100644 --- a/src/Console/Command/DatabaseDropCommand.php +++ b/src/Console/Command/DatabaseDropCommand.php @@ -20,19 +20,13 @@ #[AsCommand( 'event-sourcing:database:drop', - 'drop eventstore database' + 'drop eventstore database', )] final class DatabaseDropCommand extends Command { - private Store $store; - private DoctrineHelper $helper; - - public function __construct(Store $store, DoctrineHelper $helper) + public function __construct(private Store $store, private DoctrineHelper $helper) { parent::__construct(); - - $this->store = $store; - $this->helper = $helper; } protected function configure(): void diff --git a/src/Console/Command/DebugCommand.php b/src/Console/Command/DebugCommand.php index 46266fe02..ba63a1ce8 100644 --- a/src/Console/Command/DebugCommand.php +++ b/src/Console/Command/DebugCommand.php @@ -19,13 +19,13 @@ #[AsCommand( 'event-sourcing:debug', 'show event sourcing debug information', - ['debug:event-sourcing'] + ['debug:event-sourcing'], )] final class DebugCommand extends Command { public function __construct( private readonly AggregateRootRegistry $aggregateRootRegistry, - private readonly EventRegistry $eventRegistry + private readonly EventRegistry $eventRegistry, ) { parent::__construct(); } @@ -48,7 +48,7 @@ private function showAggregates(OutputStyle $console): void $console->table( ['name', 'class'], - array_map(null, array_keys($aggregates), array_values($aggregates)) + array_map(null, array_keys($aggregates), array_values($aggregates)), ); } @@ -60,7 +60,7 @@ private function showEvents(OutputStyle $console): void $console->table( ['name', 'class'], - array_map(null, array_keys($events), array_values($events)) + array_map(null, array_keys($events), array_values($events)), ); } } diff --git a/src/Console/Command/OutboxConsumeCommand.php b/src/Console/Command/OutboxConsumeCommand.php index 0557d1251..cf13187f8 100644 --- a/src/Console/Command/OutboxConsumeCommand.php +++ b/src/Console/Command/OutboxConsumeCommand.php @@ -23,12 +23,12 @@ #[AsCommand( 'event-sourcing:outbox:consume', - 'published the messages from the outbox store' + 'published the messages from the outbox store', )] final class OutboxConsumeCommand extends Command { public function __construct( - private readonly OutboxConsumer $consumer + private readonly OutboxConsumer $consumer, ) { parent::__construct(); } @@ -40,40 +40,40 @@ protected function configure(): void 'limit', null, InputOption::VALUE_REQUIRED, - 'How many messages should be consumed in one run (deprecated: use "message-limit" option)' + 'How many messages should be consumed in one run (deprecated: use "message-limit" option)', ) ->addOption( 'message-limit', null, InputOption::VALUE_REQUIRED, 'How many messages should be consumed in one run', - 100 + 100, ) ->addOption( 'run-limit', null, InputOption::VALUE_OPTIONAL, 'The maximum number of runs this command should execute', - 1 + 1, ) ->addOption( 'memory-limit', null, InputOption::VALUE_REQUIRED, - 'How much memory consumption should the worker be terminated' + 'How much memory consumption should the worker be terminated', ) ->addOption( 'time-limit', null, InputOption::VALUE_REQUIRED, - 'What is the maximum time the worker can run in seconds' + 'What is the maximum time the worker can run in seconds', ) ->addOption( 'sleep', null, InputOption::VALUE_REQUIRED, 'How much time should elapse before the next job is executed in microseconds', - 1000 + 1000, ); } @@ -121,7 +121,7 @@ function () use ($messageLimit): void { $this->consumer->consume($messageLimit); }, $eventDispatcher, - $logger + $logger, ); if ($sleep < 0) { diff --git a/src/Console/Command/OutboxInfoCommand.php b/src/Console/Command/OutboxInfoCommand.php index 4ead60a71..77c84bfe9 100644 --- a/src/Console/Command/OutboxInfoCommand.php +++ b/src/Console/Command/OutboxInfoCommand.php @@ -16,19 +16,13 @@ #[AsCommand( 'event-sourcing:outbox:info', - 'displays the messages stored in the outbox store' + 'displays the messages stored in the outbox store', )] final class OutboxInfoCommand extends Command { - private OutboxStore $store; - private EventSerializer $serializer; - - public function __construct(OutboxStore $store, EventSerializer $serializer) + public function __construct(private OutboxStore $store, private EventSerializer $serializer) { parent::__construct(); - - $this->store = $store; - $this->serializer = $serializer; } protected function configure(): void diff --git a/src/Console/Command/ProjectionCommand.php b/src/Console/Command/ProjectionCommand.php index 0565d4db8..580687fcd 100644 --- a/src/Console/Command/ProjectionCommand.php +++ b/src/Console/Command/ProjectionCommand.php @@ -21,13 +21,9 @@ abstract class ProjectionCommand extends Command { - private ProjectionHandler $projectionHandler; - - public function __construct(ProjectionHandler $projectionHandler) + public function __construct(private ProjectionHandler $projectionHandler) { parent::__construct(); - - $this->projectionHandler = $projectionHandler; } protected function projectionHandler(mixed $projectionOption): ProjectionHandler @@ -40,14 +36,12 @@ protected function projectionHandler(mixed $projectionOption): ProjectionHandler return $this->filterProjectionInProjectionHandler( $this->projectionHandler, - $normalizedProjectionOption + $normalizedProjectionOption, ); } - /** - * @return non-empty-array>|null - */ - private function normalizeProjectionOption(mixed $option): ?array + /** @return non-empty-array>|null */ + private function normalizeProjectionOption(mixed $option): array|null { if (is_string($option)) { $option = [$option]; @@ -74,20 +68,18 @@ private function normalizeProjectionOption(mixed $option): ?array return $result; } - /** - * @param non-empty-array> $onlyProjections - */ + /** @param non-empty-array> $onlyProjections */ private function filterProjectionInProjectionHandler( ProjectionHandler $projectionHandler, - array $onlyProjections + array $onlyProjections, ): MetadataAwareProjectionHandler { if (!$projectionHandler instanceof MetadataAwareProjectionHandler) { throw new InvalidArgumentException( sprintf( 'Filtering projections is only supported with "%s", but "%s" was used.', MetadataAwareProjectionHandler::class, - $projectionHandler::class - ) + $projectionHandler::class, + ), ); } @@ -95,12 +87,12 @@ private function filterProjectionInProjectionHandler( array_filter( [...$projectionHandler->projections()], static fn (Projection $projection): bool => in_array($projection::class, $onlyProjections) - ) + ), ); return new MetadataAwareProjectionHandler( $projections, - $projectionHandler->metadataFactory() + $projectionHandler->metadataFactory(), ); } } diff --git a/src/Console/Command/ProjectionCreateCommand.php b/src/Console/Command/ProjectionCreateCommand.php index ed61afee2..2ea769d05 100644 --- a/src/Console/Command/ProjectionCreateCommand.php +++ b/src/Console/Command/ProjectionCreateCommand.php @@ -12,7 +12,7 @@ #[AsCommand( 'event-sourcing:projection:create', - 'create projection schema' + 'create projection schema', )] final class ProjectionCreateCommand extends ProjectionCommand { diff --git a/src/Console/Command/ProjectionDropCommand.php b/src/Console/Command/ProjectionDropCommand.php index e4a866c84..e926d286c 100644 --- a/src/Console/Command/ProjectionDropCommand.php +++ b/src/Console/Command/ProjectionDropCommand.php @@ -12,7 +12,7 @@ #[AsCommand( 'event-sourcing:projection:drop', - 'drop projection schema' + 'drop projection schema', )] final class ProjectionDropCommand extends ProjectionCommand { diff --git a/src/Console/Command/ProjectionRebuildCommand.php b/src/Console/Command/ProjectionRebuildCommand.php index b749f8323..35d6878e4 100644 --- a/src/Console/Command/ProjectionRebuildCommand.php +++ b/src/Console/Command/ProjectionRebuildCommand.php @@ -25,17 +25,13 @@ #[AsCommand( 'event-sourcing:projection:rebuild', - 'rebuild projection' + 'rebuild projection', )] final class ProjectionRebuildCommand extends ProjectionCommand { - private Store $store; - - public function __construct(Store $store, ProjectionHandler $projectionHandler) + public function __construct(private Store $store, ProjectionHandler $projectionHandler) { parent::__construct($projectionHandler); - - $this->store = $store; } protected function configure(): void @@ -75,7 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (is_string($until)) { try { $date = new DateTimeImmutable($until); - } catch (Throwable $exception) { + } catch (Throwable) { $console->error(sprintf('date "%s" not supported. the format should be "2017-02-02 12:00"', $until)); return 1; @@ -87,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $pipeline = new Pipeline( new StoreSource($store), new ProjectionHandlerTarget($projectionHandler), - $middlewares + $middlewares, ); $console->warning('rebuild projections'); diff --git a/src/Console/Command/ProjectionistBootCommand.php b/src/Console/Command/ProjectionistBootCommand.php index 2e8e46f44..5c29a7e0b 100644 --- a/src/Console/Command/ProjectionistBootCommand.php +++ b/src/Console/Command/ProjectionistBootCommand.php @@ -10,7 +10,7 @@ #[AsCommand( 'event-sourcing:projectionist:boot', - 'Prepare new projections and catch up with the event store' + 'Prepare new projections and catch up with the event store', )] final class ProjectionistBootCommand extends ProjectionistCommand { diff --git a/src/Console/Command/ProjectionistCommand.php b/src/Console/Command/ProjectionistCommand.php index 9c0ab8fee..53b02f754 100644 --- a/src/Console/Command/ProjectionistCommand.php +++ b/src/Console/Command/ProjectionistCommand.php @@ -17,9 +17,7 @@ use function is_array; use function is_string; -/** - * @interal - */ +/** @interal */ abstract class ProjectionistCommand extends Command { public function __construct( @@ -35,21 +33,19 @@ protected function configure(): void 'id', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, - 'filter by projection id' + 'filter by projection id', ); } protected function projectionCriteria(InputInterface $input): ProjectionCriteria { return new ProjectionCriteria( - $this->projectionIds($input) + $this->projectionIds($input), ); } - /** - * @return list|null - */ - private function projectionIds(InputInterface $input): ?array + /** @return list|null */ + private function projectionIds(InputInterface $input): array|null { $ids = $input->getOption('id'); @@ -70,8 +66,8 @@ static function (mixed $id) use ($ids): ProjectionId { return ProjectionId::fromString($id); }, - $ids - ) + $ids, + ), ); } } diff --git a/src/Console/Command/ProjectionistReactivateCommand.php b/src/Console/Command/ProjectionistReactivateCommand.php index 4c3d874c3..631519cd4 100644 --- a/src/Console/Command/ProjectionistReactivateCommand.php +++ b/src/Console/Command/ProjectionistReactivateCommand.php @@ -10,7 +10,7 @@ #[AsCommand( 'event-sourcing:projectionist:reactivate', - 'Reactivate failed projections' + 'Reactivate failed projections', )] final class ProjectionistReactivateCommand extends ProjectionistCommand { diff --git a/src/Console/Command/ProjectionistRemoveCommand.php b/src/Console/Command/ProjectionistRemoveCommand.php index 1251decc3..1cbffe35b 100644 --- a/src/Console/Command/ProjectionistRemoveCommand.php +++ b/src/Console/Command/ProjectionistRemoveCommand.php @@ -11,7 +11,7 @@ #[AsCommand( 'event-sourcing:projectionist:remove', - 'Delete a projection and remove it from the store' + 'Delete a projection and remove it from the store', )] final class ProjectionistRemoveCommand extends ProjectionistCommand { diff --git a/src/Console/Command/ProjectionistRunCommand.php b/src/Console/Command/ProjectionistRunCommand.php index a74e4b60d..0349dff58 100644 --- a/src/Console/Command/ProjectionistRunCommand.php +++ b/src/Console/Command/ProjectionistRunCommand.php @@ -21,7 +21,7 @@ #[AsCommand( 'event-sourcing:projectionist:run', - 'Run the active projectors' + 'Run the active projectors', )] final class ProjectionistRunCommand extends ProjectionistCommand { @@ -34,33 +34,33 @@ protected function configure(): void 'run-limit', null, InputOption::VALUE_REQUIRED, - 'The maximum number of runs this command should execute' + 'The maximum number of runs this command should execute', ) ->addOption( 'message-limit', null, InputOption::VALUE_REQUIRED, 'How many messages should be consumed in one run', - 100 + 100, ) ->addOption( 'memory-limit', null, InputOption::VALUE_REQUIRED, - 'How much memory consumption should the worker be terminated' + 'How much memory consumption should the worker be terminated', ) ->addOption( 'time-limit', null, InputOption::VALUE_REQUIRED, - 'What is the maximum time the worker can run in seconds' + 'What is the maximum time the worker can run in seconds', ) ->addOption( 'sleep', null, InputOption::VALUE_REQUIRED, 'How much time should elapse before the next job is executed in microseconds', - 1000 + 1000, ); } @@ -88,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($memoryLimit) { $eventDispatcher->addSubscriber( - new StopWorkerOnMemoryLimitListener(Bytes::parseFromString($memoryLimit), $logger) + new StopWorkerOnMemoryLimitListener(Bytes::parseFromString($memoryLimit), $logger), ); } @@ -109,7 +109,7 @@ function () use ($criteria, $messageLimit): void { $this->projectionist->run($criteria, $messageLimit); }, $eventDispatcher, - $logger + $logger, ); if ($sleep < 0) { diff --git a/src/Console/Command/ProjectionistStatusCommand.php b/src/Console/Command/ProjectionistStatusCommand.php index 2d7091f13..bd8e584ae 100644 --- a/src/Console/Command/ProjectionistStatusCommand.php +++ b/src/Console/Command/ProjectionistStatusCommand.php @@ -14,7 +14,7 @@ #[AsCommand( 'event-sourcing:projectionist:status', - 'View the current status of the projections' + 'View the current status of the projections', )] final class ProjectionistStatusCommand extends ProjectionistCommand { @@ -37,8 +37,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $projection->position(), $projection->status()->value, ], - [...$projections] - ) + [...$projections], + ), ); return 0; diff --git a/src/Console/Command/ProjectionistTeardownCommand.php b/src/Console/Command/ProjectionistTeardownCommand.php index de83dfb4a..d63aa2d40 100644 --- a/src/Console/Command/ProjectionistTeardownCommand.php +++ b/src/Console/Command/ProjectionistTeardownCommand.php @@ -10,7 +10,7 @@ #[AsCommand( 'event-sourcing:projectionist:teardown', - 'Shut down and delete the outdated projections' + 'Shut down and delete the outdated projections', )] final class ProjectionistTeardownCommand extends ProjectionistCommand { diff --git a/src/Console/Command/SchemaCreateCommand.php b/src/Console/Command/SchemaCreateCommand.php index 5312b740b..3136d3622 100644 --- a/src/Console/Command/SchemaCreateCommand.php +++ b/src/Console/Command/SchemaCreateCommand.php @@ -19,19 +19,13 @@ #[AsCommand( 'event-sourcing:schema:create', - 'create eventstore schema' + 'create eventstore schema', )] final class SchemaCreateCommand extends Command { - private Store $store; - private SchemaManager|SchemaDirector $schemaDirector; - - public function __construct(Store $store, SchemaManager|SchemaDirector $schemaDirector) + public function __construct(private Store $store, private SchemaManager|SchemaDirector $schemaDirector) { parent::__construct(); - - $this->store = $store; - $this->schemaDirector = $schemaDirector; } protected function configure(): void diff --git a/src/Console/Command/SchemaDropCommand.php b/src/Console/Command/SchemaDropCommand.php index cc15041ea..e01dc7204 100644 --- a/src/Console/Command/SchemaDropCommand.php +++ b/src/Console/Command/SchemaDropCommand.php @@ -19,19 +19,13 @@ #[AsCommand( 'event-sourcing:schema:drop', - 'drop eventstore schema' + 'drop eventstore schema', )] final class SchemaDropCommand extends Command { - private Store $store; - private SchemaManager|SchemaDirector $schemaDirector; - - public function __construct(Store $store, SchemaManager|SchemaDirector $schemaDirector) + public function __construct(private Store $store, private SchemaManager|SchemaDirector $schemaDirector) { parent::__construct(); - - $this->store = $store; - $this->schemaDirector = $schemaDirector; } protected function configure(): void diff --git a/src/Console/Command/SchemaUpdateCommand.php b/src/Console/Command/SchemaUpdateCommand.php index 165032722..a01b8d05f 100644 --- a/src/Console/Command/SchemaUpdateCommand.php +++ b/src/Console/Command/SchemaUpdateCommand.php @@ -19,19 +19,13 @@ #[AsCommand( 'event-sourcing:schema:update', - 'update eventstore schema' + 'update eventstore schema', )] final class SchemaUpdateCommand extends Command { - private Store $store; - private SchemaManager|SchemaDirector $schemaDirector; - - public function __construct(Store $store, SchemaManager|SchemaDirector $schemaDirector) + public function __construct(private Store $store, private SchemaManager|SchemaDirector $schemaDirector) { parent::__construct(); - - $this->store = $store; - $this->schemaDirector = $schemaDirector; } protected function configure(): void diff --git a/src/Console/Command/ShowCommand.php b/src/Console/Command/ShowCommand.php index 26c5248ed..8d60741ef 100644 --- a/src/Console/Command/ShowCommand.php +++ b/src/Console/Command/ShowCommand.php @@ -23,21 +23,13 @@ #[AsCommand( 'event-sourcing:show', - 'show events from one aggregate' + 'show events from one aggregate', )] final class ShowCommand extends Command { - private Store $store; - private EventSerializer $serializer; - private AggregateRootRegistry $aggregateRootRegistry; - - public function __construct(Store $store, EventSerializer $serializer, AggregateRootRegistry $aggregateRootRegistry) + public function __construct(private Store $store, private EventSerializer $serializer, private AggregateRootRegistry $aggregateRootRegistry) { parent::__construct(); - - $this->store = $store; - $this->serializer = $serializer; - $this->aggregateRootRegistry = $aggregateRootRegistry; } protected function configure(): void @@ -56,7 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $question = new ChoiceQuestion( 'Choose the aggregate', array_values($this->aggregateRootRegistry->aggregateNames()), - null + null, ); $aggregate = InputHelper::string($console->askQuestion($question)); diff --git a/src/Console/Command/WatchCommand.php b/src/Console/Command/WatchCommand.php index 8ba20ba4b..23f6093af 100644 --- a/src/Console/Command/WatchCommand.php +++ b/src/Console/Command/WatchCommand.php @@ -17,19 +17,13 @@ #[AsCommand( 'event-sourcing:watch', - 'live stream of all aggregate events' + 'live stream of all aggregate events', )] final class WatchCommand extends Command { - private WatchServer $server; - private EventSerializer $serializer; - - public function __construct(WatchServer $server, EventSerializer $serializer) + public function __construct(private WatchServer $server, private EventSerializer $serializer) { parent::__construct(); - - $this->server = $server; - $this->serializer = $serializer; } protected function execute(InputInterface $input, OutputInterface $output): int @@ -44,7 +38,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->server->listen( function (Message $message) use ($console): void { $console->message($this->serializer, $message); - } + }, ); return 0; diff --git a/src/Console/DoctrineHelper.php b/src/Console/DoctrineHelper.php index 8050af4f1..921105907 100644 --- a/src/Console/DoctrineHelper.php +++ b/src/Console/DoctrineHelper.php @@ -10,16 +10,12 @@ use function in_array; -/** - * @final - */ +/** @final */ class DoctrineHelper { public function databaseName(Connection $connection): string { - /** - * @psalm-suppress InternalMethod - */ + /** @psalm-suppress InternalMethod */ $params = $connection->getParams(); if (isset($params['path'])) { @@ -31,23 +27,17 @@ public function databaseName(Connection $connection): string } throw new InvalidArgumentException( - "Connection does not contain a 'path' or 'dbname' parameter and cannot be created." + "Connection does not contain a 'path' or 'dbname' parameter and cannot be created.", ); } - /** - * @codeCoverageIgnore - */ + /** @codeCoverageIgnore */ public function copyConnectionWithoutDatabase(Connection $connection): Connection { - /** - * @psalm-suppress InternalMethod - */ + /** @psalm-suppress InternalMethod */ $params = $connection->getParams(); - /** - * @psalm-suppress InvalidArrayOffset - */ + /** @psalm-suppress InvalidArrayOffset */ unset($params['dbname'], $params['path'], $params['url']); return DriverManager::getConnection($params); @@ -61,14 +51,14 @@ public function hasDatabase(Connection $connection, string $databaseName): bool public function createDatabase(Connection $connection, string $databaseName): void { $connection->createSchemaManager()->createDatabase( - $connection->getDatabasePlatform()->quoteSingleIdentifier($databaseName) + $connection->getDatabasePlatform()->quoteSingleIdentifier($databaseName), ); } public function dropDatabase(Connection $connection, string $databaseName): void { $connection->createSchemaManager()->dropDatabase( - $connection->getDatabasePlatform()->quoteSingleIdentifier($databaseName) + $connection->getDatabasePlatform()->quoteSingleIdentifier($databaseName), ); } } diff --git a/src/Console/InputHelper.php b/src/Console/InputHelper.php index 627558f04..6e5e28baa 100644 --- a/src/Console/InputHelper.php +++ b/src/Console/InputHelper.php @@ -11,7 +11,7 @@ final class InputHelper { - public static function nullableString(mixed $value): ?string + public static function nullableString(mixed $value): string|null { if ($value === null) { return null; @@ -46,7 +46,7 @@ public static function int(mixed $value): int return (int)$value; } - public static function nullableInt(mixed $value): ?int + public static function nullableInt(mixed $value): int|null { if ($value === null) { return null; diff --git a/src/Console/InvalidArgumentGiven.php b/src/Console/InvalidArgumentGiven.php index e6ff4f65e..cccd1242d 100644 --- a/src/Console/InvalidArgumentGiven.php +++ b/src/Console/InvalidArgumentGiven.php @@ -11,19 +11,15 @@ final class InvalidArgumentGiven extends InvalidArgumentException { - private mixed $value; - - public function __construct(mixed $value, string $need) + public function __construct(private mixed $value, string $need) { parent::__construct( sprintf( 'Invalid argument given: need type "%s" got "%s"', $need, - gettype($value) - ) + gettype($value), + ), ); - - $this->value = $value; } public function value(): mixed diff --git a/src/Console/Worker/Bytes.php b/src/Console/Worker/Bytes.php index cd46bad36..a5c4d5fdd 100644 --- a/src/Console/Worker/Bytes.php +++ b/src/Console/Worker/Bytes.php @@ -18,7 +18,7 @@ final class Bytes ]; public function __construct( - private readonly int $bytes + private readonly int $bytes, ) { } diff --git a/src/Console/Worker/DefaultWorker.php b/src/Console/Worker/DefaultWorker.php index cbcaaed64..697461fc8 100644 --- a/src/Console/Worker/DefaultWorker.php +++ b/src/Console/Worker/DefaultWorker.php @@ -22,7 +22,7 @@ final class DefaultWorker implements Worker public function __construct( private readonly Closure $job, private readonly EventDispatcherInterface $eventDispatcher, - private readonly ?LoggerInterface $logger = null + private readonly LoggerInterface|null $logger = null, ) { } diff --git a/src/Console/Worker/Event/WorkerRunningEvent.php b/src/Console/Worker/Event/WorkerRunningEvent.php index b8174bd9d..b5d41e66c 100644 --- a/src/Console/Worker/Event/WorkerRunningEvent.php +++ b/src/Console/Worker/Event/WorkerRunningEvent.php @@ -9,7 +9,7 @@ final class WorkerRunningEvent { public function __construct( - public readonly Worker $worker + public readonly Worker $worker, ) { } } diff --git a/src/Console/Worker/Event/WorkerStartedEvent.php b/src/Console/Worker/Event/WorkerStartedEvent.php index 7eab777e5..d82878219 100644 --- a/src/Console/Worker/Event/WorkerStartedEvent.php +++ b/src/Console/Worker/Event/WorkerStartedEvent.php @@ -9,7 +9,7 @@ final class WorkerStartedEvent { public function __construct( - public readonly Worker $worker + public readonly Worker $worker, ) { } } diff --git a/src/Console/Worker/Event/WorkerStoppedEvent.php b/src/Console/Worker/Event/WorkerStoppedEvent.php index 31ca416b4..bca593195 100644 --- a/src/Console/Worker/Event/WorkerStoppedEvent.php +++ b/src/Console/Worker/Event/WorkerStoppedEvent.php @@ -9,7 +9,7 @@ final class WorkerStoppedEvent { public function __construct( - public readonly Worker $worker + public readonly Worker $worker, ) { } } diff --git a/src/Console/Worker/Listener/StopWorkerOnIterationLimitListener.php b/src/Console/Worker/Listener/StopWorkerOnIterationLimitListener.php index 9180247a4..4834ce5ee 100644 --- a/src/Console/Worker/Listener/StopWorkerOnIterationLimitListener.php +++ b/src/Console/Worker/Listener/StopWorkerOnIterationLimitListener.php @@ -13,12 +13,10 @@ final class StopWorkerOnIterationLimitListener implements EventSubscriberInterfa { private int $iteration = 0; - /** - * @param positive-int $maximumNumberOfIteration - */ + /** @param positive-int $maximumNumberOfIteration */ public function __construct( private readonly int $maximumNumberOfIteration, - private readonly ?LoggerInterface $logger = null + private readonly LoggerInterface|null $logger = null, ) { } @@ -39,13 +37,11 @@ public function onWorkerRunning(WorkerRunningEvent $event): void $this->logger?->info( 'Worker stopped due to maximum iteration of {count}', - ['count' => $this->maximumNumberOfIteration] + ['count' => $this->maximumNumberOfIteration], ); } - /** - * @return array - */ + /** @return array */ public static function getSubscribedEvents(): array { return [ diff --git a/src/Console/Worker/Listener/StopWorkerOnMemoryLimitListener.php b/src/Console/Worker/Listener/StopWorkerOnMemoryLimitListener.php index a815526df..3676ef8e4 100644 --- a/src/Console/Worker/Listener/StopWorkerOnMemoryLimitListener.php +++ b/src/Console/Worker/Listener/StopWorkerOnMemoryLimitListener.php @@ -15,7 +15,7 @@ final class StopWorkerOnMemoryLimitListener implements EventSubscriberInterface { public function __construct( private readonly Bytes $memoryLimit, - private readonly ?LoggerInterface $logger = null + private readonly LoggerInterface|null $logger = null, ) { } @@ -29,7 +29,7 @@ public function onWorkerRunning(WorkerRunningEvent $event): void $this->logger?->info( 'Worker stopped due to memory limit of {limit} bytes exceeded ({memory} bytes used)', - ['limit' => $this->memoryLimit->value(), 'memory' => $usedMemory->value()] + ['limit' => $this->memoryLimit->value(), 'memory' => $usedMemory->value()], ); $event->worker->stop(); @@ -40,9 +40,7 @@ private function usedMemory(): Bytes return new Bytes(memory_get_usage(true)); } - /** - * @return array - */ + /** @return array */ public static function getSubscribedEvents(): array { return [WorkerRunningEvent::class => 'onWorkerRunning']; diff --git a/src/Console/Worker/Listener/StopWorkerOnSigtermSignalListener.php b/src/Console/Worker/Listener/StopWorkerOnSigtermSignalListener.php index eecf884ba..e9b856b4c 100644 --- a/src/Console/Worker/Listener/StopWorkerOnSigtermSignalListener.php +++ b/src/Console/Worker/Listener/StopWorkerOnSigtermSignalListener.php @@ -16,7 +16,7 @@ final class StopWorkerOnSigtermSignalListener implements EventSubscriberInterface { public function __construct( - private readonly ?LoggerInterface $logger = null + private readonly LoggerInterface|null $logger = null, ) { } @@ -28,9 +28,7 @@ public function onWorkerStarted(WorkerStartedEvent $event): void }); } - /** - * @return array - */ + /** @return array */ public static function getSubscribedEvents(): array { if (!function_exists('pcntl_signal')) { diff --git a/src/Console/Worker/Listener/StopWorkerOnTimeLimitListener.php b/src/Console/Worker/Listener/StopWorkerOnTimeLimitListener.php index 1bc3225a3..836b9d2a9 100644 --- a/src/Console/Worker/Listener/StopWorkerOnTimeLimitListener.php +++ b/src/Console/Worker/Listener/StopWorkerOnTimeLimitListener.php @@ -15,12 +15,10 @@ final class StopWorkerOnTimeLimitListener implements EventSubscriberInterface { private float $endTime = 0; - /** - * @param positive-int $timeLimitInSeconds - */ + /** @param positive-int $timeLimitInSeconds */ public function __construct( private readonly int $timeLimitInSeconds, - private readonly ?LoggerInterface $logger = null + private readonly LoggerInterface|null $logger = null, ) { } @@ -38,13 +36,11 @@ public function onWorkerRunning(WorkerRunningEvent $event): void $event->worker->stop(); $this->logger?->info( 'Worker stopped due to time limit of {timeLimit}s exceeded', - ['timeLimit' => $this->timeLimitInSeconds] + ['timeLimit' => $this->timeLimitInSeconds], ); } - /** - * @return array - */ + /** @return array */ public static function getSubscribedEvents(): array { return [ diff --git a/src/Console/Worker/Worker.php b/src/Console/Worker/Worker.php index 0703cf0cb..67a144644 100644 --- a/src/Console/Worker/Worker.php +++ b/src/Console/Worker/Worker.php @@ -6,9 +6,7 @@ interface Worker { - /** - * @param 0|positive-int $sleepTimer sleepTimer in microseconds - */ + /** @param 0|positive-int $sleepTimer sleepTimer in microseconds */ public function run(int $sleepTimer = 1000): void; public function stop(): void; diff --git a/src/EventBus/Decorator/ChainMessageDecorator.php b/src/EventBus/Decorator/ChainMessageDecorator.php index adc6ba3fa..15f7e8ac0 100644 --- a/src/EventBus/Decorator/ChainMessageDecorator.php +++ b/src/EventBus/Decorator/ChainMessageDecorator.php @@ -8,11 +8,9 @@ final class ChainMessageDecorator implements MessageDecorator { - /** - * @param iterable $messageDecorators - */ + /** @param iterable $messageDecorators */ public function __construct( - private readonly iterable $messageDecorators + private readonly iterable $messageDecorators, ) { } diff --git a/src/EventBus/Decorator/RecordedOnDecorator.php b/src/EventBus/Decorator/RecordedOnDecorator.php index a9c091f22..8bee417bd 100644 --- a/src/EventBus/Decorator/RecordedOnDecorator.php +++ b/src/EventBus/Decorator/RecordedOnDecorator.php @@ -10,7 +10,7 @@ final class RecordedOnDecorator implements MessageDecorator { public function __construct( - private readonly ClockInterface $clock + private readonly ClockInterface $clock, ) { } diff --git a/src/EventBus/DefaultEventBus.php b/src/EventBus/DefaultEventBus.php index fe1510572..5d2232cf6 100644 --- a/src/EventBus/DefaultEventBus.php +++ b/src/EventBus/DefaultEventBus.php @@ -11,18 +11,12 @@ final class DefaultEventBus implements EventBus { /** @var array> */ private array $queue; - /** @var list */ - private array $listeners; - private bool $processing; - /** - * @param list $listeners - */ - public function __construct(array $listeners = []) + /** @param list $listeners */ + public function __construct(private array $listeners = []) { $this->queue = []; - $this->listeners = $listeners; $this->processing = false; } diff --git a/src/EventBus/DuplicateHandleMethod.php b/src/EventBus/DuplicateHandleMethod.php index a7d2011e7..693d54839 100644 --- a/src/EventBus/DuplicateHandleMethod.php +++ b/src/EventBus/DuplicateHandleMethod.php @@ -20,8 +20,8 @@ public function __construct(string $subscriber, string $event, string $fistMetho $fistMethod, $secondMethod, $subscriber, - $event - ) + $event, + ), ); } } diff --git a/src/EventBus/Message.php b/src/EventBus/Message.php index ee6742c62..3e7be39e1 100644 --- a/src/EventBus/Message.php +++ b/src/EventBus/Message.php @@ -25,26 +25,20 @@ final class Message public const HEADER_NEW_STREAM_START = 'newStreamStart'; /** @var class-string|null */ - private ?string $aggregateClass = null; - private ?string $aggregateId = null; + private string|null $aggregateClass = null; + private string|null $aggregateId = null; /** @var positive-int|null */ - private ?int $playhead = null; - private ?DateTimeImmutable $recordedOn = null; + private int|null $playhead = null; + private DateTimeImmutable|null $recordedOn = null; private bool $newStreamStart = false; private bool $archived = false; /** @var array */ private array $customHeaders = []; - /** @var T */ - private readonly object $event; - - /** - * @param T $event - */ - public function __construct(object $event) + /** @param T $event */ + public function __construct(private readonly object $event) { - $this->event = $event; } /** @@ -59,17 +53,13 @@ public static function create(object $event): self return new self($event); } - /** - * @return T - */ + /** @return T */ public function event(): object { return $this->event; } - /** - * @return class-string - */ + /** @return class-string */ public function aggregateClass(): string { $value = $this->aggregateClass; @@ -81,9 +71,7 @@ public function aggregateClass(): string return $value; } - /** - * @param class-string $value - */ + /** @param class-string $value */ public function withAggregateClass(string $value): self { $message = clone $this; @@ -111,9 +99,7 @@ public function withAggregateId(string $value): self return $message; } - /** - * @return positive-int - */ + /** @return positive-int */ public function playhead(): int { $value = $this->playhead; @@ -125,9 +111,7 @@ public function playhead(): int return $value; } - /** - * @param positive-int $value - */ + /** @param positive-int $value */ public function withPlayhead(int $value): self { $message = clone $this; @@ -198,17 +182,13 @@ public function withCustomHeader(string $name, mixed $value): self return $message; } - /** - * @return array - */ + /** @return array */ public function customHeaders(): array { return $this->customHeaders; } - /** - * @param array $headers - */ + /** @param array $headers */ public function withCustomHeaders(array $headers): self { $message = clone $this; @@ -217,9 +197,7 @@ public function withCustomHeaders(array $headers): self return $message; } - /** - * @return Headers - */ + /** @return Headers */ public function headers(): array { $headers = $this->customHeaders; @@ -246,9 +224,7 @@ public function headers(): array return $headers; } - /** - * @param Headers $headers - */ + /** @param Headers $headers */ public static function createWithHeaders(object $event, array $headers): self { $message = self::create($event); diff --git a/src/EventBus/Subscriber.php b/src/EventBus/Subscriber.php index c679fe53f..aef3e6dae 100644 --- a/src/EventBus/Subscriber.php +++ b/src/EventBus/Subscriber.php @@ -12,7 +12,7 @@ abstract class Subscriber implements Listener { /** @var array|null */ - private ?array $handleMethods = null; + private array|null $handleMethods = null; final public function __invoke(Message $message): void { @@ -48,7 +48,7 @@ private function init(): void static::class, $eventClass, $this->handleMethods[$eventClass], - $method->getName() + $method->getName(), ); } diff --git a/src/EventBus/SymfonyEventBus.php b/src/EventBus/SymfonyEventBus.php index c78ea7096..280676848 100644 --- a/src/EventBus/SymfonyEventBus.php +++ b/src/EventBus/SymfonyEventBus.php @@ -13,11 +13,8 @@ final class SymfonyEventBus implements EventBus { - private MessageBusInterface $bus; - - public function __construct(MessageBusInterface $bus) + public function __construct(private MessageBusInterface $bus) { - $this->bus = $bus; } public function dispatch(Message ...$messages): void @@ -30,15 +27,13 @@ public function dispatch(Message ...$messages): void } } - /** - * @param list $listeners - */ + /** @param list $listeners */ public static function create(array $listeners = []): static { $bus = new MessageBus([ new HandleMessageMiddleware( new HandlersLocator([Message::class => $listeners]), - true + true, ), ]); diff --git a/src/Lock/DoctrineDbalStoreSchemaAdapter.php b/src/Lock/DoctrineDbalStoreSchemaAdapter.php index 047a5e8fc..019abcd9e 100644 --- a/src/Lock/DoctrineDbalStoreSchemaAdapter.php +++ b/src/Lock/DoctrineDbalStoreSchemaAdapter.php @@ -12,7 +12,7 @@ final class DoctrineDbalStoreSchemaAdapter implements SchemaConfigurator { public function __construct( - private readonly DoctrineDbalStore $doctrineDbalStore + private readonly DoctrineDbalStore $doctrineDbalStore, ) { } diff --git a/src/Metadata/AggregateRoot/AggregateRootMetadata.php b/src/Metadata/AggregateRoot/AggregateRootMetadata.php index a63575d7c..fe59e16b8 100644 --- a/src/Metadata/AggregateRoot/AggregateRootMetadata.php +++ b/src/Metadata/AggregateRoot/AggregateRootMetadata.php @@ -15,9 +15,9 @@ public function __construct( /** @var array */ public readonly array $suppressEvents, public readonly bool $suppressAll, - public readonly ?string $snapshotStore, - public readonly ?int $snapshotBatch, - public readonly ?string $snapshotVersion = null, + public readonly string|null $snapshotStore, + public readonly int|null $snapshotBatch, + public readonly string|null $snapshotVersion = null, ) { } } diff --git a/src/Metadata/AggregateRoot/AggregateRootMetadataFactory.php b/src/Metadata/AggregateRoot/AggregateRootMetadataFactory.php index f6a071995..fbb7fc28f 100644 --- a/src/Metadata/AggregateRoot/AggregateRootMetadataFactory.php +++ b/src/Metadata/AggregateRoot/AggregateRootMetadataFactory.php @@ -8,8 +8,6 @@ interface AggregateRootMetadataFactory { - /** - * @param class-string $aggregate - */ + /** @param class-string $aggregate */ public function metadata(string $aggregate): AggregateRootMetadata; } diff --git a/src/Metadata/AggregateRoot/AggregateRootNameNotRegistered.php b/src/Metadata/AggregateRoot/AggregateRootNameNotRegistered.php index 039843f86..db7f5b145 100644 --- a/src/Metadata/AggregateRoot/AggregateRootNameNotRegistered.php +++ b/src/Metadata/AggregateRoot/AggregateRootNameNotRegistered.php @@ -15,7 +15,7 @@ public function __construct(string $evenName) parent::__construct( sprintf( 'Aggregate root name "%s" is not registered', - $evenName + $evenName, ), ); } diff --git a/src/Metadata/AggregateRoot/AggregateRootPropertyMetadata.php b/src/Metadata/AggregateRoot/AggregateRootPropertyMetadata.php index 35423d085..d7b1e41a3 100644 --- a/src/Metadata/AggregateRoot/AggregateRootPropertyMetadata.php +++ b/src/Metadata/AggregateRoot/AggregateRootPropertyMetadata.php @@ -12,7 +12,7 @@ final class AggregateRootPropertyMetadata public function __construct( public readonly string $fieldName, public readonly ReflectionProperty $reflection, - public readonly ?Normalizer $normalizer = null + public readonly Normalizer|null $normalizer = null, ) { } } diff --git a/src/Metadata/AggregateRoot/AggregateRootRegistry.php b/src/Metadata/AggregateRoot/AggregateRootRegistry.php index 9b0390240..4fe4f593c 100644 --- a/src/Metadata/AggregateRoot/AggregateRootRegistry.php +++ b/src/Metadata/AggregateRoot/AggregateRootRegistry.php @@ -17,18 +17,14 @@ final class AggregateRootRegistry /** @var array, string> */ private array $classToNameMap; - /** - * @param array> $aggregateNameToClassMap - */ + /** @param array> $aggregateNameToClassMap */ public function __construct(array $aggregateNameToClassMap) { $this->nameToClassMap = $aggregateNameToClassMap; $this->classToNameMap = array_flip($aggregateNameToClassMap); } - /** - * @param class-string $aggregateClass - */ + /** @param class-string $aggregateClass */ public function aggregateName(string $aggregateClass): string { if (!array_key_exists($aggregateClass, $this->classToNameMap)) { @@ -38,9 +34,7 @@ public function aggregateName(string $aggregateClass): string return $this->classToNameMap[$aggregateClass]; } - /** - * @return class-string - */ + /** @return class-string */ public function aggregateClass(string $aggregateName): string { if (!array_key_exists($aggregateName, $this->nameToClassMap)) { @@ -60,17 +54,13 @@ public function hasAggregateName(string $aggregateName): bool return array_key_exists($aggregateName, $this->nameToClassMap); } - /** - * @return array> - */ + /** @return array> */ public function aggregateClasses(): array { return $this->nameToClassMap; } - /** - * @return array, string> - */ + /** @return array, string> */ public function aggregateNames(): array { return $this->classToNameMap; diff --git a/src/Metadata/AggregateRoot/AggregateRootRegistryFactory.php b/src/Metadata/AggregateRoot/AggregateRootRegistryFactory.php index e7e873e9c..70cd55cc3 100644 --- a/src/Metadata/AggregateRoot/AggregateRootRegistryFactory.php +++ b/src/Metadata/AggregateRoot/AggregateRootRegistryFactory.php @@ -6,8 +6,6 @@ interface AggregateRootRegistryFactory { - /** - * @param list $paths - */ + /** @param list $paths */ public function create(array $paths): AggregateRootRegistry; } diff --git a/src/Metadata/AggregateRoot/AttributeAggregateRootMetadataFactory.php b/src/Metadata/AggregateRoot/AttributeAggregateRootMetadataFactory.php index baec59cd5..00e249377 100644 --- a/src/Metadata/AggregateRoot/AttributeAggregateRootMetadataFactory.php +++ b/src/Metadata/AggregateRoot/AttributeAggregateRootMetadataFactory.php @@ -30,9 +30,7 @@ final class AttributeAggregateRootMetadataFactory implements AggregateRootMetada /** @var array, AggregateRootMetadata> */ private array $aggregateMetadata = []; - /** - * @param class-string $aggregate - */ + /** @param class-string $aggregate */ public function metadata(string $aggregate): AggregateRootMetadata { if (array_key_exists($aggregate, $this->aggregateMetadata)) { @@ -55,7 +53,7 @@ public function metadata(string $aggregate): AggregateRootMetadata $suppressAll, $snapshot?->name(), $snapshot?->batch(), - $snapshot?->version() + $snapshot?->version(), ); $this->aggregateMetadata[$aggregate] = $metadata; @@ -63,9 +61,7 @@ public function metadata(string $aggregate): AggregateRootMetadata return $metadata; } - /** - * @return array{array, bool} - */ + /** @return array{array, bool} */ private function findSuppressMissingApply(ReflectionClass $reflector): array { $suppressEvents = []; @@ -103,7 +99,7 @@ private function findAggregateName(ReflectionClass $reflector): string return $aggregateAttribute->name(); } - private function findSnapshot(ReflectionClass $reflector): ?Snapshot + private function findSnapshot(ReflectionClass $reflector): Snapshot|null { $attributeReflectionList = $reflector->getAttributes(Snapshot::class); @@ -170,7 +166,7 @@ private function findApplyMethods(ReflectionClass $reflector, string $aggregate) $aggregate, $eventClass, $applyMethods[$eventClass], - $methodName + $methodName, ); } @@ -215,9 +211,7 @@ static function (ReflectionNamedType|ReflectionIntersectionType $reflectionType) return []; } - /** - * @return array - */ + /** @return array */ private function getPropertyMetadataList(ReflectionClass $reflectionClass): array { $properties = []; @@ -235,18 +229,18 @@ private function getPropertyMetadataList(ReflectionClass $reflectionClass): arra $properties[$reflectionProperty->getName()] = new AggregateRootPropertyMetadata( $fieldName, $reflectionProperty, - $this->getNormalizer($reflectionProperty) + $this->getNormalizer($reflectionProperty), ); } return $properties; } - private function getNormalizer(ReflectionProperty $reflectionProperty): ?Normalizer + private function getNormalizer(ReflectionProperty $reflectionProperty): Normalizer|null { $attributeReflectionList = $reflectionProperty->getAttributes( Normalizer::class, - ReflectionAttribute::IS_INSTANCEOF + ReflectionAttribute::IS_INSTANCEOF, ); if ($attributeReflectionList !== []) { diff --git a/src/Metadata/AggregateRoot/AttributeAggregateRootRegistryFactory.php b/src/Metadata/AggregateRoot/AttributeAggregateRootRegistryFactory.php index 64f3aabe5..4bb1b1cfa 100644 --- a/src/Metadata/AggregateRoot/AttributeAggregateRootRegistryFactory.php +++ b/src/Metadata/AggregateRoot/AttributeAggregateRootRegistryFactory.php @@ -14,9 +14,7 @@ final class AttributeAggregateRootRegistryFactory implements AggregateRootRegistryFactory { - /** - * @param list $paths - */ + /** @param list $paths */ public function create(array $paths): AggregateRootRegistry { $classes = (new ClassFinder())->findClassNames($paths); diff --git a/src/Metadata/AggregateRoot/DuplicateApplyMethod.php b/src/Metadata/AggregateRoot/DuplicateApplyMethod.php index 4e75540fe..2e648ea0a 100644 --- a/src/Metadata/AggregateRoot/DuplicateApplyMethod.php +++ b/src/Metadata/AggregateRoot/DuplicateApplyMethod.php @@ -23,8 +23,8 @@ public function __construct(string $aggregate, string $event, string $fistMethod $fistMethod, $secondMethod, $aggregate, - $event - ) + $event, + ), ); } } diff --git a/src/Metadata/AggregateRoot/DuplicateEmptyApplyAttribute.php b/src/Metadata/AggregateRoot/DuplicateEmptyApplyAttribute.php index 65a6ad295..4e35e82bb 100644 --- a/src/Metadata/AggregateRoot/DuplicateEmptyApplyAttribute.php +++ b/src/Metadata/AggregateRoot/DuplicateEmptyApplyAttribute.php @@ -14,7 +14,7 @@ public function __construct(string $methodName) { parent::__construct(sprintf( 'The method [%s] has multiple apply attributes given without an event name which is not allowed.', - $methodName + $methodName, )); } } diff --git a/src/Metadata/AggregateRoot/MixedApplyAttributeUsage.php b/src/Metadata/AggregateRoot/MixedApplyAttributeUsage.php index 7c9d076f2..e728f9447 100644 --- a/src/Metadata/AggregateRoot/MixedApplyAttributeUsage.php +++ b/src/Metadata/AggregateRoot/MixedApplyAttributeUsage.php @@ -14,7 +14,7 @@ public function __construct(string $methodName) { parent::__construct(sprintf( 'The method [%s] has at least one apply attribute with an event name and one without which is not allowed.', - $methodName + $methodName, )); } } diff --git a/src/Metadata/AggregateRoot/NoAggregateRoot.php b/src/Metadata/AggregateRoot/NoAggregateRoot.php index 5e6f22d68..b8bf8708e 100644 --- a/src/Metadata/AggregateRoot/NoAggregateRoot.php +++ b/src/Metadata/AggregateRoot/NoAggregateRoot.php @@ -10,9 +10,7 @@ final class NoAggregateRoot extends MetadataException { - /** - * @param class-string $class - */ + /** @param class-string $class */ public function __construct(string $class) { parent::__construct(sprintf('The class "%s" does not extend AggregateRoot', $class)); diff --git a/src/Metadata/Event/AttributeEventMetadataFactory.php b/src/Metadata/Event/AttributeEventMetadataFactory.php index ff0405ceb..fc6b25fa3 100644 --- a/src/Metadata/Event/AttributeEventMetadataFactory.php +++ b/src/Metadata/Event/AttributeEventMetadataFactory.php @@ -21,9 +21,7 @@ final class AttributeEventMetadataFactory implements EventMetadataFactory /** @var array */ private array $eventMetadata = []; - /** - * @param class-string $event - */ + /** @param class-string $event */ public function metadata(string $event): EventMetadata { if (array_key_exists($event, $this->eventMetadata)) { @@ -55,9 +53,7 @@ private function splitStream(ReflectionClass $reflectionClass): bool return count($reflectionClass->getAttributes(SplitStream::class)) !== 0; } - /** - * @return array - */ + /** @return array */ private function getPropertyMetadataList(ReflectionClass $reflectionClass): array { $properties = []; @@ -76,18 +72,18 @@ private function getPropertyMetadataList(ReflectionClass $reflectionClass): arra $properties[$property->getName()] = new EventPropertyMetadata( $fieldName, $reflection, - $this->getNormalizer($property) + $this->getNormalizer($property), ); } return $properties; } - private function getNormalizer(ReflectionProperty $reflectionProperty): ?Normalizer + private function getNormalizer(ReflectionProperty $reflectionProperty): Normalizer|null { $attributeReflectionList = $reflectionProperty->getAttributes( Normalizer::class, - ReflectionAttribute::IS_INSTANCEOF + ReflectionAttribute::IS_INSTANCEOF, ); if ($attributeReflectionList !== []) { diff --git a/src/Metadata/Event/AttributeEventRegistryFactory.php b/src/Metadata/Event/AttributeEventRegistryFactory.php index 63bb2fbbe..240225a2f 100644 --- a/src/Metadata/Event/AttributeEventRegistryFactory.php +++ b/src/Metadata/Event/AttributeEventRegistryFactory.php @@ -12,9 +12,7 @@ final class AttributeEventRegistryFactory implements EventRegistryFactory { - /** - * @param list $paths - */ + /** @param list $paths */ public function create(array $paths): EventRegistry { $classes = (new ClassFinder())->findClassNames($paths); diff --git a/src/Metadata/Event/EventMetadataFactory.php b/src/Metadata/Event/EventMetadataFactory.php index 79e6a3948..5c8fedcf9 100644 --- a/src/Metadata/Event/EventMetadataFactory.php +++ b/src/Metadata/Event/EventMetadataFactory.php @@ -6,8 +6,6 @@ interface EventMetadataFactory { - /** - * @param class-string $event - */ + /** @param class-string $event */ public function metadata(string $event): EventMetadata; } diff --git a/src/Metadata/Event/EventNameNotRegistered.php b/src/Metadata/Event/EventNameNotRegistered.php index d00477b2e..663d4497c 100644 --- a/src/Metadata/Event/EventNameNotRegistered.php +++ b/src/Metadata/Event/EventNameNotRegistered.php @@ -15,7 +15,7 @@ public function __construct(string $evenName) parent::__construct( sprintf( 'Event name "%s" is not registered', - $evenName + $evenName, ), ); } diff --git a/src/Metadata/Event/EventPropertyMetadata.php b/src/Metadata/Event/EventPropertyMetadata.php index aff423eed..8e6f6eeb7 100644 --- a/src/Metadata/Event/EventPropertyMetadata.php +++ b/src/Metadata/Event/EventPropertyMetadata.php @@ -12,7 +12,7 @@ final class EventPropertyMetadata public function __construct( public readonly string $fieldName, public readonly ReflectionProperty $reflection, - public readonly ?Normalizer $normalizer = null + public readonly Normalizer|null $normalizer = null, ) { } } diff --git a/src/Metadata/Event/EventRegistry.php b/src/Metadata/Event/EventRegistry.php index c619a48ae..2403484c3 100644 --- a/src/Metadata/Event/EventRegistry.php +++ b/src/Metadata/Event/EventRegistry.php @@ -15,18 +15,14 @@ final class EventRegistry /** @var array */ private array $classToNameMap; - /** - * @param array $eventNameToClassMap - */ + /** @param array $eventNameToClassMap */ public function __construct(array $eventNameToClassMap) { $this->nameToClassMap = $eventNameToClassMap; $this->classToNameMap = array_flip($eventNameToClassMap); } - /** - * @param class-string $eventClass - */ + /** @param class-string $eventClass */ public function eventName(string $eventClass): string { if (!array_key_exists($eventClass, $this->classToNameMap)) { @@ -36,9 +32,7 @@ public function eventName(string $eventClass): string return $this->classToNameMap[$eventClass]; } - /** - * @return class-string - */ + /** @return class-string */ public function eventClass(string $eventName): string { if (!array_key_exists($eventName, $this->nameToClassMap)) { @@ -58,9 +52,7 @@ public function hasEventName(string $eventName): bool return array_key_exists($eventName, $this->nameToClassMap); } - /** - * @return array - */ + /** @return array */ public function eventClasses(): array { return $this->nameToClassMap; diff --git a/src/Metadata/Event/EventRegistryFactory.php b/src/Metadata/Event/EventRegistryFactory.php index 5f9195313..c26a5aeee 100644 --- a/src/Metadata/Event/EventRegistryFactory.php +++ b/src/Metadata/Event/EventRegistryFactory.php @@ -6,8 +6,6 @@ interface EventRegistryFactory { - /** - * @param list $paths - */ + /** @param list $paths */ public function create(array $paths): EventRegistry; } diff --git a/src/Metadata/Projection/AttributeProjectionMetadataFactory.php b/src/Metadata/Projection/AttributeProjectionMetadataFactory.php index 90182b815..4ab308699 100644 --- a/src/Metadata/Projection/AttributeProjectionMetadataFactory.php +++ b/src/Metadata/Projection/AttributeProjectionMetadataFactory.php @@ -17,9 +17,7 @@ final class AttributeProjectionMetadataFactory implements ProjectionMetadataFact /** @var array, ProjectionMetadata> */ private array $projectionMetadata = []; - /** - * @param class-string $projection - */ + /** @param class-string $projection */ public function metadata(string $projection): ProjectionMetadata { if (array_key_exists($projection, $this->projectionMetadata)) { @@ -45,7 +43,7 @@ public function metadata(string $projection): ProjectionMetadata $projection, $eventClass, $handleMethods[$eventClass], - $method->getName() + $method->getName(), ); } @@ -57,7 +55,7 @@ public function metadata(string $projection): ProjectionMetadata throw new DuplicateCreateMethod( $projection, $createMethod, - $method->getName() + $method->getName(), ); } @@ -72,7 +70,7 @@ public function metadata(string $projection): ProjectionMetadata throw new DuplicateDropMethod( $projection, $dropMethod, - $method->getName() + $method->getName(), ); } @@ -82,7 +80,7 @@ public function metadata(string $projection): ProjectionMetadata $metadata = new ProjectionMetadata( $handleMethods, $createMethod, - $dropMethod + $dropMethod, ); $this->projectionMetadata[$projection] = $metadata; diff --git a/src/Metadata/Projection/DuplicateCreateMethod.php b/src/Metadata/Projection/DuplicateCreateMethod.php index 43f0b0602..11188cf3f 100644 --- a/src/Metadata/Projection/DuplicateCreateMethod.php +++ b/src/Metadata/Projection/DuplicateCreateMethod.php @@ -11,9 +11,7 @@ final class DuplicateCreateMethod extends MetadataException { - /** - * @param class-string $projection - */ + /** @param class-string $projection */ public function __construct(string $projection, string $fistMethod, string $secondMethod) { parent::__construct( @@ -22,7 +20,7 @@ public function __construct(string $projection, string $fistMethod, string $seco $fistMethod, $secondMethod, $projection, - ) + ), ); } } diff --git a/src/Metadata/Projection/DuplicateDropMethod.php b/src/Metadata/Projection/DuplicateDropMethod.php index 157e0808b..1526fc782 100644 --- a/src/Metadata/Projection/DuplicateDropMethod.php +++ b/src/Metadata/Projection/DuplicateDropMethod.php @@ -11,9 +11,7 @@ final class DuplicateDropMethod extends MetadataException { - /** - * @param class-string $projection - */ + /** @param class-string $projection */ public function __construct(string $projection, string $fistMethod, string $secondMethod) { parent::__construct( @@ -22,7 +20,7 @@ public function __construct(string $projection, string $fistMethod, string $seco $fistMethod, $secondMethod, $projection, - ) + ), ); } } diff --git a/src/Metadata/Projection/DuplicateHandleMethod.php b/src/Metadata/Projection/DuplicateHandleMethod.php index bb4942371..b3f6a2eb4 100644 --- a/src/Metadata/Projection/DuplicateHandleMethod.php +++ b/src/Metadata/Projection/DuplicateHandleMethod.php @@ -23,8 +23,8 @@ public function __construct(string $projection, string $event, string $fistMetho $fistMethod, $secondMethod, $projection, - $event - ) + $event, + ), ); } } diff --git a/src/Metadata/Projection/ProjectionMetadata.php b/src/Metadata/Projection/ProjectionMetadata.php index 8447fb901..c10dc9931 100644 --- a/src/Metadata/Projection/ProjectionMetadata.php +++ b/src/Metadata/Projection/ProjectionMetadata.php @@ -9,8 +9,8 @@ final class ProjectionMetadata public function __construct( /** @var array */ public readonly array $handleMethods, - public readonly ?string $createMethod = null, - public readonly ?string $dropMethod = null + public readonly string|null $createMethod = null, + public readonly string|null $dropMethod = null, ) { } } diff --git a/src/Metadata/Projection/ProjectionMetadataFactory.php b/src/Metadata/Projection/ProjectionMetadataFactory.php index 41ede493d..33a767dbf 100644 --- a/src/Metadata/Projection/ProjectionMetadataFactory.php +++ b/src/Metadata/Projection/ProjectionMetadataFactory.php @@ -8,8 +8,6 @@ interface ProjectionMetadataFactory { - /** - * @param class-string $projection - */ + /** @param class-string $projection */ public function metadata(string $projection): ProjectionMetadata; } diff --git a/src/Outbox/OutboxConsumer.php b/src/Outbox/OutboxConsumer.php index 93cb2fae1..3642bd919 100644 --- a/src/Outbox/OutboxConsumer.php +++ b/src/Outbox/OutboxConsumer.php @@ -6,5 +6,5 @@ interface OutboxConsumer { - public function consume(?int $limit = null): void; + public function consume(int|null $limit = null): void; } diff --git a/src/Outbox/StoreOutboxConsumer.php b/src/Outbox/StoreOutboxConsumer.php index d4ed3a18a..511e99d45 100644 --- a/src/Outbox/StoreOutboxConsumer.php +++ b/src/Outbox/StoreOutboxConsumer.php @@ -13,7 +13,7 @@ public function __construct(private OutboxStore $outboxStore, private EventBus $ { } - public function consume(?int $limit = null): void + public function consume(int|null $limit = null): void { $messages = $this->outboxStore->retrieveOutboxMessages($limit); diff --git a/src/Pipeline/Middleware/ChainMiddleware.php b/src/Pipeline/Middleware/ChainMiddleware.php index 0f4a1e1ec..7f947f8f9 100644 --- a/src/Pipeline/Middleware/ChainMiddleware.php +++ b/src/Pipeline/Middleware/ChainMiddleware.php @@ -10,17 +10,13 @@ final class ChainMiddleware implements Middleware { - /** - * @param iterable $middlewares - */ + /** @param iterable $middlewares */ public function __construct( - private readonly iterable $middlewares + private readonly iterable $middlewares, ) { } - /** - * @return list - */ + /** @return list */ public function __invoke(Message $message): array { $messages = [$message]; diff --git a/src/Pipeline/Middleware/ExcludeArchivedEventMiddleware.php b/src/Pipeline/Middleware/ExcludeArchivedEventMiddleware.php index a49181877..591708d05 100644 --- a/src/Pipeline/Middleware/ExcludeArchivedEventMiddleware.php +++ b/src/Pipeline/Middleware/ExcludeArchivedEventMiddleware.php @@ -8,9 +8,7 @@ final class ExcludeArchivedEventMiddleware implements Middleware { - /** - * @return list - */ + /** @return list */ public function __invoke(Message $message): array { if ($message->archived()) { diff --git a/src/Pipeline/Middleware/ExcludeEventMiddleware.php b/src/Pipeline/Middleware/ExcludeEventMiddleware.php index a5c1da756..09100d0d8 100644 --- a/src/Pipeline/Middleware/ExcludeEventMiddleware.php +++ b/src/Pipeline/Middleware/ExcludeEventMiddleware.php @@ -8,20 +8,12 @@ final class ExcludeEventMiddleware implements Middleware { - /** @var list */ - private array $classes; - - /** - * @param list $classes - */ - public function __construct(array $classes) + /** @param list $classes */ + public function __construct(private array $classes) { - $this->classes = $classes; } - /** - * @return list - */ + /** @return list */ public function __invoke(Message $message): array { foreach ($this->classes as $class) { diff --git a/src/Pipeline/Middleware/FilterEventMiddleware.php b/src/Pipeline/Middleware/FilterEventMiddleware.php index 38d7143dc..55f70391c 100644 --- a/src/Pipeline/Middleware/FilterEventMiddleware.php +++ b/src/Pipeline/Middleware/FilterEventMiddleware.php @@ -11,17 +11,13 @@ final class FilterEventMiddleware implements Middleware /** @var callable(object $event):bool */ private $callable; - /** - * @param callable(object $event):bool $callable - */ + /** @param callable(object $event):bool $callable */ public function __construct(callable $callable) { $this->callable = $callable; } - /** - * @return list - */ + /** @return list */ public function __invoke(Message $message): array { $result = ($this->callable)($message->event()); diff --git a/src/Pipeline/Middleware/IncludeEventMiddleware.php b/src/Pipeline/Middleware/IncludeEventMiddleware.php index 1eb916110..1f6125543 100644 --- a/src/Pipeline/Middleware/IncludeEventMiddleware.php +++ b/src/Pipeline/Middleware/IncludeEventMiddleware.php @@ -8,20 +8,12 @@ final class IncludeEventMiddleware implements Middleware { - /** @var list */ - private array $classes; - - /** - * @param list $classes - */ - public function __construct(array $classes) + /** @param list $classes */ + public function __construct(private array $classes) { - $this->classes = $classes; } - /** - * @return list - */ + /** @return list */ public function __invoke(Message $message): array { foreach ($this->classes as $class) { diff --git a/src/Pipeline/Middleware/Middleware.php b/src/Pipeline/Middleware/Middleware.php index 8e29501e0..219534109 100644 --- a/src/Pipeline/Middleware/Middleware.php +++ b/src/Pipeline/Middleware/Middleware.php @@ -8,8 +8,6 @@ interface Middleware { - /** - * @return list - */ + /** @return list */ public function __invoke(Message $message): array; } diff --git a/src/Pipeline/Middleware/OnlyArchivedEventMiddleware.php b/src/Pipeline/Middleware/OnlyArchivedEventMiddleware.php index a5663f422..ca7039c88 100644 --- a/src/Pipeline/Middleware/OnlyArchivedEventMiddleware.php +++ b/src/Pipeline/Middleware/OnlyArchivedEventMiddleware.php @@ -8,9 +8,7 @@ final class OnlyArchivedEventMiddleware implements Middleware { - /** - * @return list - */ + /** @return list */ public function __invoke(Message $message): array { if ($message->archived()) { diff --git a/src/Pipeline/Middleware/RecalculatePlayheadMiddleware.php b/src/Pipeline/Middleware/RecalculatePlayheadMiddleware.php index 14081f2f2..d2f5addea 100644 --- a/src/Pipeline/Middleware/RecalculatePlayheadMiddleware.php +++ b/src/Pipeline/Middleware/RecalculatePlayheadMiddleware.php @@ -14,9 +14,7 @@ final class RecalculatePlayheadMiddleware implements Middleware /** @var array, array> */ private array $index = []; - /** - * @return list - */ + /** @return list */ public function __invoke(Message $message): array { $playhead = $this->nextPlayhead($message->aggregateClass(), $message->aggregateId()); diff --git a/src/Pipeline/Middleware/ReplaceEventMiddleware.php b/src/Pipeline/Middleware/ReplaceEventMiddleware.php index 1864830cd..724d7c6e5 100644 --- a/src/Pipeline/Middleware/ReplaceEventMiddleware.php +++ b/src/Pipeline/Middleware/ReplaceEventMiddleware.php @@ -6,14 +6,9 @@ use Patchlevel\EventSourcing\EventBus\Message; -/** - * @template T of object - */ +/** @template T of object */ final class ReplaceEventMiddleware implements Middleware { - /** @var class-string */ - private string $class; - /** @var callable(T $event):object */ private $callable; @@ -21,15 +16,12 @@ final class ReplaceEventMiddleware implements Middleware * @param class-string $class * @param callable(T $event):object $callable */ - public function __construct(string $class, callable $callable) + public function __construct(private string $class, callable $callable) { - $this->class = $class; $this->callable = $callable; } - /** - * @return list - */ + /** @return list */ public function __invoke(Message $message): array { $event = $message->event(); diff --git a/src/Pipeline/Middleware/UntilEventMiddleware.php b/src/Pipeline/Middleware/UntilEventMiddleware.php index 1d6189909..27b8cdce9 100644 --- a/src/Pipeline/Middleware/UntilEventMiddleware.php +++ b/src/Pipeline/Middleware/UntilEventMiddleware.php @@ -9,16 +9,11 @@ final class UntilEventMiddleware implements Middleware { - private DateTimeImmutable $until; - - public function __construct(DateTimeImmutable $until) + public function __construct(private DateTimeImmutable $until) { - $this->until = $until; } - /** - * @return list - */ + /** @return list */ public function __invoke(Message $message): array { $recordedOn = $message->recordedOn(); diff --git a/src/Pipeline/Pipeline.php b/src/Pipeline/Pipeline.php index bd50d466f..11c770e1a 100644 --- a/src/Pipeline/Pipeline.php +++ b/src/Pipeline/Pipeline.php @@ -12,21 +12,15 @@ final class Pipeline { - private Source $source; - private Target $target; private ChainMiddleware $middlewares; - /** - * @param list $middlewares - */ - public function __construct(Source $source, Target $target, array $middlewares = []) + /** @param list $middlewares */ + public function __construct(private Source $source, private Target $target, array $middlewares = []) { - $this->source = $source; - $this->target = $target; $this->middlewares = new ChainMiddleware($middlewares); } - public function run(?Closure $observer = null): void + public function run(Closure|null $observer = null): void { foreach ($this->source->load() as $message) { $result = ($this->middlewares)($message); diff --git a/src/Pipeline/Source/InMemorySource.php b/src/Pipeline/Source/InMemorySource.php index 9eecd2e77..4c02fc068 100644 --- a/src/Pipeline/Source/InMemorySource.php +++ b/src/Pipeline/Source/InMemorySource.php @@ -11,20 +11,12 @@ final class InMemorySource implements Source { - /** @var list */ - private array $messages; - - /** - * @param list $messages - */ - public function __construct(array $messages) + /** @param list $messages */ + public function __construct(private array $messages) { - $this->messages = $messages; } - /** - * @return Generator - */ + /** @return Generator */ public function load(): Generator { foreach ($this->messages as $event) { diff --git a/src/Pipeline/Source/Source.php b/src/Pipeline/Source/Source.php index da9200e51..259edb58a 100644 --- a/src/Pipeline/Source/Source.php +++ b/src/Pipeline/Source/Source.php @@ -9,9 +9,7 @@ interface Source { - /** - * @return Generator - */ + /** @return Generator */ public function load(): Generator; public function count(): int; diff --git a/src/Pipeline/Source/StoreSource.php b/src/Pipeline/Source/StoreSource.php index 2dfd3374b..a352358f3 100644 --- a/src/Pipeline/Source/StoreSource.php +++ b/src/Pipeline/Source/StoreSource.php @@ -10,18 +10,11 @@ final class StoreSource implements Source { - private PipelineStore $store; - private int $fromIndex; - - public function __construct(PipelineStore $store, int $fromIndex = 0) + public function __construct(private PipelineStore $store, private int $fromIndex = 0) { - $this->store = $store; - $this->fromIndex = $fromIndex; } - /** - * @return Generator - */ + /** @return Generator */ public function load(): Generator { return $this->store->stream($this->fromIndex); diff --git a/src/Pipeline/Target/InMemoryTarget.php b/src/Pipeline/Target/InMemoryTarget.php index b2f9e2e77..b64d7c723 100644 --- a/src/Pipeline/Target/InMemoryTarget.php +++ b/src/Pipeline/Target/InMemoryTarget.php @@ -16,9 +16,7 @@ public function save(Message $message): void $this->messages[] = $message; } - /** - * @return list - */ + /** @return list */ public function messages(): array { return $this->messages; diff --git a/src/Pipeline/Target/ProjectionHandlerTarget.php b/src/Pipeline/Target/ProjectionHandlerTarget.php index 18751ffdc..f23e912c4 100644 --- a/src/Pipeline/Target/ProjectionHandlerTarget.php +++ b/src/Pipeline/Target/ProjectionHandlerTarget.php @@ -7,16 +7,11 @@ use Patchlevel\EventSourcing\EventBus\Message; use Patchlevel\EventSourcing\Projection\ProjectionHandler; -/** - * @deprecated use ProjectorRepositoryTarget instead - */ +/** @deprecated use ProjectorRepositoryTarget instead */ final class ProjectionHandlerTarget implements Target { - private ProjectionHandler $projectionHandler; - - public function __construct(ProjectionHandler $projectionHandler) + public function __construct(private ProjectionHandler $projectionHandler) { - $this->projectionHandler = $projectionHandler; } public function save(Message $message): void diff --git a/src/Pipeline/Target/ProjectionTarget.php b/src/Pipeline/Target/ProjectionTarget.php index 8553038d1..a04fd0c43 100644 --- a/src/Pipeline/Target/ProjectionTarget.php +++ b/src/Pipeline/Target/ProjectionTarget.php @@ -9,20 +9,18 @@ use Patchlevel\EventSourcing\Projection\MetadataAwareProjectionHandler; use Patchlevel\EventSourcing\Projection\Projection; -/** - * @deprecated use ProjectorTarget instead - */ +/** @deprecated use ProjectorTarget instead */ final class ProjectionTarget implements Target { private MetadataAwareProjectionHandler $projectionHandler; public function __construct( Projection $projection, - ?ProjectionMetadataFactory $projectionMetadataFactory = null + ProjectionMetadataFactory|null $projectionMetadataFactory = null, ) { $this->projectionHandler = new MetadataAwareProjectionHandler( [$projection], - $projectionMetadataFactory + $projectionMetadataFactory, ); } diff --git a/src/Pipeline/Target/ProjectorRepositoryTarget.php b/src/Pipeline/Target/ProjectorRepositoryTarget.php index 213506f3d..412c41e70 100644 --- a/src/Pipeline/Target/ProjectorRepositoryTarget.php +++ b/src/Pipeline/Target/ProjectorRepositoryTarget.php @@ -14,7 +14,7 @@ final class ProjectorRepositoryTarget implements Target { public function __construct( private readonly ProjectorRepository $projectorRepository, - private readonly ProjectorResolver $projectorResolver = new MetadataProjectorResolver() + private readonly ProjectorResolver $projectorResolver = new MetadataProjectorResolver(), ) { } diff --git a/src/Pipeline/Target/ProjectorTarget.php b/src/Pipeline/Target/ProjectorTarget.php index 19c5269b5..2f9aa9304 100644 --- a/src/Pipeline/Target/ProjectorTarget.php +++ b/src/Pipeline/Target/ProjectorTarget.php @@ -14,7 +14,7 @@ final class ProjectorTarget implements Target { public function __construct( private readonly Projector $projector, - private readonly ProjectorResolver $projectorResolver = new MetadataProjectorResolver() + private readonly ProjectorResolver $projectorResolver = new MetadataProjectorResolver(), ) { } diff --git a/src/Pipeline/Target/StoreTarget.php b/src/Pipeline/Target/StoreTarget.php index 452a3aa5c..c4150d4e0 100644 --- a/src/Pipeline/Target/StoreTarget.php +++ b/src/Pipeline/Target/StoreTarget.php @@ -9,11 +9,8 @@ final class StoreTarget implements Target { - private Store $store; - - public function __construct(Store $store) + public function __construct(private Store $store) { - $this->store = $store; } public function save(Message $message): void diff --git a/src/Projection/MetadataAwareProjectionHandler.php b/src/Projection/MetadataAwareProjectionHandler.php index beb52d65a..51fb55fb1 100644 --- a/src/Projection/MetadataAwareProjectionHandler.php +++ b/src/Projection/MetadataAwareProjectionHandler.php @@ -10,24 +10,16 @@ use Patchlevel\EventSourcing\Projection\Projector\MetadataProjectorResolver; use Patchlevel\EventSourcing\Projection\Projector\ProjectorResolver; -/** - * @deprecated use ProjectorHelper - */ +/** @deprecated use ProjectorHelper */ final class MetadataAwareProjectionHandler implements ProjectionHandler { - /** @var iterable */ - private iterable $projections; - private ProjectionMetadataFactory $metadataFactory; private ProjectorResolver $resolver; - /** - * @param iterable $projections - */ - public function __construct(iterable $projections, ?ProjectionMetadataFactory $metadataFactory = null) + /** @param iterable $projections */ + public function __construct(private iterable $projections, ProjectionMetadataFactory|null $metadataFactory = null) { - $this->projections = $projections; $this->metadataFactory = $metadataFactory ?? new AttributeProjectionMetadataFactory(); $this->resolver = new MetadataProjectorResolver($this->metadataFactory); } @@ -71,9 +63,7 @@ public function drop(): void } } - /** - * @return iterable - */ + /** @return iterable */ public function projections(): iterable { return $this->projections; diff --git a/src/Projection/Projection.php b/src/Projection/Projection.php index bdbfbde59..6b8a458be 100644 --- a/src/Projection/Projection.php +++ b/src/Projection/Projection.php @@ -4,9 +4,7 @@ namespace Patchlevel\EventSourcing\Projection; -/** - * @deprecated use Projector interface - */ +/** @deprecated use Projector interface */ interface Projection { } diff --git a/src/Projection/Projection/Projection.php b/src/Projection/Projection/Projection.php index 8e3a488d0..fed2a761e 100644 --- a/src/Projection/Projection/Projection.php +++ b/src/Projection/Projection/Projection.php @@ -9,7 +9,7 @@ final class Projection public function __construct( private readonly ProjectionId $id, private ProjectionStatus $status = ProjectionStatus::New, - private int $position = 0 + private int $position = 0, ) { } diff --git a/src/Projection/Projection/ProjectionCollection.php b/src/Projection/Projection/ProjectionCollection.php index 275056d00..a66748c33 100644 --- a/src/Projection/Projection/ProjectionCollection.php +++ b/src/Projection/Projection/ProjectionCollection.php @@ -13,17 +13,13 @@ use function array_values; use function count; -/** - * @implements IteratorAggregate - */ +/** @implements IteratorAggregate */ final class ProjectionCollection implements Countable, IteratorAggregate { /** @var array */ private readonly array $projections; - /** - * @param list $projections - */ + /** @param list $projections */ public function __construct(array $projections = []) { $result = []; @@ -63,7 +59,7 @@ public function add(Projection $projection): self [ ...array_values($this->projections), $projection, - ] + ], ); } @@ -82,14 +78,12 @@ public function getLowestProjectionPosition(): int return $min ?: 0; } - /** - * @param callable(Projection $projection):bool $callable - */ + /** @param callable(Projection $projection):bool $callable */ public function filter(callable $callable): self { $projections = array_filter( $this->projections, - $callable + $callable, ); return new self(array_values($projections)); @@ -115,7 +109,7 @@ static function (Projection $projection) use ($criteria): bool { } return true; - } + }, ); } @@ -124,9 +118,7 @@ public function count(): int return count($this->projections); } - /** - * @return ArrayIterator - */ + /** @return ArrayIterator */ public function getIterator(): ArrayIterator { return new ArrayIterator(array_values($this->projections)); diff --git a/src/Projection/Projection/ProjectionCriteria.php b/src/Projection/Projection/ProjectionCriteria.php index d139ebf03..7b58cc98c 100644 --- a/src/Projection/Projection/ProjectionCriteria.php +++ b/src/Projection/Projection/ProjectionCriteria.php @@ -4,16 +4,12 @@ namespace Patchlevel\EventSourcing\Projection\Projection; -/** - * @psalm-immutable - */ +/** @psalm-immutable */ final class ProjectionCriteria { - /** - * @param list|null $ids - */ + /** @param list|null $ids */ public function __construct( - public readonly ?array $ids = null, + public readonly array|null $ids = null, ) { } } diff --git a/src/Projection/Projection/ProjectionId.php b/src/Projection/Projection/ProjectionId.php index 45a80a005..523ac1fac 100644 --- a/src/Projection/Projection/ProjectionId.php +++ b/src/Projection/Projection/ProjectionId.php @@ -13,14 +13,12 @@ use function implode; use function sprintf; -/** - * @psalm-immutable - */ +/** @psalm-immutable */ final class ProjectionId { public function __construct( private readonly string $name, - private readonly int $version + private readonly int $version, ) { } diff --git a/src/Projection/Projection/Store/DoctrineStore.php b/src/Projection/Projection/Store/DoctrineStore.php index 814b15ca7..f898f232c 100644 --- a/src/Projection/Projection/Store/DoctrineStore.php +++ b/src/Projection/Projection/Store/DoctrineStore.php @@ -20,7 +20,7 @@ final class DoctrineStore implements ProjectionStore, SchemaConfigurator { public function __construct( private readonly Connection $connection, - private readonly string $projectionTable = 'projections' + private readonly string $projectionTable = 'projections', ) { } @@ -45,7 +45,7 @@ public function get(ProjectionId $projectionId): Projection return new Projection( $projectionId, ProjectionStatus::from($result['status']), - $result['position'] + $result['position'], ); } @@ -65,11 +65,11 @@ static function (array $data) { return new Projection( new ProjectionId($data['name'], $data['version']), ProjectionStatus::from($data['status']), - $data['position'] + $data['position'], ); }, - $result - ) + $result, + ), ); } @@ -88,7 +88,7 @@ function (Connection $connection) use ($projections): void { [ 'name' => $projection->id()->name(), 'version' => $projection->id()->version(), - ] + ], ); if ($effectedRows === 0) { @@ -102,11 +102,11 @@ function (Connection $connection) use ($projections): void { 'version' => $projection->id()->version(), 'position' => $projection->position(), 'status' => $projection->status()->value, - ] + ], ); } } - } + }, ); } @@ -120,7 +120,7 @@ function (Connection $connection) use ($projectionIds): void { 'version' => $projectionId->version(), ]); } - } + }, ); } diff --git a/src/Projection/ProjectionHandler.php b/src/Projection/ProjectionHandler.php index 18a9100d5..42065f34c 100644 --- a/src/Projection/ProjectionHandler.php +++ b/src/Projection/ProjectionHandler.php @@ -6,9 +6,7 @@ use Patchlevel\EventSourcing\EventBus\Message; -/** - * @deprecated use ProjectorResolver - */ +/** @deprecated use ProjectorResolver */ interface ProjectionHandler { public function handle(Message $message): void; diff --git a/src/Projection/ProjectionListener.php b/src/Projection/ProjectionListener.php index c928b12ff..d9aab638c 100644 --- a/src/Projection/ProjectionListener.php +++ b/src/Projection/ProjectionListener.php @@ -7,16 +7,11 @@ use Patchlevel\EventSourcing\EventBus\Listener; use Patchlevel\EventSourcing\EventBus\Message; -/** - * @deprecated use SyncProjectorListener - */ +/** @deprecated use SyncProjectorListener */ final class ProjectionListener implements Listener { - private ProjectionHandler $projectionHandler; - - public function __construct(ProjectionHandler $projectionHandler) + public function __construct(private ProjectionHandler $projectionHandler) { - $this->projectionHandler = $projectionHandler; } public function __invoke(Message $message): void diff --git a/src/Projection/Projectionist/DefaultProjectionist.php b/src/Projection/Projectionist/DefaultProjectionist.php index d972b9e85..56973992f 100644 --- a/src/Projection/Projectionist/DefaultProjectionist.php +++ b/src/Projection/Projectionist/DefaultProjectionist.php @@ -24,18 +24,18 @@ final class DefaultProjectionist implements Projectionist { /** @var array|null */ - private ?array $projectors = null; + private array|null $projectors = null; public function __construct( private readonly StreamableStore $streamableMessageStore, private readonly ProjectionStore $projectionStore, private readonly ProjectorRepository $projectorRepository, private readonly ProjectorResolver $projectorResolver = new MetadataProjectorResolver(), - private readonly ?LoggerInterface $logger = null + private readonly LoggerInterface|null $logger = null, ) { } - public function boot(ProjectionCriteria $criteria = new ProjectionCriteria(), ?int $limit = null): void + public function boot(ProjectionCriteria $criteria = new ProjectionCriteria(), int|null $limit = null): void { $projections = $this->projections() ->filter(static fn (Projection $projection) => $projection->isNew() || $projection->isBooting()) @@ -117,7 +117,7 @@ public function boot(ProjectionCriteria $criteria = new ProjectionCriteria(), ?i $this->logger?->info('finish'); } - public function run(ProjectionCriteria $criteria = new ProjectionCriteria(), ?int $limit = null): void + public function run(ProjectionCriteria $criteria = new ProjectionCriteria(), int|null $limit = null): void { $projections = $this->projections() ->filterByProjectionStatus(ProjectionStatus::Active) @@ -159,8 +159,8 @@ public function run(ProjectionCriteria $criteria = new ProjectionCriteria(), ?in sprintf( 'projection "%s" is farther than the current position (%s) and will be skipped', $projection->id()->toString(), - $projection->position() - ) + $projection->position(), + ), ); continue; @@ -196,7 +196,7 @@ public function teardown(ProjectionCriteria $criteria = new ProjectionCriteria() if (!$projector) { $this->logger?->warning( - sprintf('projector with the id "%s" not found, skipped', $projection->id()->toString()) + sprintf('projector with the id "%s" not found, skipped', $projection->id()->toString()), ); continue; @@ -209,7 +209,7 @@ public function teardown(ProjectionCriteria $criteria = new ProjectionCriteria() $dropMethod(); } catch (Throwable $e) { $this->logger?->error( - sprintf('projection for "%s" could not be removed, skipped', $projection->id()->toString()) + sprintf('projection for "%s" could not be removed, skipped', $projection->id()->toString()), ); $this->logger?->error($e->getMessage()); continue; @@ -219,7 +219,7 @@ public function teardown(ProjectionCriteria $criteria = new ProjectionCriteria() $this->projectionStore->remove($projection->id()); $this->logger?->info( - sprintf('projection for "%s" removed', $projection->id()->toString()) + sprintf('projection for "%s" removed', $projection->id()->toString()), ); } } @@ -235,7 +235,7 @@ public function remove(ProjectionCriteria $criteria = new ProjectionCriteria()): $this->projectionStore->remove($projection->id()); $this->logger?->info( - sprintf('projection for "%s" removed without a suitable projector', $projection->id()->toString()) + sprintf('projection for "%s" removed without a suitable projector', $projection->id()->toString()), ); continue; @@ -247,7 +247,7 @@ public function remove(ProjectionCriteria $criteria = new ProjectionCriteria()): $this->projectionStore->remove($projection->id()); $this->logger?->info( - sprintf('projection for "%s" removed', $projection->id()->toString()) + sprintf('projection for "%s" removed', $projection->id()->toString()), ); continue; @@ -259,8 +259,8 @@ public function remove(ProjectionCriteria $criteria = new ProjectionCriteria()): $this->logger?->error( sprintf( 'projection "%s" drop method could not be executed:', - $projection->id()->toString() - ) + $projection->id()->toString(), + ), ); $this->logger?->error($e->getMessage()); } @@ -268,7 +268,7 @@ public function remove(ProjectionCriteria $criteria = new ProjectionCriteria()): $this->projectionStore->remove($projection->id()); $this->logger?->info( - sprintf('projection for "%s" removed', $projection->id()->toString()) + sprintf('projection for "%s" removed', $projection->id()->toString()), ); } } @@ -321,12 +321,12 @@ private function handleMessage(Message $message, Projection $projection): void sprintf( 'projector "%s" processed the event "%s"', $projection->id()->toString(), - $message->event()::class - ) + $message->event()::class, + ), ); } catch (Throwable $e) { $this->logger?->error( - sprintf('projector "%s" could not process the message', $projection->id()->toString()) + sprintf('projector "%s" could not process the message', $projection->id()->toString()), ); $this->logger?->error($e->getMessage()); $projection->error(); @@ -340,16 +340,14 @@ private function handleMessage(Message $message, Projection $projection): void $this->projectionStore->save($projection); } - private function projector(ProjectionId $projectorId): ?Projector + private function projector(ProjectionId $projectorId): Projector|null { $projectors = $this->projectors(); return $projectors[$projectorId->toString()] ?? null; } - /** - * @return array - */ + /** @return array */ private function projectors(): array { if ($this->projectors === null) { @@ -358,7 +356,7 @@ private function projectors(): array foreach ($this->projectorRepository->projectors() as $projector) { if (!$projector instanceof VersionedProjector) { $this->logger?->debug( - sprintf('projector "%s" is not stateful', $projector::class) + sprintf('projector "%s" is not stateful', $projector::class), ); continue; diff --git a/src/Projection/Projectionist/Projectionist.php b/src/Projection/Projectionist/Projectionist.php index 0d35d7f8a..99980b3f8 100644 --- a/src/Projection/Projectionist/Projectionist.php +++ b/src/Projection/Projectionist/Projectionist.php @@ -9,12 +9,10 @@ interface Projectionist { - public function boot(ProjectionCriteria $criteria = new ProjectionCriteria(), ?int $limit = null): void; + public function boot(ProjectionCriteria $criteria = new ProjectionCriteria(), int|null $limit = null): void; - /** - * @param positive-int $limit - */ - public function run(ProjectionCriteria $criteria = new ProjectionCriteria(), ?int $limit = null): void; + /** @param positive-int $limit */ + public function run(ProjectionCriteria $criteria = new ProjectionCriteria(), int|null $limit = null): void; public function teardown(ProjectionCriteria $criteria = new ProjectionCriteria()): void; diff --git a/src/Projection/Projector/InMemoryProjectorRepository.php b/src/Projection/Projector/InMemoryProjectorRepository.php index 348032d14..4643784c2 100644 --- a/src/Projection/Projector/InMemoryProjectorRepository.php +++ b/src/Projection/Projector/InMemoryProjectorRepository.php @@ -6,17 +6,13 @@ final class InMemoryProjectorRepository implements ProjectorRepository { - /** - * @param iterable $projectors - */ + /** @param iterable $projectors */ public function __construct( private readonly iterable $projectors = [], ) { } - /** - * @return list - */ + /** @return list */ public function projectors(): array { return [...$this->projectors]; diff --git a/src/Projection/Projector/MetadataProjectorResolver.php b/src/Projection/Projector/MetadataProjectorResolver.php index a5517158d..5bbb0aa80 100644 --- a/src/Projection/Projector/MetadataProjectorResolver.php +++ b/src/Projection/Projector/MetadataProjectorResolver.php @@ -15,11 +15,11 @@ final class MetadataProjectorResolver implements ProjectorResolver { public function __construct( - private readonly ProjectionMetadataFactory $metadataFactory = new AttributeProjectionMetadataFactory() + private readonly ProjectionMetadataFactory $metadataFactory = new AttributeProjectionMetadataFactory(), ) { } - public function resolveCreateMethod(Projection $projector): ?Closure + public function resolveCreateMethod(Projection $projector): Closure|null { $metadata = $this->metadataFactory->metadata($projector::class); $method = $metadata->createMethod; @@ -31,7 +31,7 @@ public function resolveCreateMethod(Projection $projector): ?Closure return $projector->$method(...); } - public function resolveDropMethod(Projection $projector): ?Closure + public function resolveDropMethod(Projection $projector): Closure|null { $metadata = $this->metadataFactory->metadata($projector::class); $method = $metadata->dropMethod; @@ -43,7 +43,7 @@ public function resolveDropMethod(Projection $projector): ?Closure return $projector->$method(...); } - public function resolveHandleMethod(Projection $projector, Message $message): ?Closure + public function resolveHandleMethod(Projection $projector, Message $message): Closure|null { $event = $message->event(); $metadata = $this->metadataFactory->metadata($projector::class); diff --git a/src/Projection/Projector/ProjectorHelper.php b/src/Projection/Projector/ProjectorHelper.php index b83c12143..6a449e333 100644 --- a/src/Projection/Projector/ProjectorHelper.php +++ b/src/Projection/Projector/ProjectorHelper.php @@ -9,7 +9,7 @@ final class ProjectorHelper { public function __construct( - private readonly ProjectorResolver $projectorResolver = new MetadataProjectorResolver() + private readonly ProjectorResolver $projectorResolver = new MetadataProjectorResolver(), ) { } diff --git a/src/Projection/Projector/ProjectorRepository.php b/src/Projection/Projector/ProjectorRepository.php index be97eeb2b..6840f83cf 100644 --- a/src/Projection/Projector/ProjectorRepository.php +++ b/src/Projection/Projector/ProjectorRepository.php @@ -6,8 +6,6 @@ interface ProjectorRepository { - /** - * @return list - */ + /** @return list */ public function projectors(): array; } diff --git a/src/Projection/Projector/ProjectorResolver.php b/src/Projection/Projector/ProjectorResolver.php index dbdd70be2..6510fbccf 100644 --- a/src/Projection/Projector/ProjectorResolver.php +++ b/src/Projection/Projector/ProjectorResolver.php @@ -10,9 +10,9 @@ interface ProjectorResolver { - public function resolveCreateMethod(Projection $projector): ?Closure; + public function resolveCreateMethod(Projection $projector): Closure|null; - public function resolveDropMethod(Projection $projector): ?Closure; + public function resolveDropMethod(Projection $projector): Closure|null; - public function resolveHandleMethod(Projection $projector, Message $message): ?Closure; + public function resolveHandleMethod(Projection $projector, Message $message): Closure|null; } diff --git a/src/Repository/DefaultRepository.php b/src/Repository/DefaultRepository.php index 4ad3b47c9..f6d33fbc6 100644 --- a/src/Repository/DefaultRepository.php +++ b/src/Repository/DefaultRepository.php @@ -32,40 +32,25 @@ */ final class DefaultRepository implements Repository { - private Store $store; - private EventBus $eventBus; - - /** @var class-string */ - private string $aggregateClass; - - private ?SnapshotStore $snapshotStore; private LoggerInterface $logger; private AggregateRootMetadata $metadata; private MessageDecorator $messageDecorator; - /** - * @param class-string $aggregateClass - */ + /** @param class-string $aggregateClass */ public function __construct( - Store $store, - EventBus $eventBus, - string $aggregateClass, - ?SnapshotStore $snapshotStore = null, - ?MessageDecorator $messageDecorator = null, - ?LoggerInterface $logger = null + private Store $store, + private EventBus $eventBus, + private string $aggregateClass, + private SnapshotStore|null $snapshotStore = null, + MessageDecorator|null $messageDecorator = null, + LoggerInterface|null $logger = null, ) { - $this->store = $store; - $this->eventBus = $eventBus; - $this->aggregateClass = $aggregateClass; - $this->snapshotStore = $snapshotStore; $this->messageDecorator = $messageDecorator ?? new RecordedOnDecorator(new SystemClock()); $this->logger = $logger ?? new NullLogger(); $this->metadata = $aggregateClass::metadata(); } - /** - * @return T - */ + /** @return T */ public function load(string $id): AggregateRoot { $aggregateClass = $this->aggregateClass; @@ -80,16 +65,16 @@ public function load(string $id): AggregateRoot sprintf( 'snapshot for aggregate "%s" with the id "%s" not found', $aggregateClass, - $id - ) + $id, + ), ); } catch (SnapshotVersionInvalid) { $this->logger->debug( sprintf( 'snapshot for aggregate "%s" with the id "%s" is invalid', $aggregateClass, - $id - ) + $id, + ), ); } } @@ -103,9 +88,9 @@ public function load(string $id): AggregateRoot $aggregate = $aggregateClass::createFromEvents( array_map( static fn (Message $message) => $message->event(), - $messages + $messages, ), - $messages[0]->playhead() - 1 + $messages[0]->playhead() - 1, ); if ($this->snapshotStore && $this->metadata->snapshotStore) { @@ -120,9 +105,7 @@ public function has(string $id): bool return $this->store->has($this->aggregateClass, $id); } - /** - * @param T $aggregate - */ + /** @param T $aggregate */ public function save(AggregateRoot $aggregate): void { $this->assertRightAggregate($aggregate); @@ -141,7 +124,7 @@ public function save(AggregateRoot $aggregate): void $aggregate::class, $aggregate->aggregateRootId(), $aggregate->playhead(), - count($events) + count($events), ); } @@ -154,7 +137,7 @@ static function (object $event) use ($aggregate, &$playhead, $messageDecorator) return $messageDecorator($message); }, - $events + $events, ); if ($this->store instanceof TransactionStore) { @@ -170,7 +153,7 @@ static function (object $event) use ($aggregate, &$playhead, $messageDecorator) $this->store->archiveMessages( $message->aggregateClass(), $message->aggregateId(), - $message->playhead() + $message->playhead(), ); } } @@ -203,7 +186,7 @@ private function loadFromSnapshot(string $aggregateClass, string $id): Aggregate $events = array_map( static fn (Message $message) => $message->event(), - $messages + $messages, ); try { diff --git a/src/Repository/DefaultRepositoryManager.php b/src/Repository/DefaultRepositoryManager.php index 840993621..68b703284 100644 --- a/src/Repository/DefaultRepositoryManager.php +++ b/src/Repository/DefaultRepositoryManager.php @@ -20,10 +20,6 @@ final class DefaultRepositoryManager implements RepositoryManager { - private AggregateRootRegistry $aggregateRootRegistry; - private Store $store; - private EventBus $eventBus; - private ?SnapshotStore $snapshotStore; private MessageDecorator $messageDecorator; private LoggerInterface $logger; @@ -31,17 +27,13 @@ final class DefaultRepositoryManager implements RepositoryManager private array $instances = []; public function __construct( - AggregateRootRegistry $aggregateRootRegistry, - Store $store, - EventBus $eventBus, - ?SnapshotStore $snapshotStore = null, - ?MessageDecorator $messageDecorator = null, - ?LoggerInterface $logger = null + private AggregateRootRegistry $aggregateRootRegistry, + private Store $store, + private EventBus $eventBus, + private SnapshotStore|null $snapshotStore = null, + MessageDecorator|null $messageDecorator = null, + LoggerInterface|null $logger = null, ) { - $this->aggregateRootRegistry = $aggregateRootRegistry; - $this->store = $store; - $this->eventBus = $eventBus; - $this->snapshotStore = $snapshotStore; $this->messageDecorator = $messageDecorator ?? new RecordedOnDecorator(new SystemClock()); $this->logger = $logger ?? new NullLogger(); } @@ -72,7 +64,7 @@ public function get(string $aggregateClass): Repository $aggregateClass, $this->snapshotStore, $this->messageDecorator, - $this->logger + $this->logger, ); } } diff --git a/src/Repository/InvalidAggregateClass.php b/src/Repository/InvalidAggregateClass.php index e10c5a802..0ba6daf61 100644 --- a/src/Repository/InvalidAggregateClass.php +++ b/src/Repository/InvalidAggregateClass.php @@ -6,16 +6,14 @@ use function sprintf; -/** - * @deprecated - */ +/** @deprecated */ final class InvalidAggregateClass extends RepositoryException { public static function notAggregateRoot(string $aggregateClass): self { return new self(sprintf( 'Class "%s" is not an AggregateRoot.', - $aggregateClass + $aggregateClass, )); } @@ -23,7 +21,7 @@ public static function notSnapshotableAggregateRoot(string $aggregateClass): sel { return new self(sprintf( 'Class "%s" is not a SnapshotableAggregateRoot.', - $aggregateClass + $aggregateClass, )); } } diff --git a/src/Repository/PlayheadMismatch.php b/src/Repository/PlayheadMismatch.php index 722c1137b..54eaaecff 100644 --- a/src/Repository/PlayheadMismatch.php +++ b/src/Repository/PlayheadMismatch.php @@ -15,7 +15,7 @@ public function __construct(string $aggregateClass, string $aggregateId, int $pl $playhead, $eventCount, $aggregateClass, - $aggregateId + $aggregateId, )); } } diff --git a/src/Repository/Repository.php b/src/Repository/Repository.php index 55538f6a2..253732aa3 100644 --- a/src/Repository/Repository.php +++ b/src/Repository/Repository.php @@ -6,20 +6,14 @@ use Patchlevel\EventSourcing\Aggregate\AggregateRoot; -/** - * @template T of AggregateRoot - */ +/** @template T of AggregateRoot */ interface Repository { - /** - * @return T - */ + /** @return T */ public function load(string $id): AggregateRoot; public function has(string $id): bool; - /** - * @param T $aggregate - */ + /** @param T $aggregate */ public function save(AggregateRoot $aggregate): void; } diff --git a/src/Repository/SnapshotRebuildFailed.php b/src/Repository/SnapshotRebuildFailed.php index db5bd9a7f..30360fb83 100644 --- a/src/Repository/SnapshotRebuildFailed.php +++ b/src/Repository/SnapshotRebuildFailed.php @@ -11,32 +11,21 @@ final class SnapshotRebuildFailed extends RepositoryException { - /** @var class-string */ - private string $aggregateClass; - private string $aggregateId; - - /** - * @param class-string $aggregateClass - */ - public function __construct(string $aggregateClass, string $aggregateId, Throwable $previous) + /** @param class-string $aggregateClass */ + public function __construct(private string $aggregateClass, private string $aggregateId, Throwable $previous) { parent::__construct( sprintf( 'Rebuild from snapshot of aggregate "%s" with the id "%s" failed', $aggregateClass, - $aggregateId + $aggregateId, ), 0, - $previous + $previous, ); - - $this->aggregateClass = $aggregateClass; - $this->aggregateId = $aggregateId; } - /** - * @return class-string - */ + /** @return class-string */ public function aggregateClass(): string { return $this->aggregateClass; diff --git a/src/Repository/WrongAggregate.php b/src/Repository/WrongAggregate.php index 84cf78d2a..3c864a671 100644 --- a/src/Repository/WrongAggregate.php +++ b/src/Repository/WrongAggregate.php @@ -15,7 +15,7 @@ final class WrongAggregate extends RepositoryException public function __construct(string $aggregateClass, string $expected) { parent::__construct( - sprintf('Wrong aggregate given: got "%s" but expected "%s"', $aggregateClass, $expected) + sprintf('Wrong aggregate given: got "%s" but expected "%s"', $aggregateClass, $expected), ); } } diff --git a/src/Schema/ChainSchemaConfigurator.php b/src/Schema/ChainSchemaConfigurator.php index 6047b9886..59d3ea95c 100644 --- a/src/Schema/ChainSchemaConfigurator.php +++ b/src/Schema/ChainSchemaConfigurator.php @@ -9,11 +9,9 @@ final class ChainSchemaConfigurator implements SchemaConfigurator { - /** - * @param iterable $schemaConfigurator - */ + /** @param iterable $schemaConfigurator */ public function __construct( - private readonly iterable $schemaConfigurator + private readonly iterable $schemaConfigurator, ) { } diff --git a/src/Schema/DoctrineMigrationSchemaProvider.php b/src/Schema/DoctrineMigrationSchemaProvider.php index 1f5f59105..49fe2e5a3 100644 --- a/src/Schema/DoctrineMigrationSchemaProvider.php +++ b/src/Schema/DoctrineMigrationSchemaProvider.php @@ -10,7 +10,7 @@ final class DoctrineMigrationSchemaProvider implements SchemaProvider { public function __construct( - private readonly DoctrineSchemaProvider $doctrineSchemaProvider + private readonly DoctrineSchemaProvider $doctrineSchemaProvider, ) { } diff --git a/src/Schema/DoctrineSchemaDirector.php b/src/Schema/DoctrineSchemaDirector.php index eeecabfeb..305d98cba 100644 --- a/src/Schema/DoctrineSchemaDirector.php +++ b/src/Schema/DoctrineSchemaDirector.php @@ -26,9 +26,7 @@ public function create(): void } } - /** - * @return list - */ + /** @return list */ public function dryRunCreate(): array { return $this->schema()->toSql($this->connection->getDatabasePlatform()); @@ -43,9 +41,7 @@ public function update(): void } } - /** - * @return list - */ + /** @return list */ public function dryRunUpdate(): array { $schemaManager = $this->connection->createSchemaManager(); @@ -68,9 +64,7 @@ public function drop(): void } } - /** - * @return list - */ + /** @return list */ public function dryRunDrop(): array { $currentSchema = $this->connection->createSchemaManager()->createSchema(); diff --git a/src/Schema/DoctrineSchemaManager.php b/src/Schema/DoctrineSchemaManager.php index dbb0bbe90..549bf7fea 100644 --- a/src/Schema/DoctrineSchemaManager.php +++ b/src/Schema/DoctrineSchemaManager.php @@ -9,9 +9,7 @@ use function sprintf; -/** - * @deprecated use DoctrineSchemaDirector - */ +/** @deprecated use DoctrineSchemaDirector */ final class DoctrineSchemaManager implements DryRunSchemaManager { public function create(Store $store): void @@ -28,9 +26,7 @@ public function create(Store $store): void } } - /** - * @return list - */ + /** @return list */ public function dryRunCreate(Store $store): array { if (!$store instanceof DoctrineStore) { @@ -54,9 +50,7 @@ public function update(Store $store): void } } - /** - * @return list - */ + /** @return list */ public function dryRunUpdate(Store $store): array { if (!$store instanceof DoctrineStore) { @@ -89,9 +83,7 @@ public function drop(Store $store): void } } - /** - * @return list - */ + /** @return list */ public function dryRunDrop(Store $store): array { if (!$store instanceof DoctrineStore) { diff --git a/src/Schema/DoctrineSchemaSubscriber.php b/src/Schema/DoctrineSchemaSubscriber.php index 30f2e8c86..861acae5f 100644 --- a/src/Schema/DoctrineSchemaSubscriber.php +++ b/src/Schema/DoctrineSchemaSubscriber.php @@ -13,7 +13,7 @@ final class DoctrineSchemaSubscriber implements EventSubscriber { public function __construct( - private readonly SchemaConfigurator $schemaConfigurator + private readonly SchemaConfigurator $schemaConfigurator, ) { } @@ -21,13 +21,11 @@ public function postGenerateSchema(GenerateSchemaEventArgs $event): void { $this->schemaConfigurator->configureSchema( $event->getSchema(), - $event->getEntityManager()->getConnection() + $event->getEntityManager()->getConnection(), ); } - /** - * @return list - */ + /** @return list */ public function getSubscribedEvents(): array { $subscribedEvents = []; diff --git a/src/Schema/DryRunSchemaDirector.php b/src/Schema/DryRunSchemaDirector.php index 6b4531b83..db35943fa 100644 --- a/src/Schema/DryRunSchemaDirector.php +++ b/src/Schema/DryRunSchemaDirector.php @@ -6,18 +6,12 @@ interface DryRunSchemaDirector extends SchemaDirector { - /** - * @return list - */ + /** @return list */ public function dryRunCreate(): array; - /** - * @return list - */ + /** @return list */ public function dryRunUpdate(): array; - /** - * @return list - */ + /** @return list */ public function dryRunDrop(): array; } diff --git a/src/Schema/DryRunSchemaManager.php b/src/Schema/DryRunSchemaManager.php index bd60eb934..6e734c924 100644 --- a/src/Schema/DryRunSchemaManager.php +++ b/src/Schema/DryRunSchemaManager.php @@ -6,23 +6,15 @@ use Patchlevel\EventSourcing\Store\Store; -/** - * @deprecated use DryRunSchemaDirector - */ +/** @deprecated use DryRunSchemaDirector */ interface DryRunSchemaManager extends SchemaManager { - /** - * @return list - */ + /** @return list */ public function dryRunCreate(Store $store): array; - /** - * @return list - */ + /** @return list */ public function dryRunUpdate(Store $store): array; - /** - * @return list - */ + /** @return list */ public function dryRunDrop(Store $store): array; } diff --git a/src/Schema/MigrationSchemaProvider.php b/src/Schema/MigrationSchemaProvider.php index 5fc3cfb85..71a3c1a46 100644 --- a/src/Schema/MigrationSchemaProvider.php +++ b/src/Schema/MigrationSchemaProvider.php @@ -8,13 +8,11 @@ use Doctrine\Migrations\Provider\SchemaProvider; use Patchlevel\EventSourcing\Store\DoctrineStore; -/** - * @deprecated use DoctrineMigrationSchemaProvider - */ +/** @deprecated use DoctrineMigrationSchemaProvider */ final class MigrationSchemaProvider implements SchemaProvider { public function __construct( - private readonly DoctrineStore $doctrineStore + private readonly DoctrineStore $doctrineStore, ) { } diff --git a/src/Schema/SchemaManager.php b/src/Schema/SchemaManager.php index 486c5cfe3..7158a3557 100644 --- a/src/Schema/SchemaManager.php +++ b/src/Schema/SchemaManager.php @@ -6,9 +6,7 @@ use Patchlevel\EventSourcing\Store\Store; -/** - * @deprecated use SchemaDirector - */ +/** @deprecated use SchemaDirector */ interface SchemaManager { public function create(Store $store): void; diff --git a/src/Schema/StoreNotSupported.php b/src/Schema/StoreNotSupported.php index 260fbec21..737c50d5f 100644 --- a/src/Schema/StoreNotSupported.php +++ b/src/Schema/StoreNotSupported.php @@ -9,22 +9,18 @@ use function sprintf; -/** - * @deprecated - */ +/** @deprecated */ final class StoreNotSupported extends RuntimeException { - /** - * @param class-string $need - */ + /** @param class-string $need */ public function __construct(Store $store, string $need) { parent::__construct( sprintf( 'store "%s" is not supported, need "%s"', $store::class, - $need - ) + $need, + ), ); } } diff --git a/src/Serializer/DefaultEventSerializer.php b/src/Serializer/DefaultEventSerializer.php index ad790826b..803bca957 100644 --- a/src/Serializer/DefaultEventSerializer.php +++ b/src/Serializer/DefaultEventSerializer.php @@ -16,26 +16,15 @@ final class DefaultEventSerializer implements EventSerializer { - private EventRegistry $eventRegistry; - private EventHydrator $hydrator; - private Encoder $encoder; - private ?Upcaster $upcaster; - public function __construct( - EventRegistry $eventRegistry, - EventHydrator $hydrator, - Encoder $encoder, - ?Upcaster $upcaster = null + private EventRegistry $eventRegistry, + private EventHydrator $hydrator, + private Encoder $encoder, + private Upcaster|null $upcaster = null, ) { - $this->eventRegistry = $eventRegistry; - $this->hydrator = $hydrator; - $this->encoder = $encoder; - $this->upcaster = $upcaster; } - /** - * @param array $options - */ + /** @param array $options */ public function serialize(object $event, array $options = []): SerializedEvent { $name = $this->eventRegistry->eventName($event::class); @@ -43,13 +32,11 @@ public function serialize(object $event, array $options = []): SerializedEvent return new SerializedEvent( $name, - $this->encoder->encode($data, $options) + $this->encoder->encode($data, $options), ); } - /** - * @param array $options - */ + /** @param array $options */ public function deserialize(SerializedEvent $data, array $options = []): object { $payload = $this->encoder->decode($data->payload, $options); @@ -66,16 +53,14 @@ public function deserialize(SerializedEvent $data, array $options = []): object return $this->hydrator->hydrate($class, $payload); } - /** - * @param list $paths - */ - public static function createFromPaths(array $paths, ?Upcaster $upcaster = null): static + /** @param list $paths */ + public static function createFromPaths(array $paths, Upcaster|null $upcaster = null): static { return new self( (new AttributeEventRegistryFactory())->create($paths), new MetadataEventHydrator(new AttributeEventMetadataFactory()), new JsonEncoder(), - $upcaster + $upcaster, ); } } diff --git a/src/Serializer/Encoder/DecodeNotPossible.php b/src/Serializer/Encoder/DecodeNotPossible.php index 6fb5d75e9..b88bbd530 100644 --- a/src/Serializer/Encoder/DecodeNotPossible.php +++ b/src/Serializer/Encoder/DecodeNotPossible.php @@ -11,19 +11,15 @@ final class DecodeNotPossible extends SerializeException { - private string $data; - - public function __construct(string $data, ?Throwable $previous = null) + public function __construct(private string $data, Throwable|null $previous = null) { - $this->data = $data; - parent::__construct( sprintf( 'deserialization of "%s" data is not possible', - $data + $data, ), 0, - $previous + $previous, ); } diff --git a/src/Serializer/Encoder/EncodeNotPossible.php b/src/Serializer/Encoder/EncodeNotPossible.php index 2c6d67ef2..b11072f72 100644 --- a/src/Serializer/Encoder/EncodeNotPossible.php +++ b/src/Serializer/Encoder/EncodeNotPossible.php @@ -9,26 +9,17 @@ final class EncodeNotPossible extends SerializeException { - /** @var array */ - private array $data; - - /** - * @param array $data - */ - public function __construct(array $data, ?Throwable $previous = null) + /** @param array $data */ + public function __construct(private array $data, Throwable|null $previous = null) { parent::__construct( 'serialization is not possible', 0, - $previous + $previous, ); - - $this->data = $data; } - /** - * @return array - */ + /** @return array */ public function data(): array { return $this->data; diff --git a/src/Serializer/EventSerializer.php b/src/Serializer/EventSerializer.php index 38fecc1d4..9835dd327 100644 --- a/src/Serializer/EventSerializer.php +++ b/src/Serializer/EventSerializer.php @@ -6,13 +6,9 @@ interface EventSerializer { - /** - * @param array $options - */ + /** @param array $options */ public function serialize(object $event, array $options = []): SerializedEvent; - /** - * @param array $options - */ + /** @param array $options */ public function deserialize(SerializedEvent $data, array $options = []): object; } diff --git a/src/Serializer/Hydrator/AggregateRootHydrator.php b/src/Serializer/Hydrator/AggregateRootHydrator.php index a47b7db49..4fb81392b 100644 --- a/src/Serializer/Hydrator/AggregateRootHydrator.php +++ b/src/Serializer/Hydrator/AggregateRootHydrator.php @@ -18,8 +18,6 @@ interface AggregateRootHydrator */ public function hydrate(string $class, array $data): AggregateRoot; - /** - * @return array - */ + /** @return array */ public function extract(AggregateRoot $aggregateRoot): array; } diff --git a/src/Serializer/Hydrator/DenormalizationFailure.php b/src/Serializer/Hydrator/DenormalizationFailure.php index 707aec115..b721fd9dc 100644 --- a/src/Serializer/Hydrator/DenormalizationFailure.php +++ b/src/Serializer/Hydrator/DenormalizationFailure.php @@ -21,10 +21,10 @@ public function __construct(string $class, string $property, string $normalizer, 'denormalization for the property "%s" in the class "%s" with the normalizer "%s" failed.', $property, $class, - $normalizer + $normalizer, ), 0, - $e + $e, ); } } diff --git a/src/Serializer/Hydrator/EventHydrator.php b/src/Serializer/Hydrator/EventHydrator.php index 1d4eec8b3..e5c23f8b9 100644 --- a/src/Serializer/Hydrator/EventHydrator.php +++ b/src/Serializer/Hydrator/EventHydrator.php @@ -16,8 +16,6 @@ interface EventHydrator */ public function hydrate(string $class, array $data): object; - /** - * @return array - */ + /** @return array */ public function extract(object $object): array; } diff --git a/src/Serializer/Hydrator/MetadataAggregateRootHydrator.php b/src/Serializer/Hydrator/MetadataAggregateRootHydrator.php index 4d6fd42a3..dfbb8736b 100644 --- a/src/Serializer/Hydrator/MetadataAggregateRootHydrator.php +++ b/src/Serializer/Hydrator/MetadataAggregateRootHydrator.php @@ -21,7 +21,7 @@ final class MetadataAggregateRootHydrator implements AggregateRootHydrator /** @var array */ private array $reflectionClassCache = []; - private ?ReflectionProperty $playheadReflection = null; + private ReflectionProperty|null $playheadReflection = null; /** * @param class-string $class @@ -49,7 +49,7 @@ public function hydrate(string $class, array $data): AggregateRoot $class, $propertyMetadata->reflection->getName(), $propertyMetadata->normalizer::class, - $e + $e, ); } } @@ -60,7 +60,7 @@ public function hydrate(string $class, array $data): AggregateRoot throw new TypeMismatch( $class, $propertyMetadata->reflection->getName(), - $e + $e, ); } } @@ -74,9 +74,7 @@ public function hydrate(string $class, array $data): AggregateRoot return $aggregateRoot; } - /** - * @return array - */ + /** @return array */ public function extract(AggregateRoot $aggregateRoot): array { $metadata = $aggregateRoot::metadata(); @@ -96,7 +94,7 @@ public function extract(AggregateRoot $aggregateRoot): array $aggregateRoot::class, $propertyMetadata->reflection->getName(), $propertyMetadata->normalizer::class, - $e + $e, ); } } diff --git a/src/Serializer/Hydrator/MetadataEventHydrator.php b/src/Serializer/Hydrator/MetadataEventHydrator.php index 47711ddf9..36577bd91 100644 --- a/src/Serializer/Hydrator/MetadataEventHydrator.php +++ b/src/Serializer/Hydrator/MetadataEventHydrator.php @@ -14,14 +14,11 @@ final class MetadataEventHydrator implements EventHydrator { - private EventMetadataFactory $metadataFactory; - /** @var array */ private array $reflectionClassCache = []; - public function __construct(EventMetadataFactory $metadataFactory) + public function __construct(private EventMetadataFactory $metadataFactory) { - $this->metadataFactory = $metadataFactory; } /** @@ -50,7 +47,7 @@ public function hydrate(string $class, array $data): object $class, $propertyMetadata->reflection->getName(), $propertyMetadata->normalizer::class, - $e + $e, ); } } @@ -61,7 +58,7 @@ public function hydrate(string $class, array $data): object throw new TypeMismatch( $class, $propertyMetadata->reflection->getName(), - $e + $e, ); } } @@ -69,9 +66,7 @@ public function hydrate(string $class, array $data): object return $object; } - /** - * @return array - */ + /** @return array */ public function extract(object $object): array { $metadata = $this->metadataFactory->metadata($object::class); @@ -91,7 +86,7 @@ public function extract(object $object): array $object::class, $propertyMetadata->reflection->getName(), $propertyMetadata->normalizer::class, - $e + $e, ); } } diff --git a/src/Serializer/Hydrator/NormalizationFailure.php b/src/Serializer/Hydrator/NormalizationFailure.php index 0878f74c2..2a68d7036 100644 --- a/src/Serializer/Hydrator/NormalizationFailure.php +++ b/src/Serializer/Hydrator/NormalizationFailure.php @@ -21,10 +21,10 @@ public function __construct(string $class, string $property, string $normalizer, 'normalization for the property "%s" in the class "%s" with the normalizer "%s" failed.', $property, $class, - $normalizer + $normalizer, ), 0, - $e + $e, ); } } diff --git a/src/Serializer/Hydrator/TypeMismatch.php b/src/Serializer/Hydrator/TypeMismatch.php index 8aff324b3..976a4f0d9 100644 --- a/src/Serializer/Hydrator/TypeMismatch.php +++ b/src/Serializer/Hydrator/TypeMismatch.php @@ -10,19 +10,17 @@ final class TypeMismatch extends HydratorException { - /** - * @param class-string $class - */ - public function __construct(string $class, string $property, ?TypeError $previous = null) + /** @param class-string $class */ + public function __construct(string $class, string $property, TypeError|null $previous = null) { parent::__construct( sprintf( 'The value could not be set because the expected type of the property "%s" in class "%s" does not match.', $property, - $class + $class, ), 0, - $previous + $previous, ); } } diff --git a/src/Serializer/Normalizer/ArrayNormalizer.php b/src/Serializer/Normalizer/ArrayNormalizer.php index 5f7d0395e..c27e0460c 100644 --- a/src/Serializer/Normalizer/ArrayNormalizer.php +++ b/src/Serializer/Normalizer/ArrayNormalizer.php @@ -16,10 +16,8 @@ public function __construct(private readonly Normalizer $normalizer) { } - /** - * @return array|null - */ - public function normalize(mixed $value): ?array + /** @return array|null */ + public function normalize(mixed $value): array|null { if ($value === null) { return null; @@ -32,10 +30,8 @@ public function normalize(mixed $value): ?array return array_map(fn (mixed $value): mixed => $this->normalizer->normalize($value), $value); } - /** - * @return array|null - */ - public function denormalize(mixed $value): ?array + /** @return array|null */ + public function denormalize(mixed $value): array|null { if ($value === null) { return null; diff --git a/src/Serializer/Normalizer/DateTimeImmutableNormalizer.php b/src/Serializer/Normalizer/DateTimeImmutableNormalizer.php index fd8449d6d..05fedbcf0 100644 --- a/src/Serializer/Normalizer/DateTimeImmutableNormalizer.php +++ b/src/Serializer/Normalizer/DateTimeImmutableNormalizer.php @@ -13,11 +13,11 @@ final class DateTimeImmutableNormalizer implements Normalizer { public function __construct( - private readonly string $format = DateTimeImmutable::ATOM + private readonly string $format = DateTimeImmutable::ATOM, ) { } - public function normalize(mixed $value): ?string + public function normalize(mixed $value): string|null { if ($value === null) { return null; @@ -30,7 +30,7 @@ public function normalize(mixed $value): ?string return $value->format($this->format); } - public function denormalize(mixed $value): ?DateTimeImmutable + public function denormalize(mixed $value): DateTimeImmutable|null { if ($value === null) { return null; diff --git a/src/Serializer/Normalizer/DateTimeNormalizer.php b/src/Serializer/Normalizer/DateTimeNormalizer.php index 70d6d9626..b66641c17 100644 --- a/src/Serializer/Normalizer/DateTimeNormalizer.php +++ b/src/Serializer/Normalizer/DateTimeNormalizer.php @@ -13,11 +13,11 @@ final class DateTimeNormalizer implements Normalizer { public function __construct( - private readonly string $format = DateTime::ATOM + private readonly string $format = DateTime::ATOM, ) { } - public function normalize(mixed $value): ?string + public function normalize(mixed $value): string|null { if ($value === null) { return null; @@ -30,7 +30,7 @@ public function normalize(mixed $value): ?string return $value->format($this->format); } - public function denormalize(mixed $value): ?DateTime + public function denormalize(mixed $value): DateTime|null { if ($value === null) { return null; diff --git a/src/Serializer/Normalizer/DateTimeZoneNormalizer.php b/src/Serializer/Normalizer/DateTimeZoneNormalizer.php index fe779b8c9..8e0711974 100644 --- a/src/Serializer/Normalizer/DateTimeZoneNormalizer.php +++ b/src/Serializer/Normalizer/DateTimeZoneNormalizer.php @@ -12,7 +12,7 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class DateTimeZoneNormalizer implements Normalizer { - public function normalize(mixed $value): ?string + public function normalize(mixed $value): string|null { if ($value === null) { return null; @@ -25,7 +25,7 @@ public function normalize(mixed $value): ?string return $value->getName(); } - public function denormalize(mixed $value): ?DateTimeZone + public function denormalize(mixed $value): DateTimeZone|null { if ($value === null) { return null; diff --git a/src/Serializer/Normalizer/EnumNormalizer.php b/src/Serializer/Normalizer/EnumNormalizer.php index 31bdb5911..9ad766daa 100644 --- a/src/Serializer/Normalizer/EnumNormalizer.php +++ b/src/Serializer/Normalizer/EnumNormalizer.php @@ -16,7 +16,7 @@ final class EnumNormalizer implements Normalizer { public function __construct( /** @var class-string */ - private readonly string $enum + private readonly string $enum, ) { } @@ -33,7 +33,7 @@ public function normalize(mixed $value): mixed return $value->value; } - public function denormalize(mixed $value): ?BackedEnum + public function denormalize(mixed $value): BackedEnum|null { if ($value === null) { return null; diff --git a/src/Serializer/Normalizer/Normalizer.php b/src/Serializer/Normalizer/Normalizer.php index c5060ba06..d269bdcf0 100644 --- a/src/Serializer/Normalizer/Normalizer.php +++ b/src/Serializer/Normalizer/Normalizer.php @@ -6,13 +6,9 @@ interface Normalizer { - /** - * @throws InvalidArgument - */ + /** @throws InvalidArgument */ public function normalize(mixed $value): mixed; - /** - * @throws InvalidArgument - */ + /** @throws InvalidArgument */ public function denormalize(mixed $value): mixed; } diff --git a/src/Serializer/SerializedEvent.php b/src/Serializer/SerializedEvent.php index 0ceb3d276..362346b1f 100644 --- a/src/Serializer/SerializedEvent.php +++ b/src/Serializer/SerializedEvent.php @@ -8,7 +8,7 @@ final class SerializedEvent { public function __construct( public readonly string $name, - public readonly string $payload + public readonly string $payload, ) { } } diff --git a/src/Serializer/Upcast/Upcast.php b/src/Serializer/Upcast/Upcast.php index 95a5a0a02..ca769d106 100644 --- a/src/Serializer/Upcast/Upcast.php +++ b/src/Serializer/Upcast/Upcast.php @@ -4,17 +4,13 @@ namespace Patchlevel\EventSourcing\Serializer\Upcast; -/** - * @psalm-immutable - */ +/** @psalm-immutable */ final class Upcast { - /** - * @param array $payload - */ + /** @param array $payload */ public function __construct( public readonly string $eventName, - public readonly array $payload + public readonly array $payload, ) { } @@ -23,9 +19,7 @@ public function replaceEventName(string $eventName): self return new self($eventName, $this->payload); } - /** - * @param array $payload - */ + /** @param array $payload */ public function replacePayload(array $payload): self { return new self($this->eventName, $payload); diff --git a/src/Serializer/Upcast/UpcasterChain.php b/src/Serializer/Upcast/UpcasterChain.php index bd358ad56..efb34e10f 100644 --- a/src/Serializer/Upcast/UpcasterChain.php +++ b/src/Serializer/Upcast/UpcasterChain.php @@ -6,11 +6,9 @@ final class UpcasterChain implements Upcaster { - /** - * @param iterable $upcaster - */ + /** @param iterable $upcaster */ public function __construct( - private readonly iterable $upcaster + private readonly iterable $upcaster, ) { } diff --git a/src/Snapshot/Adapter/InMemorySnapshotAdapter.php b/src/Snapshot/Adapter/InMemorySnapshotAdapter.php index 675a28bbe..74fa75bc3 100644 --- a/src/Snapshot/Adapter/InMemorySnapshotAdapter.php +++ b/src/Snapshot/Adapter/InMemorySnapshotAdapter.php @@ -11,17 +11,13 @@ final class InMemorySnapshotAdapter implements SnapshotAdapter /** @var array> */ private array $snapshots = []; - /** - * @param array $data - */ + /** @param array $data */ public function save(string $key, array $data): void { $this->snapshots[$key] = $data; } - /** - * @return array - */ + /** @return array */ public function load(string $key): array { if (!array_key_exists($key, $this->snapshots)) { diff --git a/src/Snapshot/Adapter/Psr16SnapshotAdapter.php b/src/Snapshot/Adapter/Psr16SnapshotAdapter.php index f4d8014c4..5cbc37951 100644 --- a/src/Snapshot/Adapter/Psr16SnapshotAdapter.php +++ b/src/Snapshot/Adapter/Psr16SnapshotAdapter.php @@ -8,29 +8,20 @@ final class Psr16SnapshotAdapter implements SnapshotAdapter { - private CacheInterface $cache; - - public function __construct(CacheInterface $cache) + public function __construct(private CacheInterface $cache) { - $this->cache = $cache; } - /** - * @param array $data - */ + /** @param array $data */ public function save(string $key, array $data): void { $this->cache->set($key, $data); } - /** - * @return array - */ + /** @return array */ public function load(string $key): array { - /** - * @var ?array $data - */ + /** @var ?array $data */ $data = $this->cache->get($key); if ($data === null) { diff --git a/src/Snapshot/Adapter/Psr6SnapshotAdapter.php b/src/Snapshot/Adapter/Psr6SnapshotAdapter.php index 1e37b7ff0..947da09b9 100644 --- a/src/Snapshot/Adapter/Psr6SnapshotAdapter.php +++ b/src/Snapshot/Adapter/Psr6SnapshotAdapter.php @@ -8,16 +8,11 @@ final class Psr6SnapshotAdapter implements SnapshotAdapter { - private CacheItemPoolInterface $cache; - - public function __construct(CacheItemPoolInterface $cache) + public function __construct(private CacheItemPoolInterface $cache) { - $this->cache = $cache; } - /** - * @param array $data - */ + /** @param array $data */ public function save(string $key, array $data): void { $item = $this->cache->getItem($key); @@ -38,9 +33,7 @@ public function load(string $key): array throw new SnapshotNotFound($key); } - /** - * @var array $data - */ + /** @var array $data */ $data = $item->get(); return $data; diff --git a/src/Snapshot/Adapter/SnapshotAdapter.php b/src/Snapshot/Adapter/SnapshotAdapter.php index f45c789a4..98960da78 100644 --- a/src/Snapshot/Adapter/SnapshotAdapter.php +++ b/src/Snapshot/Adapter/SnapshotAdapter.php @@ -6,9 +6,7 @@ interface SnapshotAdapter { - /** - * @param array $data - */ + /** @param array $data */ public function save(string $key, array $data): void; /** diff --git a/src/Snapshot/Adapter/SnapshotNotFound.php b/src/Snapshot/Adapter/SnapshotNotFound.php index a4753d38a..d457c41aa 100644 --- a/src/Snapshot/Adapter/SnapshotNotFound.php +++ b/src/Snapshot/Adapter/SnapshotNotFound.php @@ -15,8 +15,8 @@ public function __construct(string $key) parent::__construct( sprintf( 'snapshot with the key "%s" not found', - $key - ) + $key, + ), ); } } diff --git a/src/Snapshot/AdapterNotFound.php b/src/Snapshot/AdapterNotFound.php index a74e93b55..b637bf734 100644 --- a/src/Snapshot/AdapterNotFound.php +++ b/src/Snapshot/AdapterNotFound.php @@ -14,7 +14,7 @@ public function __construct(string $adapterName) sprintf( 'adapter with the name "%s" not found', $adapterName, - ) + ), ); } } diff --git a/src/Snapshot/DefaultSnapshotStore.php b/src/Snapshot/DefaultSnapshotStore.php index 176e66659..3901dabc0 100644 --- a/src/Snapshot/DefaultSnapshotStore.php +++ b/src/Snapshot/DefaultSnapshotStore.php @@ -15,17 +15,11 @@ final class DefaultSnapshotStore implements SnapshotStore { - /** @var array */ - private array $snapshotAdapters; - private AggregateRootHydrator $hydrator; - /** - * @param array $snapshotAdapters - */ - public function __construct(array $snapshotAdapters, ?AggregateRootHydrator $hydrator = null) + /** @param array $snapshotAdapters */ + public function __construct(private array $snapshotAdapters, AggregateRootHydrator|null $hydrator = null) { - $this->snapshotAdapters = $snapshotAdapters; $this->hydrator = $hydrator ?? new MetadataAggregateRootHydrator(); } @@ -78,9 +72,7 @@ public function load(string $aggregateClass, string $id): AggregateRoot return $this->hydrator->hydrate($aggregateClass, $data['payload']); } - /** - * @param class-string $aggregateClass - */ + /** @param class-string $aggregateClass */ public function adapter(string $aggregateClass): SnapshotAdapter { $adapterName = $aggregateClass::metadata()->snapshotStore; @@ -96,9 +88,7 @@ public function adapter(string $aggregateClass): SnapshotAdapter return $this->snapshotAdapters[$adapterName]; } - /** - * @param class-string $aggregateClass - */ + /** @param class-string $aggregateClass */ private function key(string $aggregateClass, string $aggregateId): string { $aggregateName = $aggregateClass::metadata()->name; @@ -106,10 +96,8 @@ private function key(string $aggregateClass, string $aggregateId): string return sprintf('%s-%s', $aggregateName, $aggregateId); } - /** - * @param class-string $aggregateClass - */ - private function version(string $aggregateClass): ?string + /** @param class-string $aggregateClass */ + private function version(string $aggregateClass): string|null { return $aggregateClass::metadata()->snapshotVersion; } diff --git a/src/Snapshot/Snapshot.php b/src/Snapshot/Snapshot.php index de9b3dc76..4c3309297 100644 --- a/src/Snapshot/Snapshot.php +++ b/src/Snapshot/Snapshot.php @@ -8,28 +8,15 @@ final class Snapshot { - /** @var class-string */ - private readonly string $aggregate; - private readonly string $id; - private readonly int $playhead; - /** @var array */ - private readonly array $payload; - /** * @param class-string $aggregate * @param array $payload */ - public function __construct(string $aggregate, string $id, int $playhead, array $payload) + public function __construct(private readonly string $aggregate, private readonly string $id, private readonly int $playhead, private readonly array $payload) { - $this->aggregate = $aggregate; - $this->id = $id; - $this->playhead = $playhead; - $this->payload = $payload; } - /** - * @return class-string - */ + /** @return class-string */ public function aggregate(): string { return $this->aggregate; @@ -45,9 +32,7 @@ public function playhead(): int return $this->playhead; } - /** - * @return array - */ + /** @return array */ public function payload(): array { return $this->payload; diff --git a/src/Snapshot/SnapshotNotConfigured.php b/src/Snapshot/SnapshotNotConfigured.php index 01c6cda92..bd948a13a 100644 --- a/src/Snapshot/SnapshotNotConfigured.php +++ b/src/Snapshot/SnapshotNotConfigured.php @@ -10,16 +10,14 @@ final class SnapshotNotConfigured extends SnapshotException { - /** - * @param class-string $aggregateClass - */ + /** @param class-string $aggregateClass */ public function __construct(string $aggregateClass) { parent::__construct( sprintf( 'Missing snapshot configuration for the aggregate class "%s"', - $aggregateClass - ) + $aggregateClass, + ), ); } } diff --git a/src/Snapshot/SnapshotNotFound.php b/src/Snapshot/SnapshotNotFound.php index ae72c5001..455de4924 100644 --- a/src/Snapshot/SnapshotNotFound.php +++ b/src/Snapshot/SnapshotNotFound.php @@ -11,19 +11,17 @@ final class SnapshotNotFound extends SnapshotException { - /** - * @param class-string $aggregate - */ - public function __construct(string $aggregate, string $id, ?Throwable $previous = null) + /** @param class-string $aggregate */ + public function __construct(string $aggregate, string $id, Throwable|null $previous = null) { parent::__construct( sprintf( 'snapshot for aggregate "%s" with the id "%s" not found', $aggregate, - $id + $id, ), 0, - $previous + $previous, ); } } diff --git a/src/Snapshot/SnapshotVersionInvalid.php b/src/Snapshot/SnapshotVersionInvalid.php index cab47b2d4..783b53022 100644 --- a/src/Snapshot/SnapshotVersionInvalid.php +++ b/src/Snapshot/SnapshotVersionInvalid.php @@ -13,8 +13,8 @@ public function __construct(string $key) parent::__construct( sprintf( 'snapshot version with the key "%s" is invalid', - $key - ) + $key, + ), ); } } diff --git a/src/Store/CorruptedMetadata.php b/src/Store/CorruptedMetadata.php index 57a94287d..3bba89b4f 100644 --- a/src/Store/CorruptedMetadata.php +++ b/src/Store/CorruptedMetadata.php @@ -13,7 +13,7 @@ public static function fromEntryMismatch(string $expectedId, string $actualId): return new self(sprintf( 'Corrupted metadata: expected id is %s get %s', $expectedId, - $actualId + $actualId, )); } @@ -21,7 +21,7 @@ public static function fromMissingEntry(string $expectedId): self { return new self(sprintf( 'Corrupted metadata: expected id is %s there but it is missing', - $expectedId + $expectedId, )); } } diff --git a/src/Store/DoctrineStore.php b/src/Store/DoctrineStore.php index e6726e68f..fea2f04b5 100644 --- a/src/Store/DoctrineStore.php +++ b/src/Store/DoctrineStore.php @@ -29,7 +29,7 @@ abstract class DoctrineStore implements Store, TransactionStore, OutboxStore, Sp public function __construct( protected Connection $connection, protected EventSerializer $serializer, - protected AggregateRootRegistry $aggregateRootRegistry + protected AggregateRootRegistry $aggregateRootRegistry, ) { } @@ -86,17 +86,15 @@ function (Connection $connection) use ($messages): void { [ 'recorded_on' => Types::DATETIMETZ_IMMUTABLE, 'custom_headers' => Types::JSON, - ] + ], ); } - } + }, ); } - /** - * @return list - */ - public function retrieveOutboxMessages(?int $limit = null): array + /** @return list */ + public function retrieveOutboxMessages(int|null $limit = null): array { $sql = $this->connection->createQueryBuilder() ->select('*') @@ -119,7 +117,7 @@ function (array $data) use ($platform) { ->withRecordedOn(self::normalizeRecordedOn($data['recorded_on'], $platform)) ->withCustomHeaders(self::normalizeCustomHeaders($data['custom_headers'], $platform)); }, - $result + $result, ); } @@ -134,10 +132,10 @@ function (Connection $connection) use ($messages): void { 'aggregate' => $this->aggregateRootRegistry->aggregateName($message->aggregateClass()), 'aggregate_id' => $message->aggregateId(), 'playhead' => $message->playhead(), - ] + ], ); } - } + }, ); } @@ -157,9 +155,7 @@ public function countOutboxMessages(): int return (int)$result; } - /** - * @deprecated use DoctrineSchemaDirector - */ + /** @deprecated use DoctrineSchemaDirector */ public function schema(): Schema { $schema = new Schema([], [], $this->connection->createSchemaManager()->createSchemaConfig()); @@ -182,9 +178,7 @@ protected static function normalizeRecordedOn(string $recordedOn, AbstractPlatfo return $normalizedRecordedOn; } - /** - * @return positive-int - */ + /** @return positive-int */ protected static function normalizePlayhead(string|int $playhead, AbstractPlatform $platform): int { $normalizedPlayhead = Type::getType(Types::INTEGER)->convertToPHPValue($playhead, $platform); @@ -196,9 +190,7 @@ protected static function normalizePlayhead(string|int $playhead, AbstractPlatfo return $normalizedPlayhead; } - /** - * @return array - */ + /** @return array */ protected static function normalizeCustomHeaders(string $customHeaders, AbstractPlatform $platform): array { $normalizedCustomHeaders = Type::getType(Types::JSON)->convertToPHPValue($customHeaders, $platform); diff --git a/src/Store/MultiTableStore.php b/src/Store/MultiTableStore.php index 105956f6f..d28f67ff1 100644 --- a/src/Store/MultiTableStore.php +++ b/src/Store/MultiTableStore.php @@ -24,17 +24,13 @@ final class MultiTableStore extends DoctrineStore implements StreamableStore, SchemaConfigurator { - private string $metadataTableName; - public function __construct( Connection $connection, EventSerializer $serializer, AggregateRootRegistry $aggregateRootRegistry, - string $metadataTableName = 'eventstore_metadata', + private string $metadataTableName = 'eventstore_metadata', ) { parent::__construct($connection, $serializer, $aggregateRootRegistry); - - $this->metadataTableName = $metadataTableName; } /** @@ -64,7 +60,7 @@ public function load(string $aggregate, string $id, int $fromPlayhead = 0): arra ], [ 'archived' => Types::BOOLEAN, - ] + ], ); $platform = $this->connection->getDatabasePlatform(); @@ -80,13 +76,11 @@ function (array $data) use ($platform, $aggregate): Message { ->withRecordedOn(self::normalizeRecordedOn($data['recorded_on'], $platform)) ->withCustomHeaders(self::normalizeCustomHeaders($data['custom_headers'], $platform)); }, - $result + $result, ); } - /** - * @param class-string $aggregate - */ + /** @param class-string $aggregate */ public function archiveMessages(string $aggregate, string $id, int $untilPlayhead): void { $tableName = $this->aggregateRootRegistry->aggregateName($aggregate); @@ -97,7 +91,7 @@ public function archiveMessages(string $aggregate, string $id, int $untilPlayhea WHERE aggregate_id = :aggregate_id AND playhead < :playhead AND archived = false', - $tableName + $tableName, )); $statement->bindValue('aggregate_id', $id); $statement->bindValue('playhead', $untilPlayhead); @@ -105,9 +99,7 @@ public function archiveMessages(string $aggregate, string $id, int $untilPlayhea $statement->executeQuery(); } - /** - * @param class-string $aggregate - */ + /** @param class-string $aggregate */ public function has(string $aggregate, string $id): bool { $tableName = $this->aggregateRootRegistry->aggregateName($aggregate); @@ -121,7 +113,7 @@ public function has(string $aggregate, string $id): bool $result = $this->connection->fetchOne( $sql, - ['id' => $id] + ['id' => $id], ); if (!is_int($result) && !is_string($result)) { @@ -167,10 +159,10 @@ function (Connection $connection) use ($messages): void { 'custom_headers' => Types::JSON, 'new_stream_start' => Types::BOOLEAN, 'archived' => Types::BOOLEAN, - ] + ], ); } - } + }, ); } @@ -183,9 +175,7 @@ public function stream(int $fromIndex = 0): Generator ->orderBy('id') ->getSQL(); - /** - * @var Traversable $metaQuery - */ + /** @var Traversable $metaQuery */ $metaQuery = $this->connection->iterateAssociative($sql, ['index' => $fromIndex]); $platform = $this->connection->getDatabasePlatform(); @@ -203,9 +193,7 @@ public function stream(int $fromIndex = 0): Generator ->orderBy('id') ->getSQL(); - /** - * @var Traversable $query - */ + /** @var Traversable $query */ $query = $this->connection->iterateAssociative($sql, ['index' => $fromIndex]); if (!$query instanceof Generator) { diff --git a/src/Store/OutboxStore.php b/src/Store/OutboxStore.php index 2379571af..09fc92365 100644 --- a/src/Store/OutboxStore.php +++ b/src/Store/OutboxStore.php @@ -10,10 +10,8 @@ interface OutboxStore extends TransactionStore { public function saveOutboxMessage(Message ...$messages): void; - /** - * @return list - */ - public function retrieveOutboxMessages(?int $limit = null): array; + /** @return list */ + public function retrieveOutboxMessages(int|null $limit = null): array; public function markOutboxMessageConsumed(Message ...$messages): void; diff --git a/src/Store/PipelineStore.php b/src/Store/PipelineStore.php index c2f9c95ea..324de1ae1 100644 --- a/src/Store/PipelineStore.php +++ b/src/Store/PipelineStore.php @@ -10,9 +10,7 @@ /** @deprecated use StreamableStore */ interface PipelineStore extends Store { - /** - * @return Generator - */ + /** @return Generator */ public function stream(int $fromIndex = 0): Generator; public function count(int $fromIndex = 0): int; diff --git a/src/Store/SingleTableStore.php b/src/Store/SingleTableStore.php index a9b8f46e8..a413dea3b 100644 --- a/src/Store/SingleTableStore.php +++ b/src/Store/SingleTableStore.php @@ -22,17 +22,13 @@ final class SingleTableStore extends DoctrineStore implements StreamableStore, SchemaConfigurator { - private string $storeTableName; - public function __construct( Connection $connection, EventSerializer $serializer, AggregateRootRegistry $aggregateRootRegistry, - string $storeTableName = 'eventstore', + private string $storeTableName = 'eventstore', ) { parent::__construct($connection, $serializer, $aggregateRootRegistry); - - $this->storeTableName = $storeTableName; } /** @@ -64,7 +60,7 @@ public function load(string $aggregate, string $id, int $fromPlayhead = 0): arra ], [ 'archived' => Types::BOOLEAN, - ] + ], ); $platform = $this->connection->getDatabasePlatform(); @@ -80,13 +76,11 @@ function (array $data) use ($platform, $aggregate) { ->withRecordedOn(self::normalizeRecordedOn($data['recorded_on'], $platform)) ->withCustomHeaders(self::normalizeCustomHeaders($data['custom_headers'], $platform)); }, - $result + $result, ); } - /** - * @param class-string $aggregate - */ + /** @param class-string $aggregate */ public function archiveMessages(string $aggregate, string $id, int $untilPlayhead): void { $aggregateName = $this->aggregateRootRegistry->aggregateName($aggregate); @@ -98,7 +92,7 @@ public function archiveMessages(string $aggregate, string $id, int $untilPlayhea AND aggregate_id = :aggregate_id AND playhead < :playhead AND archived = false', - $this->storeTableName + $this->storeTableName, )); $statement->bindValue('aggregate', $aggregateName); $statement->bindValue('aggregate_id', $id); @@ -107,9 +101,7 @@ public function archiveMessages(string $aggregate, string $id, int $untilPlayhea $statement->executeQuery(); } - /** - * @param class-string $aggregate - */ + /** @param class-string $aggregate */ public function has(string $aggregate, string $id): bool { $shortName = $this->aggregateRootRegistry->aggregateName($aggregate); @@ -127,7 +119,7 @@ public function has(string $aggregate, string $id): bool [ 'aggregate' => $shortName, 'id' => $id, - ] + ], ); if (!is_int($result) && !is_string($result)) { @@ -162,16 +154,14 @@ function (Connection $connection) use ($messages): void { 'custom_headers' => Types::JSON, 'new_stream_start' => Types::BOOLEAN, 'archived' => Types::BOOLEAN, - ] + ], ); } - } + }, ); } - /** - * @return Generator - */ + /** @return Generator */ public function stream(int $fromIndex = 0): Generator { $sql = $this->connection->createQueryBuilder() diff --git a/src/Store/SplitEventstreamStore.php b/src/Store/SplitEventstreamStore.php index 7ecd66e6d..3ef6f1dd1 100644 --- a/src/Store/SplitEventstreamStore.php +++ b/src/Store/SplitEventstreamStore.php @@ -8,8 +8,6 @@ interface SplitEventstreamStore extends TransactionStore { - /** - * @param class-string $aggregate - */ + /** @param class-string $aggregate */ public function archiveMessages(string $aggregate, string $id, int $untilPlayhead): void; } diff --git a/src/Store/Store.php b/src/Store/Store.php index 1731e7506..cd1607169 100644 --- a/src/Store/Store.php +++ b/src/Store/Store.php @@ -16,9 +16,7 @@ interface Store */ public function load(string $aggregate, string $id, int $fromPlayhead = 0): array; - /** - * @param class-string $aggregate - */ + /** @param class-string $aggregate */ public function has(string $aggregate, string $id): bool; public function save(Message ...$messages): void; diff --git a/src/Store/StreamableStore.php b/src/Store/StreamableStore.php index fa096cb58..2c927f626 100644 --- a/src/Store/StreamableStore.php +++ b/src/Store/StreamableStore.php @@ -9,9 +9,7 @@ interface StreamableStore extends PipelineStore { - /** - * @return Generator - */ + /** @return Generator */ public function stream(int $fromIndex = 0): Generator; public function count(int $fromIndex = 0): int; diff --git a/src/WatchServer/PhpNativeMessageSerializer.php b/src/WatchServer/PhpNativeMessageSerializer.php index e45308413..f15835602 100644 --- a/src/WatchServer/PhpNativeMessageSerializer.php +++ b/src/WatchServer/PhpNativeMessageSerializer.php @@ -14,16 +14,11 @@ use function serialize; use function unserialize; -/** - * @psalm-import-type Headers from Message - */ +/** @psalm-import-type Headers from Message */ final class PhpNativeMessageSerializer implements MessageSerializer { - private EventSerializer $serializer; - - public function __construct(EventSerializer $serializer) + public function __construct(private EventSerializer $serializer) { - $this->serializer = $serializer; } public function serialize(Message $message): string @@ -45,7 +40,7 @@ public function deserialize(string $content): Message /** @var array{event: class-string, payload: string, headers: Headers} $data */ $data = unserialize( base64_decode($content), - ['allowed_classes' => [DateTimeImmutable::class]] + ['allowed_classes' => [DateTimeImmutable::class]], ); return Message::createWithHeaders( diff --git a/src/WatchServer/SocketWatchServer.php b/src/WatchServer/SocketWatchServer.php index 60ef07525..e2cf15d4e 100644 --- a/src/WatchServer/SocketWatchServer.php +++ b/src/WatchServer/SocketWatchServer.php @@ -25,17 +25,15 @@ final class SocketWatchServer implements WatchServer /** @var resource|null */ private $socket; - private MessageSerializer $serializer; private LoggerInterface $logger; - public function __construct(string $host, MessageSerializer $serializer, ?LoggerInterface $logger = null) + public function __construct(string $host, private MessageSerializer $serializer, LoggerInterface|null $logger = null) { if (strpos($host, '://') === false) { $host = 'tcp://' . $host; } $this->host = $host; - $this->serializer = $serializer; $this->logger = $logger ?? new NullLogger(); $this->socket = null; } @@ -73,9 +71,7 @@ public function host(): string return $this->host; } - /** - * @return resource - */ + /** @return resource */ private function socket() { $this->start(); diff --git a/src/WatchServer/SocketWatchServerClient.php b/src/WatchServer/SocketWatchServerClient.php index b1ac56b83..7ec808dff 100644 --- a/src/WatchServer/SocketWatchServerClient.php +++ b/src/WatchServer/SocketWatchServerClient.php @@ -22,22 +22,17 @@ final class SocketWatchServerClient implements WatchServerClient { private string $host; - private MessageSerializer $serializer; - /** @var resource|null */ private $socket; - /** - * @param string $host The server host - */ - public function __construct(string $host, MessageSerializer $serializer) + /** @param string $host The server host */ + public function __construct(string $host, private MessageSerializer $serializer) { if (strpos($host, '://') === false) { $host = 'tcp://' . $host; } $this->host = $host; - $this->serializer = $serializer; $this->socket = null; } @@ -75,9 +70,7 @@ public function send(Message $message): void throw new SendingFailed('unknown error'); } - /** - * @return resource|null - */ + /** @return resource|null */ private function createSocket() { if ($this->socket) { @@ -92,7 +85,7 @@ private function createSocket() $errno, $errstr, 3, - STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT + STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT, ); if (!$socket) { diff --git a/src/WatchServer/WatchListener.php b/src/WatchServer/WatchListener.php index 9c7972e0c..08cb3d795 100644 --- a/src/WatchServer/WatchListener.php +++ b/src/WatchServer/WatchListener.php @@ -9,18 +9,15 @@ final class WatchListener implements Listener { - private WatchServerClient $client; - - public function __construct(WatchServerClient $client) + public function __construct(private WatchServerClient $client) { - $this->client = $client; } public function __invoke(Message $message): void { try { $this->client->send($message); - } catch (SendingFailed $exception) { + } catch (SendingFailed) { // to nothing } } diff --git a/src/WatchServer/WatchServer.php b/src/WatchServer/WatchServer.php index 88aee54f2..890c2f896 100644 --- a/src/WatchServer/WatchServer.php +++ b/src/WatchServer/WatchServer.php @@ -11,9 +11,7 @@ interface WatchServer { public function start(): void; - /** - * @param Closure(Message, int):void $callback - */ + /** @param Closure(Message, int):void $callback */ public function listen(Closure $callback): void; public function host(): string; diff --git a/tests/Benchmark/BasicImplementation/Events/NameChanged.php b/tests/Benchmark/BasicImplementation/Events/NameChanged.php index d05650c6a..7a63430b7 100644 --- a/tests/Benchmark/BasicImplementation/Events/NameChanged.php +++ b/tests/Benchmark/BasicImplementation/Events/NameChanged.php @@ -10,7 +10,7 @@ final class NameChanged { public function __construct( - public string $name + public string $name, ) { } } diff --git a/tests/Benchmark/BasicImplementation/Events/ProfileCreated.php b/tests/Benchmark/BasicImplementation/Events/ProfileCreated.php index 18f3c9199..c2be67f57 100644 --- a/tests/Benchmark/BasicImplementation/Events/ProfileCreated.php +++ b/tests/Benchmark/BasicImplementation/Events/ProfileCreated.php @@ -14,7 +14,7 @@ final class ProfileCreated public function __construct( #[ProfileIdNormalizer] public ProfileId $profileId, - public string $name + public string $name, ) { } } diff --git a/tests/Benchmark/BasicImplementation/Normalizer/ProfileIdNormalizer.php b/tests/Benchmark/BasicImplementation/Normalizer/ProfileIdNormalizer.php index 320d49d3f..f4bd3f2a6 100644 --- a/tests/Benchmark/BasicImplementation/Normalizer/ProfileIdNormalizer.php +++ b/tests/Benchmark/BasicImplementation/Normalizer/ProfileIdNormalizer.php @@ -23,7 +23,7 @@ public function normalize(mixed $value): string return $value->toString(); } - public function denormalize(mixed $value): ?ProfileId + public function denormalize(mixed $value): ProfileId|null { if ($value === null) { return null; diff --git a/tests/Benchmark/BasicImplementation/ProfileId.php b/tests/Benchmark/BasicImplementation/ProfileId.php index bc303aa7a..be8799e1c 100644 --- a/tests/Benchmark/BasicImplementation/ProfileId.php +++ b/tests/Benchmark/BasicImplementation/ProfileId.php @@ -6,11 +6,8 @@ final class ProfileId { - private string $id; - - private function __construct(string $id) + private function __construct(private string $id) { - $this->id = $id; } public static function fromString(string $id): self diff --git a/tests/Benchmark/BasicImplementation/Projection/ProfileProjector.php b/tests/Benchmark/BasicImplementation/Projection/ProfileProjector.php index 009be1c3a..54b213889 100644 --- a/tests/Benchmark/BasicImplementation/Projection/ProfileProjector.php +++ b/tests/Benchmark/BasicImplementation/Projection/ProfileProjector.php @@ -16,11 +16,8 @@ final class ProfileProjector implements Projector { - private Connection $connection; - - public function __construct(Connection $connection) + public function __construct(private Connection $connection) { - $this->connection = $connection; } #[Create] @@ -47,7 +44,7 @@ public function handleProfileCreated(Message $message): void [ 'id' => $profileCreated->profileId->toString(), 'name' => $profileCreated->name, - ] + ], ); } } diff --git a/tests/Benchmark/LoadEventsBench.php b/tests/Benchmark/LoadEventsBench.php index 04f8ac359..5d8b74b31 100644 --- a/tests/Benchmark/LoadEventsBench.php +++ b/tests/Benchmark/LoadEventsBench.php @@ -48,14 +48,14 @@ public function setUp(): void $connection, DefaultEventSerializer::createFromPaths([__DIR__ . '/BasicImplementation/Events']), (new AttributeAggregateRootRegistryFactory())->create([__DIR__ . '/BasicImplementation/Aggregate']), - 'eventstore' + 'eventstore', ); $this->repository = new DefaultRepository($this->store, $this->bus, Profile::class); $schemaDirector = new DoctrineSchemaDirector( $connection, - $this->store + $this->store, ); $schemaDirector->create(); diff --git a/tests/Benchmark/LoadEventsWithSnapshotsBench.php b/tests/Benchmark/LoadEventsWithSnapshotsBench.php index 04cc69573..451a90896 100644 --- a/tests/Benchmark/LoadEventsWithSnapshotsBench.php +++ b/tests/Benchmark/LoadEventsWithSnapshotsBench.php @@ -52,7 +52,7 @@ public function setUp(): void $connection, DefaultEventSerializer::createFromPaths([__DIR__ . '/BasicImplementation/Events']), (new AttributeAggregateRootRegistryFactory())->create([__DIR__ . '/BasicImplementation/Aggregate']), - 'eventstore' + 'eventstore', ); $this->snapshotStore = new DefaultSnapshotStore(['default' => new InMemorySnapshotAdapter()]); @@ -61,7 +61,7 @@ public function setUp(): void $schemaDirector = new DoctrineSchemaDirector( $connection, - $this->store + $this->store, ); $schemaDirector->create(); diff --git a/tests/Benchmark/WriteEventsBench.php b/tests/Benchmark/WriteEventsBench.php index 536e648bd..01c59d6c6 100644 --- a/tests/Benchmark/WriteEventsBench.php +++ b/tests/Benchmark/WriteEventsBench.php @@ -49,7 +49,7 @@ public function setUp(): void $profileProjection = new ProfileProjector($connection); $projectionRepository = new MetadataAwareProjectionHandler( - [$profileProjection] + [$profileProjection], ); $this->bus = new DefaultEventBus(); @@ -60,14 +60,14 @@ public function setUp(): void $connection, DefaultEventSerializer::createFromPaths([__DIR__ . '/BasicImplementation/Events']), (new AttributeAggregateRootRegistryFactory())->create([__DIR__ . '/BasicImplementation/Aggregate']), - 'eventstore' + 'eventstore', ); $this->repository = new DefaultRepository($this->store, $this->bus, Profile::class); $schemaDirector = new DoctrineSchemaDirector( $connection, - $this->store + $this->store, ); $schemaDirector->create(); diff --git a/tests/Integration/BankAccountSplitStream/AccountId.php b/tests/Integration/BankAccountSplitStream/AccountId.php index 5c451e32e..4351edff2 100644 --- a/tests/Integration/BankAccountSplitStream/AccountId.php +++ b/tests/Integration/BankAccountSplitStream/AccountId.php @@ -6,11 +6,8 @@ final class AccountId { - private string $id; - - private function __construct(string $id) + private function __construct(private string $id) { - $this->id = $id; } public static function fromString(string $id): self diff --git a/tests/Integration/BankAccountSplitStream/Aggregate/BankAccount.php b/tests/Integration/BankAccountSplitStream/Aggregate/BankAccount.php index 69d93b25b..07b59ed42 100644 --- a/tests/Integration/BankAccountSplitStream/Aggregate/BankAccount.php +++ b/tests/Integration/BankAccountSplitStream/Aggregate/BankAccount.php @@ -36,9 +36,7 @@ public static function create(AccountId $id, string $name): self return $self; } - /** - * @param positive-int $newAddedBalance - */ + /** @param positive-int $newAddedBalance */ public function addBalance(int $newAddedBalance): void { $this->recordThat(new BalanceAdded($this->id, $newAddedBalance)); diff --git a/tests/Integration/BankAccountSplitStream/IntegrationTest.php b/tests/Integration/BankAccountSplitStream/IntegrationTest.php index b524d6cf8..a70a685ec 100644 --- a/tests/Integration/BankAccountSplitStream/IntegrationTest.php +++ b/tests/Integration/BankAccountSplitStream/IntegrationTest.php @@ -30,9 +30,7 @@ use function count; -/** - * @coversNothing - */ +/** @coversNothing */ final class IntegrationTest extends TestCase { private Connection $connection; @@ -59,7 +57,7 @@ public function testSingleTableSuccessful(): void $this->connection, DefaultEventSerializer::createFromPaths([__DIR__ . '/Events']), (new AttributeAggregateRootRegistryFactory())->create([__DIR__ . '/Aggregate']), - 'eventstore' + 'eventstore', ); $manager = new DefaultRepositoryManager( @@ -70,13 +68,13 @@ public function testSingleTableSuccessful(): void new ChainMessageDecorator([ new RecordedOnDecorator(new SystemClock()), new SplitStreamDecorator(new AttributeEventMetadataFactory()), - ]) + ]), ); $repository = $manager->get(BankAccount::class); $schemaDirector = new DoctrineSchemaDirector( $this->connection, - $store + $store, ); $schemaDirector->create(); @@ -103,7 +101,7 @@ public function testSingleTableSuccessful(): void new ChainMessageDecorator([ new RecordedOnDecorator(new SystemClock()), new SplitStreamDecorator(new AttributeEventMetadataFactory()), - ]) + ]), ); $repository = $manager->get(BankAccount::class); $bankAccount = $repository->load('1'); @@ -138,7 +136,7 @@ public function testSingleTableSuccessful(): void new ChainMessageDecorator([ new RecordedOnDecorator(new SystemClock()), new SplitStreamDecorator(new AttributeEventMetadataFactory()), - ]) + ]), ); $repository = $manager->get(BankAccount::class); $bankAccount = $repository->load('1'); @@ -175,13 +173,13 @@ public function testMultiTableSuccessful(): void new ChainMessageDecorator([ new RecordedOnDecorator(new SystemClock()), new SplitStreamDecorator(new AttributeEventMetadataFactory()), - ]) + ]), ); $repository = $manager->get(BankAccount::class); $schemaDirector = new DoctrineSchemaDirector( $this->connection, - $store + $store, ); $schemaDirector->create(); @@ -208,7 +206,7 @@ public function testMultiTableSuccessful(): void new ChainMessageDecorator([ new RecordedOnDecorator(new SystemClock()), new SplitStreamDecorator(new AttributeEventMetadataFactory()), - ]) + ]), ); $repository = $manager->get(BankAccount::class); $bankAccount = $repository->load('1'); @@ -243,7 +241,7 @@ public function testMultiTableSuccessful(): void new ChainMessageDecorator([ new RecordedOnDecorator(new SystemClock()), new SplitStreamDecorator(new AttributeEventMetadataFactory()), - ]) + ]), ); $repository = $manager->get(BankAccount::class); $bankAccount = $repository->load('1'); diff --git a/tests/Integration/BankAccountSplitStream/Normalizer/AccountIdNormalizer.php b/tests/Integration/BankAccountSplitStream/Normalizer/AccountIdNormalizer.php index 33a2586bf..d153dec32 100644 --- a/tests/Integration/BankAccountSplitStream/Normalizer/AccountIdNormalizer.php +++ b/tests/Integration/BankAccountSplitStream/Normalizer/AccountIdNormalizer.php @@ -23,7 +23,7 @@ public function normalize(mixed $value): string return $value->toString(); } - public function denormalize(mixed $value): ?AccountId + public function denormalize(mixed $value): AccountId|null { if ($value === null) { return null; diff --git a/tests/Integration/BankAccountSplitStream/Projection/BankAccountProjection.php b/tests/Integration/BankAccountSplitStream/Projection/BankAccountProjection.php index 186d5830c..bee6b7694 100644 --- a/tests/Integration/BankAccountSplitStream/Projection/BankAccountProjection.php +++ b/tests/Integration/BankAccountSplitStream/Projection/BankAccountProjection.php @@ -16,11 +16,8 @@ final class BankAccountProjection implements Projector { - private Connection $connection; - - public function __construct(Connection $connection) + public function __construct(private Connection $connection) { - $this->connection = $connection; } #[Create] @@ -51,7 +48,7 @@ public function handleBankAccountCreated(Message $message): void [ 'id' => $event->accountId->toString(), 'name' => $event->name, - ] + ], ); } @@ -65,7 +62,7 @@ public function handleBalanceAdded(Message $message): void [ 'id' => $event->accountId->toString(), 'balance' => $event->balanceInCents, - ] + ], ); } } diff --git a/tests/Integration/BasicImplementation/BasicIntegrationTest.php b/tests/Integration/BasicImplementation/BasicIntegrationTest.php index cafbb77c1..46434e410 100644 --- a/tests/Integration/BasicImplementation/BasicIntegrationTest.php +++ b/tests/Integration/BasicImplementation/BasicIntegrationTest.php @@ -28,9 +28,7 @@ use Patchlevel\EventSourcing\Tests\Integration\DbalManager; use PHPUnit\Framework\TestCase; -/** - * @coversNothing - */ +/** @coversNothing */ final class BasicIntegrationTest extends TestCase { private Connection $connection; @@ -50,7 +48,7 @@ public function testSuccessful(): void { $profileProjection = new ProfileProjection($this->connection); $projectorRepository = new InMemoryProjectorRepository( - [$profileProjection] + [$profileProjection], ); $eventStream = new DefaultEventBus(); @@ -61,7 +59,7 @@ public function testSuccessful(): void $this->connection, DefaultEventSerializer::createFromPaths([__DIR__ . '/Events']), (new AttributeAggregateRootRegistryFactory())->create([__DIR__ . '/Aggregate']), - 'eventstore' + 'eventstore', ); $manager = new DefaultRepositoryManager( @@ -69,13 +67,13 @@ public function testSuccessful(): void $store, $eventStream, null, - new ChainMessageDecorator([new RecordedOnDecorator(new SystemClock()), new FooMessageDecorator()]) + new ChainMessageDecorator([new RecordedOnDecorator(new SystemClock()), new FooMessageDecorator()]), ); $repository = $manager->get(Profile::class); $schemaDirector = new DoctrineSchemaDirector( $this->connection, - $store + $store, ); $schemaDirector->create(); @@ -96,7 +94,7 @@ public function testSuccessful(): void $store, $eventStream, null, - new ChainMessageDecorator([new RecordedOnDecorator(new SystemClock())]) + new ChainMessageDecorator([new RecordedOnDecorator(new SystemClock())]), ); $repository = $manager->get(Profile::class); $profile = $repository->load('1'); @@ -112,7 +110,7 @@ public function testWithSymfonySuccessful(): void { $profileProjection = new ProfileProjection($this->connection); $projectorRepository = new InMemoryProjectorRepository( - [$profileProjection] + [$profileProjection], ); $eventStream = SymfonyEventBus::create([ @@ -124,7 +122,7 @@ public function testWithSymfonySuccessful(): void $this->connection, DefaultEventSerializer::createFromPaths([__DIR__ . '/Events']), (new AttributeAggregateRootRegistryFactory())->create([__DIR__ . '/Aggregate']), - 'eventstore' + 'eventstore', ); $manager = new DefaultRepositoryManager( @@ -132,13 +130,13 @@ public function testWithSymfonySuccessful(): void $store, $eventStream, null, - new ChainMessageDecorator([new RecordedOnDecorator(new SystemClock())]) + new ChainMessageDecorator([new RecordedOnDecorator(new SystemClock())]), ); $repository = $manager->get(Profile::class); $schemaDirector = new DoctrineSchemaDirector( $this->connection, - $store + $store, ); $schemaDirector->create(); @@ -159,7 +157,7 @@ public function testWithSymfonySuccessful(): void $store, $eventStream, null, - new ChainMessageDecorator([new RecordedOnDecorator(new SystemClock()), new FooMessageDecorator()]) + new ChainMessageDecorator([new RecordedOnDecorator(new SystemClock()), new FooMessageDecorator()]), ); $repository = $manager->get(Profile::class); @@ -176,7 +174,7 @@ public function testMultiTableSuccessful(): void { $profileProjection = new ProfileProjection($this->connection); $projectorRepository = new InMemoryProjectorRepository( - [$profileProjection] + [$profileProjection], ); $eventStream = new DefaultEventBus(); @@ -194,13 +192,13 @@ public function testMultiTableSuccessful(): void $store, $eventStream, null, - new ChainMessageDecorator([new RecordedOnDecorator(new SystemClock()), new FooMessageDecorator()]) + new ChainMessageDecorator([new RecordedOnDecorator(new SystemClock()), new FooMessageDecorator()]), ); $repository = $manager->get(Profile::class); $schemaDirector = new DoctrineSchemaDirector( $this->connection, - $store + $store, ); $schemaDirector->create(); @@ -221,7 +219,7 @@ public function testMultiTableSuccessful(): void $store, $eventStream, null, - new ChainMessageDecorator([new RecordedOnDecorator(new SystemClock())]) + new ChainMessageDecorator([new RecordedOnDecorator(new SystemClock())]), ); $repository = $manager->get(Profile::class); $profile = $repository->load('1'); @@ -237,7 +235,7 @@ public function testSnapshot(): void { $profileProjection = new ProfileProjection($this->connection); $projectorRepository = new InMemoryProjectorRepository( - [$profileProjection] + [$profileProjection], ); $eventStream = new DefaultEventBus(); @@ -248,7 +246,7 @@ public function testSnapshot(): void $this->connection, DefaultEventSerializer::createFromPaths([__DIR__ . '/Events']), (new AttributeAggregateRootRegistryFactory())->create([__DIR__ . '/Aggregate']), - 'eventstore' + 'eventstore', ); $manager = new DefaultRepositoryManager( @@ -256,13 +254,13 @@ public function testSnapshot(): void $store, $eventStream, new DefaultSnapshotStore(['default' => new InMemorySnapshotAdapter()]), - new ChainMessageDecorator([new RecordedOnDecorator(new SystemClock()), new FooMessageDecorator()]) + new ChainMessageDecorator([new RecordedOnDecorator(new SystemClock()), new FooMessageDecorator()]), ); $repository = $manager->get(Profile::class); $schemaDirector = new DoctrineSchemaDirector( $this->connection, - $store + $store, ); $schemaDirector->create(); @@ -283,7 +281,7 @@ public function testSnapshot(): void $store, $eventStream, null, - new ChainMessageDecorator([new RecordedOnDecorator(new SystemClock())]) + new ChainMessageDecorator([new RecordedOnDecorator(new SystemClock())]), ); $repository = $manager->get(Profile::class); $profile = $repository->load('1'); diff --git a/tests/Integration/BasicImplementation/Events/ProfileCreated.php b/tests/Integration/BasicImplementation/Events/ProfileCreated.php index e1ae4382a..6def21561 100644 --- a/tests/Integration/BasicImplementation/Events/ProfileCreated.php +++ b/tests/Integration/BasicImplementation/Events/ProfileCreated.php @@ -14,7 +14,7 @@ final class ProfileCreated public function __construct( #[ProfileIdNormalizer] public ProfileId $profileId, - public string $name + public string $name, ) { } } diff --git a/tests/Integration/BasicImplementation/Normalizer/ProfileIdNormalizer.php b/tests/Integration/BasicImplementation/Normalizer/ProfileIdNormalizer.php index d277e6439..d248321a5 100644 --- a/tests/Integration/BasicImplementation/Normalizer/ProfileIdNormalizer.php +++ b/tests/Integration/BasicImplementation/Normalizer/ProfileIdNormalizer.php @@ -23,7 +23,7 @@ public function normalize(mixed $value): string return $value->toString(); } - public function denormalize(mixed $value): ?ProfileId + public function denormalize(mixed $value): ProfileId|null { if ($value === null) { return null; diff --git a/tests/Integration/BasicImplementation/ProfileId.php b/tests/Integration/BasicImplementation/ProfileId.php index 672902377..eb627f8a8 100644 --- a/tests/Integration/BasicImplementation/ProfileId.php +++ b/tests/Integration/BasicImplementation/ProfileId.php @@ -6,11 +6,8 @@ final class ProfileId { - private string $id; - - private function __construct(string $id) + private function __construct(private string $id) { - $this->id = $id; } public static function fromString(string $id): self diff --git a/tests/Integration/BasicImplementation/Projection/ProfileProjection.php b/tests/Integration/BasicImplementation/Projection/ProfileProjection.php index f16965202..603646c49 100644 --- a/tests/Integration/BasicImplementation/Projection/ProfileProjection.php +++ b/tests/Integration/BasicImplementation/Projection/ProfileProjection.php @@ -17,11 +17,8 @@ final class ProfileProjection implements Projector { - private Connection $connection; - - public function __construct(Connection $connection) + public function __construct(private Connection $connection) { - $this->connection = $connection; } #[Create] @@ -53,7 +50,7 @@ public function handleProfileCreated(Message $message): void [ 'id' => $profileCreated->profileId->toString(), 'name' => $profileCreated->name, - ] + ], ); } } diff --git a/tests/Integration/Outbox/Events/ProfileCreated.php b/tests/Integration/Outbox/Events/ProfileCreated.php index bbafee4b5..27cf670b1 100644 --- a/tests/Integration/Outbox/Events/ProfileCreated.php +++ b/tests/Integration/Outbox/Events/ProfileCreated.php @@ -14,7 +14,7 @@ final class ProfileCreated public function __construct( #[ProfileIdNormalizer] public ProfileId $profileId, - public string $name + public string $name, ) { } } diff --git a/tests/Integration/Outbox/Normalizer/ProfileIdNormalizer.php b/tests/Integration/Outbox/Normalizer/ProfileIdNormalizer.php index 50212608b..2146f93a4 100644 --- a/tests/Integration/Outbox/Normalizer/ProfileIdNormalizer.php +++ b/tests/Integration/Outbox/Normalizer/ProfileIdNormalizer.php @@ -23,7 +23,7 @@ public function normalize(mixed $value): string return $value->toString(); } - public function denormalize(mixed $value): ?ProfileId + public function denormalize(mixed $value): ProfileId|null { if ($value === null) { return null; diff --git a/tests/Integration/Outbox/OutboxTest.php b/tests/Integration/Outbox/OutboxTest.php index 91665ad0d..e14ed0905 100644 --- a/tests/Integration/Outbox/OutboxTest.php +++ b/tests/Integration/Outbox/OutboxTest.php @@ -22,9 +22,7 @@ use Patchlevel\EventSourcing\Tests\Integration\Outbox\Projection\ProfileProjection; use PHPUnit\Framework\TestCase; -/** - * @coversNothing - */ +/** @coversNothing */ final class OutboxTest extends TestCase { private Connection $connection; @@ -44,14 +42,14 @@ public function testSuccessful(): void { $profileProjection = new ProfileProjection($this->connection); $projectionRepository = new MetadataAwareProjectionHandler( - [$profileProjection] + [$profileProjection], ); $store = new SingleTableStore( $this->connection, DefaultEventSerializer::createFromPaths([__DIR__ . '/Events']), (new AttributeAggregateRootRegistryFactory())->create([__DIR__ . '/Aggregate']), - 'eventstore' + 'eventstore', ); $realEventBus = new DefaultEventBus(); @@ -63,7 +61,7 @@ public function testSuccessful(): void $schemaDirector = new DoctrineSchemaDirector( $this->connection, - $store + $store, ); $schemaDirector->create(); @@ -85,7 +83,7 @@ public function testSuccessful(): void self::assertSame(1, $message->playhead()); self::assertEquals( new ProfileCreated(ProfileId::fromString('1'), 'John'), - $message->event() + $message->event(), ); $consumer = new StoreOutboxConsumer($store, $realEventBus); diff --git a/tests/Integration/Outbox/ProfileId.php b/tests/Integration/Outbox/ProfileId.php index fc2221191..c820b2f29 100644 --- a/tests/Integration/Outbox/ProfileId.php +++ b/tests/Integration/Outbox/ProfileId.php @@ -6,11 +6,8 @@ final class ProfileId { - private string $id; - - private function __construct(string $id) + private function __construct(private string $id) { - $this->id = $id; } public static function fromString(string $id): self diff --git a/tests/Integration/Outbox/Projection/ProfileProjection.php b/tests/Integration/Outbox/Projection/ProfileProjection.php index 7d89e6167..7e85afab0 100644 --- a/tests/Integration/Outbox/Projection/ProfileProjection.php +++ b/tests/Integration/Outbox/Projection/ProfileProjection.php @@ -15,11 +15,8 @@ final class ProfileProjection implements Projector { - private Connection $connection; - - public function __construct(Connection $connection) + public function __construct(private Connection $connection) { - $this->connection = $connection; } #[Create] @@ -49,7 +46,7 @@ public function handleProfileCreated(Message $message): void [ 'id' => $profileCreated->profileId->toString(), 'name' => $profileCreated->name, - ] + ], ); } } diff --git a/tests/Integration/Pipeline/EventNormalizer/ProfileIdNormalizer.php b/tests/Integration/Pipeline/EventNormalizer/ProfileIdNormalizer.php index 1bc550bc0..5e09f2046 100644 --- a/tests/Integration/Pipeline/EventNormalizer/ProfileIdNormalizer.php +++ b/tests/Integration/Pipeline/EventNormalizer/ProfileIdNormalizer.php @@ -23,7 +23,7 @@ public function normalize(mixed $value): string return $value->toString(); } - public function denormalize(mixed $value): ?ProfileId + public function denormalize(mixed $value): ProfileId|null { if ($value === null) { return null; diff --git a/tests/Integration/Pipeline/Events/NewVisited.php b/tests/Integration/Pipeline/Events/NewVisited.php index 38afc557c..0a4c4faad 100644 --- a/tests/Integration/Pipeline/Events/NewVisited.php +++ b/tests/Integration/Pipeline/Events/NewVisited.php @@ -13,7 +13,7 @@ final class NewVisited { public function __construct( #[ProfileIdNormalizer] - public ProfileId $profileId + public ProfileId $profileId, ) { } } diff --git a/tests/Integration/Pipeline/Events/OldVisited.php b/tests/Integration/Pipeline/Events/OldVisited.php index 51221a80d..669577f35 100644 --- a/tests/Integration/Pipeline/Events/OldVisited.php +++ b/tests/Integration/Pipeline/Events/OldVisited.php @@ -13,7 +13,7 @@ final class OldVisited { public function __construct( #[ProfileIdNormalizer] - public ProfileId $profileId + public ProfileId $profileId, ) { } } diff --git a/tests/Integration/Pipeline/Events/PrivacyAdded.php b/tests/Integration/Pipeline/Events/PrivacyAdded.php index d3a9bbf44..a753c1784 100644 --- a/tests/Integration/Pipeline/Events/PrivacyAdded.php +++ b/tests/Integration/Pipeline/Events/PrivacyAdded.php @@ -13,7 +13,7 @@ final class PrivacyAdded { public function __construct( #[ProfileIdNormalizer] - public ProfileId $profileId + public ProfileId $profileId, ) { } } diff --git a/tests/Integration/Pipeline/Events/ProfileCreated.php b/tests/Integration/Pipeline/Events/ProfileCreated.php index 6f578bfca..d635ed450 100644 --- a/tests/Integration/Pipeline/Events/ProfileCreated.php +++ b/tests/Integration/Pipeline/Events/ProfileCreated.php @@ -13,7 +13,7 @@ final class ProfileCreated { public function __construct( #[ProfileIdNormalizer] - public ProfileId $profileId + public ProfileId $profileId, ) { } } diff --git a/tests/Integration/Pipeline/PipelineChangeStoreTest.php b/tests/Integration/Pipeline/PipelineChangeStoreTest.php index e138568e7..cca58f05b 100644 --- a/tests/Integration/Pipeline/PipelineChangeStoreTest.php +++ b/tests/Integration/Pipeline/PipelineChangeStoreTest.php @@ -25,9 +25,7 @@ use Patchlevel\EventSourcing\Tests\Integration\Pipeline\Events\PrivacyAdded; use PHPUnit\Framework\TestCase; -/** - * @coversNothing - */ +/** @coversNothing */ final class PipelineChangeStoreTest extends TestCase { private Connection $connectionOld; @@ -54,12 +52,12 @@ public function testSuccessful(): void $this->connectionOld, $serializer, $aggregateRootRegistry, - 'eventstore' + 'eventstore', ); $oldSchemaDirector = new DoctrineSchemaDirector( $this->connectionOld, - $oldStore + $oldStore, ); $oldSchemaDirector->create(); @@ -68,12 +66,12 @@ public function testSuccessful(): void $this->connectionNew, $serializer, $aggregateRootRegistry, - 'eventstore' + 'eventstore', ); $newSchemaDirector = new DoctrineSchemaDirector( $this->connectionNew, - $newStore + $newStore, ); $newSchemaDirector->create(); @@ -103,7 +101,7 @@ public function testSuccessful(): void return new NewVisited($oldVisited->profileId); }), new RecalculatePlayheadMiddleware(), - ] + ], ); self::assertSame(4, $pipeline->count()); diff --git a/tests/Integration/Pipeline/ProfileId.php b/tests/Integration/Pipeline/ProfileId.php index 06aa13271..cfa178d16 100644 --- a/tests/Integration/Pipeline/ProfileId.php +++ b/tests/Integration/Pipeline/ProfileId.php @@ -6,11 +6,8 @@ final class ProfileId { - private string $id; - - private function __construct(string $id) + private function __construct(private string $id) { - $this->id = $id; } public static function fromString(string $id): self diff --git a/tests/Integration/Projectionist/Events/ProfileCreated.php b/tests/Integration/Projectionist/Events/ProfileCreated.php index 7ecc27c4b..7626f32ed 100644 --- a/tests/Integration/Projectionist/Events/ProfileCreated.php +++ b/tests/Integration/Projectionist/Events/ProfileCreated.php @@ -14,7 +14,7 @@ final class ProfileCreated public function __construct( #[ProfileIdNormalizer] public ProfileId $profileId, - public string $name + public string $name, ) { } } diff --git a/tests/Integration/Projectionist/Normalizer/ProfileIdNormalizer.php b/tests/Integration/Projectionist/Normalizer/ProfileIdNormalizer.php index 29699e67e..0d7fb7311 100644 --- a/tests/Integration/Projectionist/Normalizer/ProfileIdNormalizer.php +++ b/tests/Integration/Projectionist/Normalizer/ProfileIdNormalizer.php @@ -23,7 +23,7 @@ public function normalize(mixed $value): string return $value->toString(); } - public function denormalize(mixed $value): ?ProfileId + public function denormalize(mixed $value): ProfileId|null { if ($value === null) { return null; diff --git a/tests/Integration/Projectionist/ProfileId.php b/tests/Integration/Projectionist/ProfileId.php index 65c33fd27..23841ea59 100644 --- a/tests/Integration/Projectionist/ProfileId.php +++ b/tests/Integration/Projectionist/ProfileId.php @@ -6,11 +6,8 @@ final class ProfileId { - private string $id; - - private function __construct(string $id) + private function __construct(private string $id) { - $this->id = $id; } public static function fromString(string $id): self diff --git a/tests/Integration/Projectionist/Projection/ProfileProjection.php b/tests/Integration/Projectionist/Projection/ProfileProjection.php index 6cd6adae6..ba386e251 100644 --- a/tests/Integration/Projectionist/Projection/ProfileProjection.php +++ b/tests/Integration/Projectionist/Projection/ProfileProjection.php @@ -19,11 +19,8 @@ final class ProfileProjection implements VersionedProjector { - private Connection $connection; - - public function __construct(Connection $connection) + public function __construct(private Connection $connection) { - $this->connection = $connection; } #[Create] @@ -55,7 +52,7 @@ public function handleProfileCreated(Message $message): void [ 'id' => $profileCreated->profileId->toString(), 'name' => $profileCreated->name, - ] + ], ); } @@ -64,7 +61,7 @@ private function tableName(): string return sprintf( 'projection_%s_%s', $this->targetProjection()->name(), - $this->targetProjection()->version() + $this->targetProjection()->version(), ); } diff --git a/tests/Integration/Projectionist/ProjectionistTest.php b/tests/Integration/Projectionist/ProjectionistTest.php index 503cfdf21..51fceb89f 100644 --- a/tests/Integration/Projectionist/ProjectionistTest.php +++ b/tests/Integration/Projectionist/ProjectionistTest.php @@ -25,9 +25,7 @@ use Symfony\Component\Lock\LockFactory; use Symfony\Component\Lock\Store\DoctrineDbalStore; -/** - * @coversNothing - */ +/** @coversNothing */ final class ProjectionistTest extends TestCase { private Connection $connection; @@ -48,7 +46,7 @@ public function testAsync(): void $this->connection, DefaultEventSerializer::createFromPaths([__DIR__ . '/Events']), (new AttributeAggregateRootRegistryFactory())->create([__DIR__ . '/Aggregate']), - 'eventstore' + 'eventstore', ); $projectionStore = new DoctrineStore($this->connection); @@ -66,7 +64,7 @@ public function testAsync(): void new ChainSchemaConfigurator([ $store, $projectionStore, - ]) + ]), ); $schemaDirector->create(); @@ -78,7 +76,7 @@ public function testAsync(): void $store, $projectionStore, new InMemoryProjectorRepository( - [new ProfileProjection($this->connection)] + [new ProfileProjection($this->connection)], ), ); @@ -103,7 +101,7 @@ public function testSync(): void $this->connection, DefaultEventSerializer::createFromPaths([__DIR__ . '/Events']), $aggregateRegistry, - 'eventstore' + 'eventstore', ); $lockStore = new DoctrineDbalStore($this->connection); @@ -113,7 +111,7 @@ public function testSync(): void $store, $projectionStore, new InMemoryProjectorRepository( - [new ProfileProjection($this->connection)] + [new ProfileProjection($this->connection)], ), ); @@ -123,7 +121,7 @@ public function testSync(): void new RunProjectionistEventBusWrapper( new DefaultEventBus(), $projectionist, - new LockFactory($lockStore) + new LockFactory($lockStore), ), ); @@ -135,7 +133,7 @@ public function testSync(): void $store, $projectionStore, new DoctrineDbalStoreSchemaAdapter($lockStore), - ]) + ]), ); $schemaDirector->drop(); diff --git a/tests/Unit/Aggregate/AggregateRootTest.php b/tests/Unit/Aggregate/AggregateRootTest.php index 683542c6a..569c3b837 100644 --- a/tests/Unit/Aggregate/AggregateRootTest.php +++ b/tests/Unit/Aggregate/AggregateRootTest.php @@ -104,8 +104,8 @@ public function testEventWithoutApplyMethod(): void $profile->publishMessage( Message::create( $messageId, - 'foo' - ) + 'foo', + ), ); } diff --git a/tests/Unit/Aggregate/ApplyMethodNotFoundTest.php b/tests/Unit/Aggregate/ApplyMethodNotFoundTest.php index 7521eae87..71a53f4aa 100644 --- a/tests/Unit/Aggregate/ApplyMethodNotFoundTest.php +++ b/tests/Unit/Aggregate/ApplyMethodNotFoundTest.php @@ -17,7 +17,7 @@ public function testCreate(): void self::assertSame( 'Apply method in "Patchlevel\EventSourcing\Tests\Unit\Fixture\Profile" could not be found for the event "Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileCreated"', - $exception->getMessage() + $exception->getMessage(), ); } } diff --git a/tests/Unit/Console/Command/DatabaseCreateCommandTest.php b/tests/Unit/Console/Command/DatabaseCreateCommandTest.php index 6364601b5..276ec9fcd 100644 --- a/tests/Unit/Console/Command/DatabaseCreateCommandTest.php +++ b/tests/Unit/Console/Command/DatabaseCreateCommandTest.php @@ -27,7 +27,7 @@ public function testStoreNotSupported(): void $command = new DatabaseCreateCommand( $store->reveal(), - $helper->reveal() + $helper->reveal(), ); $input = new ArrayInput([]); @@ -57,7 +57,7 @@ public function testSuccessful(): void $command = new DatabaseCreateCommand( $store->reveal(), - $helper->reveal() + $helper->reveal(), ); $input = new ArrayInput([]); @@ -86,7 +86,7 @@ public function testSkip(): void $command = new DatabaseCreateCommand( $store->reveal(), - $helper->reveal() + $helper->reveal(), ); $input = new ArrayInput(['--if-not-exists' => true]); @@ -116,7 +116,7 @@ public function testError(): void $command = new DatabaseCreateCommand( $store->reveal(), - $helper->reveal() + $helper->reveal(), ); $input = new ArrayInput([]); diff --git a/tests/Unit/Console/Command/DatabaseDropCommandTest.php b/tests/Unit/Console/Command/DatabaseDropCommandTest.php index f761e31d7..3d030f9a9 100644 --- a/tests/Unit/Console/Command/DatabaseDropCommandTest.php +++ b/tests/Unit/Console/Command/DatabaseDropCommandTest.php @@ -27,7 +27,7 @@ public function testStoreNotSupported(): void $command = new DatabaseDropCommand( $store->reveal(), - $helper->reveal() + $helper->reveal(), ); $input = new ArrayInput([]); @@ -55,7 +55,7 @@ public function testMissingForce(): void $command = new DatabaseDropCommand( $store->reveal(), - $helper->reveal() + $helper->reveal(), ); $input = new ArrayInput([]); @@ -85,7 +85,7 @@ public function testSuccessful(): void $command = new DatabaseDropCommand( $store->reveal(), - $helper->reveal() + $helper->reveal(), ); $input = new ArrayInput(['--force' => true]); @@ -114,7 +114,7 @@ public function testSkip(): void $command = new DatabaseDropCommand( $store->reveal(), - $helper->reveal() + $helper->reveal(), ); $input = new ArrayInput(['--force' => true, '--if-exists' => true]); @@ -144,7 +144,7 @@ public function testError(): void $command = new DatabaseDropCommand( $store->reveal(), - $helper->reveal() + $helper->reveal(), ); $input = new ArrayInput(['--force' => true]); diff --git a/tests/Unit/Console/Command/DebugCommandTest.php b/tests/Unit/Console/Command/DebugCommandTest.php index 784d41508..8b06d6e63 100644 --- a/tests/Unit/Console/Command/DebugCommandTest.php +++ b/tests/Unit/Console/Command/DebugCommandTest.php @@ -20,7 +20,7 @@ public function testSuccessful(): void { $command = new DebugCommand( new AggregateRootRegistry(['profile' => Profile::class]), - new EventRegistry(['profile.created' => ProfileCreated::class]) + new EventRegistry(['profile.created' => ProfileCreated::class]), ); $input = new ArrayInput([]); diff --git a/tests/Unit/Console/Command/OutboxInfoCommandTest.php b/tests/Unit/Console/Command/OutboxInfoCommandTest.php index aa7f67058..514a8e7ac 100644 --- a/tests/Unit/Console/Command/OutboxInfoCommandTest.php +++ b/tests/Unit/Console/Command/OutboxInfoCommandTest.php @@ -42,7 +42,7 @@ public function testSuccessful(): void new SerializedEvent( 'profile.visited', '{"visitorId": "1"}', - ) + ), ); $command = new OutboxInfoCommand( @@ -80,7 +80,7 @@ public function testSuccessfulWithLimit(): void new SerializedEvent( 'profile.visited', '{"visitorId": "1"}', - ) + ), ); $command = new OutboxInfoCommand( diff --git a/tests/Unit/Console/Command/ProjectionCreateCommandTest.php b/tests/Unit/Console/Command/ProjectionCreateCommandTest.php index 565e46015..bdd58f8f9 100644 --- a/tests/Unit/Console/Command/ProjectionCreateCommandTest.php +++ b/tests/Unit/Console/Command/ProjectionCreateCommandTest.php @@ -28,7 +28,7 @@ public function testSuccessful(): void $repository->create()->shouldBeCalled(); $command = new ProjectionCreateCommand( - $repository->reveal() + $repository->reveal(), ); $input = new ArrayInput([]); @@ -50,7 +50,7 @@ public function testSpecificProjection(): void $handler = new MetadataAwareProjectionHandler([$projectionA, $projectionB]); $command = new ProjectionCreateCommand( - $handler + $handler, ); $input = new ArrayInput(['--projection' => DummyProjection::class]); diff --git a/tests/Unit/Console/Command/ProjectionDropCommandTest.php b/tests/Unit/Console/Command/ProjectionDropCommandTest.php index ffd62f4f3..d65200df7 100644 --- a/tests/Unit/Console/Command/ProjectionDropCommandTest.php +++ b/tests/Unit/Console/Command/ProjectionDropCommandTest.php @@ -28,7 +28,7 @@ public function testSuccessful(): void $repository->drop()->shouldBeCalled(); $command = new ProjectionDropCommand( - $repository->reveal() + $repository->reveal(), ); $input = new ArrayInput([]); @@ -50,7 +50,7 @@ public function testSpecificProjection(): void $handler = new MetadataAwareProjectionHandler([$projectionA, $projectionB]); $command = new ProjectionDropCommand( - $handler + $handler, ); $input = new ArrayInput(['--projection' => DummyProjection::class]); diff --git a/tests/Unit/Console/Command/ProjectionRebuildCommandTest.php b/tests/Unit/Console/Command/ProjectionRebuildCommandTest.php index 824cc68f3..698e08009 100644 --- a/tests/Unit/Console/Command/ProjectionRebuildCommandTest.php +++ b/tests/Unit/Console/Command/ProjectionRebuildCommandTest.php @@ -35,28 +35,26 @@ final class ProjectionRebuildCommandTest extends TestCase public function setUp(): void { - /** - * @return Generator - */ + /** @return Generator */ $this->messages = static function (): Generator { yield new Message( - new ProfileCreated(ProfileId::fromString('1'), Email::fromString('info@patchlevel.de')) + new ProfileCreated(ProfileId::fromString('1'), Email::fromString('info@patchlevel.de')), ); yield new Message( - new ProfileCreated(ProfileId::fromString('1'), Email::fromString('info@patchlevel.de')) + new ProfileCreated(ProfileId::fromString('1'), Email::fromString('info@patchlevel.de')), ); yield new Message( - new ProfileCreated(ProfileId::fromString('1'), Email::fromString('info@patchlevel.de')) + new ProfileCreated(ProfileId::fromString('1'), Email::fromString('info@patchlevel.de')), ); yield new Message( - new ProfileCreated(ProfileId::fromString('1'), Email::fromString('info@patchlevel.de')) + new ProfileCreated(ProfileId::fromString('1'), Email::fromString('info@patchlevel.de')), ); yield new Message( - new ProfileCreated(ProfileId::fromString('1'), Email::fromString('info@patchlevel.de')) + new ProfileCreated(ProfileId::fromString('1'), Email::fromString('info@patchlevel.de')), ); }; } @@ -72,7 +70,7 @@ public function testSuccessful(): void $command = new ProjectionRebuildCommand( $store->reveal(), - $repository->reveal() + $repository->reveal(), ); $input = new ArrayInput([]); @@ -100,7 +98,7 @@ public function testSpecificProjection(): void $command = new ProjectionRebuildCommand( $store->reveal(), - $handler + $handler, ); $input = new ArrayInput(['--projection' => $projectionA::class]); @@ -131,7 +129,7 @@ public function testRecreate(): void $command = new ProjectionRebuildCommand( $store->reveal(), - $repository->reveal() + $repository->reveal(), ); $input = new ArrayInput(['--recreate' => true]); @@ -161,7 +159,7 @@ public function testRecreateWithSpecificProjection(): void $command = new ProjectionRebuildCommand( $store->reveal(), - $handler + $handler, ); $input = new ArrayInput(['--recreate' => true, '--projection' => DummyProjection::class]); @@ -192,7 +190,7 @@ public function testStoreNotSupported(): void $command = new ProjectionRebuildCommand( $store->reveal(), - $repository->reveal() + $repository->reveal(), ); $input = new ArrayInput([]); diff --git a/tests/Unit/Console/Command/SchemaCreateCommandTest.php b/tests/Unit/Console/Command/SchemaCreateCommandTest.php index f999a6349..0a929811b 100644 --- a/tests/Unit/Console/Command/SchemaCreateCommandTest.php +++ b/tests/Unit/Console/Command/SchemaCreateCommandTest.php @@ -27,7 +27,7 @@ public function testSuccessful(): void $command = new SchemaCreateCommand( $store, - $schemaManager->reveal() + $schemaManager->reveal(), ); $input = new ArrayInput([]); @@ -55,7 +55,7 @@ public function testDryRun(): void $command = new SchemaCreateCommand( $store, - $schemaManager->reveal() + $schemaManager->reveal(), ); $input = new ArrayInput(['--dry-run' => true]); @@ -81,7 +81,7 @@ public function testDryRunNotSupported(): void $command = new SchemaCreateCommand( $store, - $schemaManager->reveal() + $schemaManager->reveal(), ); $input = new ArrayInput(['--dry-run' => true]); diff --git a/tests/Unit/Console/Command/SchemaDropCommandTest.php b/tests/Unit/Console/Command/SchemaDropCommandTest.php index 7164a4c51..efc1389e5 100644 --- a/tests/Unit/Console/Command/SchemaDropCommandTest.php +++ b/tests/Unit/Console/Command/SchemaDropCommandTest.php @@ -27,7 +27,7 @@ public function testSuccessful(): void $command = new SchemaDropCommand( $store, - $schemaManager->reveal() + $schemaManager->reveal(), ); $input = new ArrayInput(['--force' => true]); @@ -51,7 +51,7 @@ public function testMissingForce(): void $command = new SchemaDropCommand( $store, - $schemaManager->reveal() + $schemaManager->reveal(), ); $input = new ArrayInput([]); @@ -65,7 +65,7 @@ public function testMissingForce(): void self::assertStringContainsString( '[ERROR] Please run the operation with --force to execute. All data will be lost!', - $content + $content, ); } @@ -82,7 +82,7 @@ public function testDryRun(): void $command = new SchemaDropCommand( $store, - $schemaManager->reveal() + $schemaManager->reveal(), ); $input = new ArrayInput(['--dry-run' => true]); @@ -108,7 +108,7 @@ public function testDryRunNotSupported(): void $command = new SchemaDropCommand( $store, - $schemaManager->reveal() + $schemaManager->reveal(), ); $input = new ArrayInput(['--dry-run' => true]); diff --git a/tests/Unit/Console/Command/SchemaUpdateCommandTest.php b/tests/Unit/Console/Command/SchemaUpdateCommandTest.php index fb79d5587..b76826bb2 100644 --- a/tests/Unit/Console/Command/SchemaUpdateCommandTest.php +++ b/tests/Unit/Console/Command/SchemaUpdateCommandTest.php @@ -27,7 +27,7 @@ public function testSuccessful(): void $command = new SchemaUpdateCommand( $store, - $schemaManager->reveal() + $schemaManager->reveal(), ); $input = new ArrayInput(['--force' => true]); @@ -51,7 +51,7 @@ public function testMissingForce(): void $command = new SchemaUpdateCommand( $store, - $schemaManager->reveal() + $schemaManager->reveal(), ); $input = new ArrayInput([]); @@ -65,7 +65,7 @@ public function testMissingForce(): void self::assertStringContainsString( '[ERROR] Please run the operation with --force to execute. Database could break!', - $content + $content, ); } @@ -82,7 +82,7 @@ public function testDryRun(): void $command = new SchemaUpdateCommand( $store, - $schemaManager->reveal() + $schemaManager->reveal(), ); $input = new ArrayInput(['--dry-run' => true]); @@ -107,7 +107,7 @@ public function testDryRunNotSupported(): void $command = new SchemaUpdateCommand( $store, - $schemaManager->reveal() + $schemaManager->reveal(), ); $input = new ArrayInput(['--dry-run' => true]); diff --git a/tests/Unit/Console/Command/ShowCommandTest.php b/tests/Unit/Console/Command/ShowCommandTest.php index 66651e092..d09cb8158 100644 --- a/tests/Unit/Console/Command/ShowCommandTest.php +++ b/tests/Unit/Console/Command/ShowCommandTest.php @@ -46,13 +46,13 @@ public function testSuccessful(): void new SerializedEvent( 'profile.visited', '{"visitorId": "1"}', - ) + ), ); $command = new ShowCommand( $store->reveal(), $serializer->reveal(), - new AggregateRootRegistry(['profile' => Profile::class]) + new AggregateRootRegistry(['profile' => Profile::class]), ); $input = new ArrayInput([ @@ -79,7 +79,7 @@ public function testAggregateNotAString(): void $command = new ShowCommand( $store->reveal(), $serializer->reveal(), - new AggregateRootRegistry(['profile' => Profile::class]) + new AggregateRootRegistry(['profile' => Profile::class]), ); $input = new ArrayInput([ @@ -101,7 +101,7 @@ public function testIdNotAString(): void $command = new ShowCommand( $store->reveal(), $serializer->reveal(), - new AggregateRootRegistry(['profile' => Profile::class]) + new AggregateRootRegistry(['profile' => Profile::class]), ); $input = new ArrayInput([ @@ -123,7 +123,7 @@ public function testWrongAggregate(): void $command = new ShowCommand( $store->reveal(), $serializer->reveal(), - new AggregateRootRegistry(['profile' => Profile::class]) + new AggregateRootRegistry(['profile' => Profile::class]), ); $input = new ArrayInput([ @@ -152,7 +152,7 @@ public function testNotFound(): void $command = new ShowCommand( $store->reveal(), $serializer->reveal(), - new AggregateRootRegistry(['profile' => Profile::class]) + new AggregateRootRegistry(['profile' => Profile::class]), ); $input = new ArrayInput([ @@ -177,8 +177,8 @@ public function testInteractiveMissingAggregateShouldRaiseException(): void new ShowCommand( $this->prophesize(Store::class)->reveal(), $this->prophesize(EventSerializer::class)->reveal(), - new AggregateRootRegistry(['test' => Profile::class]) - ) + new AggregateRootRegistry(['test' => Profile::class]), + ), ); $this->expectException(MissingInputException::class); @@ -191,8 +191,8 @@ public function testInteractiveMissingIdShouldRaiseException(): void new ShowCommand( $this->prophesize(Store::class)->reveal(), $this->prophesize(EventSerializer::class)->reveal(), - new AggregateRootRegistry(['test' => Profile::class]) - ) + new AggregateRootRegistry(['test' => Profile::class]), + ), ); // Select "test" in first question @@ -220,15 +220,15 @@ public function testInteractiveSuccessful(): void new SerializedEvent( 'profile.visited', '{"visitorId": "1"}', - ) + ), ); $commandTest = new CommandTester( new ShowCommand( $store->reveal(), $serializer->reveal(), - new AggregateRootRegistry(['profile' => Profile::class]) - ) + new AggregateRootRegistry(['profile' => Profile::class]), + ), ); $commandTest->setInputs([0, 1]); diff --git a/tests/Unit/Console/Command/WatchCommandTest.php b/tests/Unit/Console/Command/WatchCommandTest.php index 8ff6478ec..60df44d5e 100644 --- a/tests/Unit/Console/Command/WatchCommandTest.php +++ b/tests/Unit/Console/Command/WatchCommandTest.php @@ -30,7 +30,7 @@ public function testSuccessful(): void $command = new WatchCommand( $watchServer->reveal(), - $serializer->reveal() + $serializer->reveal(), ); $input = new ArrayInput([]); diff --git a/tests/Unit/Console/OutputStyleTest.php b/tests/Unit/Console/OutputStyleTest.php index 01822a525..9137509c2 100644 --- a/tests/Unit/Console/OutputStyleTest.php +++ b/tests/Unit/Console/OutputStyleTest.php @@ -31,7 +31,7 @@ public function testWrite(): void $event = new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('foo@bar.com') + Email::fromString('foo@bar.com'), ); $serializer = $this->prophesize(EventSerializer::class); diff --git a/tests/Unit/Console/Worker/BytesTest.php b/tests/Unit/Console/Worker/BytesTest.php index 678773f58..3a6f713ea 100644 --- a/tests/Unit/Console/Worker/BytesTest.php +++ b/tests/Unit/Console/Worker/BytesTest.php @@ -25,9 +25,7 @@ public function testParseInvalidNegativeNumber(): void Bytes::parseFromString('-5GB'); } - /** - * @dataProvider validParseDataProvider - */ + /** @dataProvider validParseDataProvider */ public function testValidParse(string $string, int $expectedBytes): void { $bytes = Bytes::parseFromString($string); @@ -35,9 +33,7 @@ public function testValidParse(string $string, int $expectedBytes): void self::assertSame($expectedBytes, $bytes->value()); } - /** - * @return Generator - */ + /** @return Generator */ public function validParseDataProvider(): Generator { yield ['50', 50]; diff --git a/tests/Unit/Console/Worker/DefaultWorkerTest.php b/tests/Unit/Console/Worker/DefaultWorkerTest.php index dced126af..c5ecd9e37 100644 --- a/tests/Unit/Console/Worker/DefaultWorkerTest.php +++ b/tests/Unit/Console/Worker/DefaultWorkerTest.php @@ -28,7 +28,7 @@ static function (array $args) { $args[0]->worker->stop(); return $args[0]; - } + }, ); $evenDispatcher->dispatch(Argument::type(WorkerStoppedEvent::class))->shouldBeCalledTimes(1); diff --git a/tests/Unit/EventBus/Decorator/ChainMessageDecoratorTest.php b/tests/Unit/EventBus/Decorator/ChainMessageDecoratorTest.php index 8d19ed410..b63739ae1 100644 --- a/tests/Unit/EventBus/Decorator/ChainMessageDecoratorTest.php +++ b/tests/Unit/EventBus/Decorator/ChainMessageDecoratorTest.php @@ -23,8 +23,8 @@ public function testChain(): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $decorator1 = $this->prophesize(MessageDecorator::class); diff --git a/tests/Unit/EventBus/DefaultEventBusTest.php b/tests/Unit/EventBus/DefaultEventBusTest.php index c28168de4..1c79232cf 100644 --- a/tests/Unit/EventBus/DefaultEventBusTest.php +++ b/tests/Unit/EventBus/DefaultEventBusTest.php @@ -22,7 +22,7 @@ final class DefaultEventBusTest extends TestCase public function testDispatchEvent(): void { $listener = new class implements Listener { - public ?Message $message = null; + public Message|null $message = null; public function __invoke(Message $message): void { @@ -33,8 +33,8 @@ public function __invoke(Message $message): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $eventBus = new DefaultEventBus([$listener]); @@ -58,15 +58,15 @@ public function __invoke(Message $message): void $message1 = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $message2 = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $eventBus = new DefaultEventBus([$listener]); @@ -80,7 +80,7 @@ public function __invoke(Message $message): void public function testDynamicListener(): void { $listener = new class implements Listener { - public ?Message $message = null; + public Message|null $message = null; public function __invoke(Message $message): void { @@ -91,8 +91,8 @@ public function __invoke(Message $message): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $eventBus = new DefaultEventBus(); @@ -107,19 +107,17 @@ public function testSynchroneEvents(): void $messageA = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $eventBus = new DefaultEventBus(); $listenerA = new class ($eventBus) implements Listener { - public ?float $time = null; - private DefaultEventBus $bus; + public float|null $time = null; - public function __construct(DefaultEventBus $bus) + public function __construct(private DefaultEventBus $bus) { - $this->bus = $bus; } public function __invoke(Message $message): void @@ -131,7 +129,7 @@ public function __invoke(Message $message): void $messageB = new Message( new ProfileVisited( ProfileId::fromString('1'), - ) + ), ); $this->bus->dispatch($messageB); @@ -141,7 +139,7 @@ public function __invoke(Message $message): void }; $listenerB = new class implements Listener { - public ?float $time = null; + public float|null $time = null; public function __invoke(Message $message): void { @@ -169,25 +167,23 @@ public function testMultipleMessagesAddingNewEventInListener(): void $messageA = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $messageB = new Message( new ProfileVisited( ProfileId::fromString('1'), - ) + ), ); $eventBus = new DefaultEventBus(); $listenerA = new class ($eventBus) implements Listener { - public ?float $time = null; - private DefaultEventBus $bus; + public float|null $time = null; - public function __construct(DefaultEventBus $bus) + public function __construct(private DefaultEventBus $bus) { - $this->bus = $bus; } public function __invoke(Message $message): void @@ -198,8 +194,8 @@ public function __invoke(Message $message): void $messageB = new Message( new NameChanged( - 'name' - ) + 'name', + ), ); $this->bus->dispatch($messageB); @@ -209,7 +205,7 @@ public function __invoke(Message $message): void }; $listenerB = new class implements Listener { - public ?float $time = null; + public float|null $time = null; public function __invoke(Message $message): void { diff --git a/tests/Unit/EventBus/MessageTest.php b/tests/Unit/EventBus/MessageTest.php index 12f189227..596721188 100644 --- a/tests/Unit/EventBus/MessageTest.php +++ b/tests/Unit/EventBus/MessageTest.php @@ -23,11 +23,11 @@ public function testEmptyMessage(): void $event = new ProfileCreated( $id, - $email + $email, ); $message = new Message( - $event + $event, ); self::assertEquals($event, $message->event()); @@ -42,7 +42,7 @@ public function testCreateMessageWithHeader(): void $event = new ProfileCreated( $id, - $email + $email, ); $message = Message::create($event) @@ -67,7 +67,7 @@ public function testChangeHeader(): void $event = new ProfileCreated( $id, - $email + $email, ); $message = Message::create($event) @@ -94,8 +94,8 @@ public function testHeaderNotFound(): void $message = new Message( new ProfileCreated( $id, - $email - ) + $email, + ), ); /** @psalm-suppress UnusedMethodCall */ @@ -111,7 +111,7 @@ public function testCustomHeaders(): void $event = new ProfileCreated( $id, - $email + $email, ); $message = Message::create($event) @@ -123,7 +123,7 @@ public function testCustomHeaders(): void self::assertEquals( ['custom-field' => 'foo-bar'], - $message->customHeaders() + $message->customHeaders(), ); } } diff --git a/tests/Unit/EventBus/SubscriberTest.php b/tests/Unit/EventBus/SubscriberTest.php index d3fc90f3d..48a787ebd 100644 --- a/tests/Unit/EventBus/SubscriberTest.php +++ b/tests/Unit/EventBus/SubscriberTest.php @@ -21,7 +21,7 @@ final class SubscriberTest extends TestCase public function testSubscribeEvent(): void { $subscriber = new class extends Subscriber { - public ?Message $message = null; + public Message|null $message = null; #[Handle(ProfileCreated::class)] public function handle(Message $message): void @@ -33,8 +33,8 @@ public function handle(Message $message): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $eventBus = new DefaultEventBus([$subscriber]); @@ -46,7 +46,7 @@ public function handle(Message $message): void public function testSubscribeWrongEvent(): void { $subscriber = new class extends Subscriber { - public ?Message $message = null; + public Message|null $message = null; #[Handle(ProfileVisited::class)] public function handle(Message $message): void @@ -58,8 +58,8 @@ public function handle(Message $message): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $eventBus = new DefaultEventBus([$subscriber]); @@ -71,8 +71,8 @@ public function handle(Message $message): void public function testSubscribeMultipleEvents(): void { $subscriber = new class extends Subscriber { - public ?Message $a = null; - public ?Message $b = null; + public Message|null $a = null; + public Message|null $b = null; #[Handle(ProfileCreated::class)] public function handleA(Message $message): void @@ -90,14 +90,14 @@ public function handleB(Message $message): void $message1 = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $message2 = new Message( new ProfileVisited( - ProfileId::fromString('1') - ) + ProfileId::fromString('1'), + ), ); $eventBus = new DefaultEventBus([$subscriber]); @@ -124,14 +124,14 @@ public function handle(Message $message): void $message1 = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $message2 = new Message( new ProfileVisited( - ProfileId::fromString('1') - ) + ProfileId::fromString('1'), + ), ); $eventBus = new DefaultEventBus([$subscriber]); @@ -161,8 +161,8 @@ public function handleB(Message $message): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $eventBus = new DefaultEventBus(); diff --git a/tests/Unit/EventBus/SymfonyEventBusTest.php b/tests/Unit/EventBus/SymfonyEventBusTest.php index 3b7da9695..8ccff282b 100644 --- a/tests/Unit/EventBus/SymfonyEventBusTest.php +++ b/tests/Unit/EventBus/SymfonyEventBusTest.php @@ -26,8 +26,8 @@ public function testDispatchEvent(): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $envelope = new Envelope($message); @@ -50,15 +50,15 @@ public function testDispatchMultipleMessages(): void $message1 = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $message2 = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $envelope1 = new Envelope($message1); @@ -89,7 +89,7 @@ public function testDispatchMultipleMessages(): void public function testDefaultEventBus(): void { $listener = new class implements Listener { - public ?Message $message = null; + public Message|null $message = null; public function __invoke(Message $message): void { @@ -100,8 +100,8 @@ public function __invoke(Message $message): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $eventBus = SymfonyEventBus::create([$listener]); diff --git a/tests/Unit/Fixture/Dummy2Projection.php b/tests/Unit/Fixture/Dummy2Projection.php index 45bf5ab02..da767c6e2 100644 --- a/tests/Unit/Fixture/Dummy2Projection.php +++ b/tests/Unit/Fixture/Dummy2Projection.php @@ -12,7 +12,7 @@ final class Dummy2Projection implements Projection { - public ?EventMessage $handledMessage = null; + public EventMessage|null $handledMessage = null; public bool $createCalled = false; public bool $dropCalled = false; diff --git a/tests/Unit/Fixture/DummyProjection.php b/tests/Unit/Fixture/DummyProjection.php index 95fe50e5d..63495f969 100644 --- a/tests/Unit/Fixture/DummyProjection.php +++ b/tests/Unit/Fixture/DummyProjection.php @@ -12,7 +12,7 @@ final class DummyProjection implements Projection { - public ?EventMessage $handledMessage = null; + public EventMessage|null $handledMessage = null; public bool $createCalled = false; public bool $dropCalled = false; diff --git a/tests/Unit/Fixture/Email.php b/tests/Unit/Fixture/Email.php index 9995706b5..d1d5e3b47 100644 --- a/tests/Unit/Fixture/Email.php +++ b/tests/Unit/Fixture/Email.php @@ -6,11 +6,8 @@ final class Email { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } public static function fromString(string $value): self diff --git a/tests/Unit/Fixture/EmailNormalizer.php b/tests/Unit/Fixture/EmailNormalizer.php index bef6e23b8..393d4e1ec 100644 --- a/tests/Unit/Fixture/EmailNormalizer.php +++ b/tests/Unit/Fixture/EmailNormalizer.php @@ -23,7 +23,7 @@ public function normalize(mixed $value): string return $value->toString(); } - public function denormalize(mixed $value): ?Email + public function denormalize(mixed $value): Email|null { if ($value === null) { return null; diff --git a/tests/Unit/Fixture/Message.php b/tests/Unit/Fixture/Message.php index 074dc244c..6e63798bb 100644 --- a/tests/Unit/Fixture/Message.php +++ b/tests/Unit/Fixture/Message.php @@ -10,15 +10,8 @@ final class Message { - private MessageId $messageId; - private string $text; - private DateTimeImmutable $createdAt; - - private function __construct(MessageId $messageId, string $text, DateTimeImmutable $createdAt) + private function __construct(private MessageId $messageId, private string $text, private DateTimeImmutable $createdAt) { - $this->messageId = $messageId; - $this->text = $text; - $this->createdAt = $createdAt; } public function id(): MessageId @@ -36,9 +29,7 @@ public function createdAt(): DateTimeImmutable return $this->createdAt; } - /** - * @return array{id: string, text: string, createdAt: string} - */ + /** @return array{id: string, text: string, createdAt: string} */ public function toArray(): array { return [ @@ -53,9 +44,7 @@ public static function create(MessageId $messageId, string $text): self return new self($messageId, $text, new DateTimeImmutable()); } - /** - * @param array{id: string, text: string, createdAt: string} $data - */ + /** @param array{id: string, text: string, createdAt: string} $data */ public static function fromArray(array $data): self { return new self(MessageId::fromString($data['id']), $data['text'], new DateTimeImmutable($data['createdAt'])); diff --git a/tests/Unit/Fixture/MessageDeleted.php b/tests/Unit/Fixture/MessageDeleted.php index 2f31dde0b..5dce62da7 100644 --- a/tests/Unit/Fixture/MessageDeleted.php +++ b/tests/Unit/Fixture/MessageDeleted.php @@ -10,7 +10,7 @@ final class MessageDeleted { public function __construct( - public MessageId $messageId + public MessageId $messageId, ) { } } diff --git a/tests/Unit/Fixture/MessageId.php b/tests/Unit/Fixture/MessageId.php index 7c588da7e..c1e0866a3 100644 --- a/tests/Unit/Fixture/MessageId.php +++ b/tests/Unit/Fixture/MessageId.php @@ -6,11 +6,8 @@ final class MessageId { - private string $id; - - private function __construct(string $id) + private function __construct(private string $id) { - $this->id = $id; } public static function fromString(string $id): self diff --git a/tests/Unit/Fixture/MessageNormalizer.php b/tests/Unit/Fixture/MessageNormalizer.php index 188ac1456..347bf11f8 100644 --- a/tests/Unit/Fixture/MessageNormalizer.php +++ b/tests/Unit/Fixture/MessageNormalizer.php @@ -13,10 +13,8 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class MessageNormalizer implements Normalizer { - /** - * @return array|null - */ - public function normalize(mixed $value): ?array + /** @return array|null */ + public function normalize(mixed $value): array|null { if ($value === null) { return null; @@ -29,7 +27,7 @@ public function normalize(mixed $value): ?array return $value->toArray(); } - public function denormalize(mixed $value): ?Message + public function denormalize(mixed $value): Message|null { if ($value === null) { return null; diff --git a/tests/Unit/Fixture/MessagePublished.php b/tests/Unit/Fixture/MessagePublished.php index 2c3c21f65..3ea5d059a 100644 --- a/tests/Unit/Fixture/MessagePublished.php +++ b/tests/Unit/Fixture/MessagePublished.php @@ -10,7 +10,7 @@ final class MessagePublished { public function __construct( - public Message $message + public Message $message, ) { } } diff --git a/tests/Unit/Fixture/NameChanged.php b/tests/Unit/Fixture/NameChanged.php index 638c521c3..2d2cb5ba3 100644 --- a/tests/Unit/Fixture/NameChanged.php +++ b/tests/Unit/Fixture/NameChanged.php @@ -7,7 +7,7 @@ final class NameChanged { public function __construct( - public string $name + public string $name, ) { } } diff --git a/tests/Unit/Fixture/NotNormalizedProfileCreated.php b/tests/Unit/Fixture/NotNormalizedProfileCreated.php index 601ab663d..28b66d437 100644 --- a/tests/Unit/Fixture/NotNormalizedProfileCreated.php +++ b/tests/Unit/Fixture/NotNormalizedProfileCreated.php @@ -11,7 +11,7 @@ final class NotNormalizedProfileCreated { public function __construct( public ProfileId $profileId, - public Email $email + public Email $email, ) { } } diff --git a/tests/Unit/Fixture/Profile.php b/tests/Unit/Fixture/Profile.php index e35d36c53..32f272845 100644 --- a/tests/Unit/Fixture/Profile.php +++ b/tests/Unit/Fixture/Profile.php @@ -43,14 +43,14 @@ public static function createProfile(ProfileId $id, Email $email): self public function publishMessage(Message $message): void { $this->recordThat(new MessagePublished( - $message + $message, )); } public function deleteMessage(MessageId $messageId): void { $this->recordThat(new MessageDeleted( - $messageId + $messageId, )); } diff --git a/tests/Unit/Fixture/ProfileId.php b/tests/Unit/Fixture/ProfileId.php index 117d303ec..21dc3f4ad 100644 --- a/tests/Unit/Fixture/ProfileId.php +++ b/tests/Unit/Fixture/ProfileId.php @@ -6,11 +6,8 @@ final class ProfileId { - private string $id; - - private function __construct(string $id) + private function __construct(private string $id) { - $this->id = $id; } public static function fromString(string $id): self diff --git a/tests/Unit/Fixture/ProfileIdNormalizer.php b/tests/Unit/Fixture/ProfileIdNormalizer.php index a7568c3cf..fa64ee3e6 100644 --- a/tests/Unit/Fixture/ProfileIdNormalizer.php +++ b/tests/Unit/Fixture/ProfileIdNormalizer.php @@ -23,7 +23,7 @@ public function normalize(mixed $value): string return $value->toString(); } - public function denormalize(mixed $value): ?ProfileId + public function denormalize(mixed $value): ProfileId|null { if ($value === null) { return null; diff --git a/tests/Unit/Fixture/ProfileVisited.php b/tests/Unit/Fixture/ProfileVisited.php index 054722b4f..a4d5a2a18 100644 --- a/tests/Unit/Fixture/ProfileVisited.php +++ b/tests/Unit/Fixture/ProfileVisited.php @@ -11,7 +11,7 @@ final class ProfileVisited { public function __construct( #[ProfileIdNormalizer] - public ProfileId $visitorId + public ProfileId $visitorId, ) { } } diff --git a/tests/Unit/Fixture/ProfileWithBrokenApplyNoType.php b/tests/Unit/Fixture/ProfileWithBrokenApplyNoType.php index d05790874..bf7cdcf1b 100644 --- a/tests/Unit/Fixture/ProfileWithBrokenApplyNoType.php +++ b/tests/Unit/Fixture/ProfileWithBrokenApplyNoType.php @@ -11,9 +11,7 @@ #[Aggregate(ProfileWithBrokenApplyNoType::class)] final class ProfileWithBrokenApplyNoType extends AggregateRoot { - /** - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint - */ + /** @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint */ #[Apply] protected function applyWithNoType($event): void { diff --git a/tests/Unit/Fixture/ProfileWithSnapshot.php b/tests/Unit/Fixture/ProfileWithSnapshot.php index bf7f2c7cf..4d9632b5f 100644 --- a/tests/Unit/Fixture/ProfileWithSnapshot.php +++ b/tests/Unit/Fixture/ProfileWithSnapshot.php @@ -34,9 +34,7 @@ public function email(): Email return $this->email; } - /** - * @return array - */ + /** @return array */ public function messages(): array { return $this->messages; @@ -53,7 +51,7 @@ public static function createProfile(ProfileId $id, Email $email): self public function publishMessage(Message $message): void { $this->recordThat(new MessagePublished( - $message + $message, )); } diff --git a/tests/Unit/Fixture/SimpleEvent.php b/tests/Unit/Fixture/SimpleEvent.php index 1d07a1eb6..428d3416f 100644 --- a/tests/Unit/Fixture/SimpleEvent.php +++ b/tests/Unit/Fixture/SimpleEvent.php @@ -9,5 +9,5 @@ #[Event('simple')] final class SimpleEvent { - public ?string $name = null; + public string|null $name = null; } diff --git a/tests/Unit/Fixture/WrongNormalizerEvent.php b/tests/Unit/Fixture/WrongNormalizerEvent.php index df8408d03..88cdbda92 100644 --- a/tests/Unit/Fixture/WrongNormalizerEvent.php +++ b/tests/Unit/Fixture/WrongNormalizerEvent.php @@ -11,7 +11,7 @@ final class WrongNormalizerEvent { public function __construct( #[EmailNormalizer] - public bool $email + public bool $email, ) { } } diff --git a/tests/Unit/Metadata/Aggregate/AttributeAggregateMetadataFactoryTest.php b/tests/Unit/Metadata/Aggregate/AttributeAggregateMetadataFactoryTest.php index 223d337b5..277828614 100644 --- a/tests/Unit/Metadata/Aggregate/AttributeAggregateMetadataFactoryTest.php +++ b/tests/Unit/Metadata/Aggregate/AttributeAggregateMetadataFactoryTest.php @@ -35,12 +35,12 @@ public function testProfile(): void NameChanged::class => 'applyNameChanged', SplittingEvent::class => 'applySplittingEvent', ], - $metadata->applyMethods + $metadata->applyMethods, ); self::assertFalse($metadata->suppressAll); self::assertSame( [MessageDeleted::class => true], - $metadata->suppressEvents + $metadata->suppressEvents, ); } @@ -55,7 +55,7 @@ public function testApplyWithNoEventClass(): void ProfileVisited::class => 'applyProfileCreated', NameChanged::class => 'applyNameChanged', ], - $metadata->applyMethods + $metadata->applyMethods, ); self::assertFalse($metadata->suppressAll); self::assertSame([], $metadata->suppressEvents); diff --git a/tests/Unit/Metadata/Event/AttributeEventMetadataFactoryTest.php b/tests/Unit/Metadata/Event/AttributeEventMetadataFactoryTest.php index 0d0d27993..92c81dff5 100644 --- a/tests/Unit/Metadata/Event/AttributeEventMetadataFactoryTest.php +++ b/tests/Unit/Metadata/Event/AttributeEventMetadataFactoryTest.php @@ -29,7 +29,8 @@ public function testEmptyEvent(): void public function testEventWithoutProperties(): void { - $event = new #[Event('profile_created')] class { + $event = new #[Event('profile_created')] + class { }; $metadataFactory = new AttributeEventMetadataFactory(); @@ -41,9 +42,10 @@ public function testEventWithoutProperties(): void public function testEventWithProperties(): void { - $event = new #[Event('profile_created')] class ('Foo') { + $event = new #[Event('profile_created')] + class ('Foo') { public function __construct( - public string $name + public string $name, ) { } }; @@ -64,10 +66,11 @@ public function __construct( public function testEventWithFieldName(): void { - $event = new #[Event('profile_created')] class ('Foo') { + $event = new #[Event('profile_created')] + class ('Foo') { public function __construct( #[NormalizedName('username')] - public string $name + public string $name, ) { } }; @@ -88,10 +91,11 @@ public function __construct( public function testEventWithNormalizer(): void { - $event = new #[Event('profile_created')] class (Email::fromString('info@patchlevel.de')) { + $event = new #[Event('profile_created')] + class (Email::fromString('info@patchlevel.de')) { public function __construct( #[EmailNormalizer] - public Email $email + public Email $email, ) { } }; @@ -112,10 +116,11 @@ public function __construct( public function testEventWithLegacyNormalizer(): void { - $event = new #[Event('profile_created')] class (Email::fromString('info@patchlevel.de')) { + $event = new #[Event('profile_created')] + class (Email::fromString('info@patchlevel.de')) { public function __construct( #[Normalize(new EmailNormalizer())] - public Email $email + public Email $email, ) { } }; diff --git a/tests/Unit/Metadata/Projection/AttributeProjectionMetadataFactoryTest.php b/tests/Unit/Metadata/Projection/AttributeProjectionMetadataFactoryTest.php index c5729f61b..5273e7c8f 100644 --- a/tests/Unit/Metadata/Projection/AttributeProjectionMetadataFactoryTest.php +++ b/tests/Unit/Metadata/Projection/AttributeProjectionMetadataFactoryTest.php @@ -54,7 +54,7 @@ public function drop(): void self::assertEquals( [ProfileVisited::class => 'handle'], - $metadata->handleMethods + $metadata->handleMethods, ); self::assertSame('create', $metadata->createMethod); @@ -79,7 +79,7 @@ public function handle(): void ProfileVisited::class => 'handle', ProfileCreated::class => 'handle', ], - $metadata->handleMethods + $metadata->handleMethods, ); } diff --git a/tests/Unit/Outbox/OutboxEventBusTest.php b/tests/Unit/Outbox/OutboxEventBusTest.php index 395d938da..ae5bb773f 100644 --- a/tests/Unit/Outbox/OutboxEventBusTest.php +++ b/tests/Unit/Outbox/OutboxEventBusTest.php @@ -23,8 +23,8 @@ public function testDispatchEvent(): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $store = $this->prophesize(OutboxStore::class); @@ -39,15 +39,15 @@ public function testDispatchMultipleMessages(): void $message1 = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $message2 = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $store = $this->prophesize(OutboxStore::class); diff --git a/tests/Unit/Outbox/StoreOutboxConsumerTest.php b/tests/Unit/Outbox/StoreOutboxConsumerTest.php index 7fd27495b..474e62e9b 100644 --- a/tests/Unit/Outbox/StoreOutboxConsumerTest.php +++ b/tests/Unit/Outbox/StoreOutboxConsumerTest.php @@ -24,8 +24,8 @@ public function testConsume(): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $store = $this->prophesize(OutboxStore::class); @@ -44,8 +44,8 @@ public function testConsumeWithLimit(): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), ); $store = $this->prophesize(OutboxStore::class); diff --git a/tests/Unit/Pipeline/Middleware/ChainMiddlewareTest.php b/tests/Unit/Pipeline/Middleware/ChainMiddlewareTest.php index 1c2e9620c..3eb7a06a3 100644 --- a/tests/Unit/Pipeline/Middleware/ChainMiddlewareTest.php +++ b/tests/Unit/Pipeline/Middleware/ChainMiddlewareTest.php @@ -23,8 +23,8 @@ public function testChain(): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') - ) + Email::fromString('hallo@patchlevel.de'), + ), ); $child1 = $this->prophesize(Middleware::class); diff --git a/tests/Unit/Pipeline/Middleware/ExcludeArchivedEventMiddlewareTest.php b/tests/Unit/Pipeline/Middleware/ExcludeArchivedEventMiddlewareTest.php index 7a69b97c6..b1d437470 100644 --- a/tests/Unit/Pipeline/Middleware/ExcludeArchivedEventMiddlewareTest.php +++ b/tests/Unit/Pipeline/Middleware/ExcludeArchivedEventMiddlewareTest.php @@ -21,8 +21,8 @@ public function testExcludedEvent(): void $message = Message::create( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') - ) + Email::fromString('hallo@patchlevel.de'), + ), )->withArchived(true); $result = $middleware($message); @@ -37,8 +37,8 @@ public function testIncludeEvent(): void $message = Message::create( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') - ) + Email::fromString('hallo@patchlevel.de'), + ), )->withArchived(false); $result = $middleware($message); diff --git a/tests/Unit/Pipeline/Middleware/ExcludeEventMiddlewareTest.php b/tests/Unit/Pipeline/Middleware/ExcludeEventMiddlewareTest.php index a42d6515c..80cfdefe9 100644 --- a/tests/Unit/Pipeline/Middleware/ExcludeEventMiddlewareTest.php +++ b/tests/Unit/Pipeline/Middleware/ExcludeEventMiddlewareTest.php @@ -22,8 +22,8 @@ public function testDeleteEvent(): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') - ) + Email::fromString('hallo@patchlevel.de'), + ), ); $result = $middleware($message); @@ -37,8 +37,8 @@ public function testSkipEvent(): void $message = new Message( new ProfileVisited( - ProfileId::fromString('1') - ) + ProfileId::fromString('1'), + ), ); $result = $middleware($message); diff --git a/tests/Unit/Pipeline/Middleware/FilterEventMiddlewareTest.php b/tests/Unit/Pipeline/Middleware/FilterEventMiddlewareTest.php index c9f2bbc4d..8e7077f88 100644 --- a/tests/Unit/Pipeline/Middleware/FilterEventMiddlewareTest.php +++ b/tests/Unit/Pipeline/Middleware/FilterEventMiddlewareTest.php @@ -24,8 +24,8 @@ public function testPositive(): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') - ) + Email::fromString('hallo@patchlevel.de'), + ), ); $result = $middleware($message); @@ -41,8 +41,8 @@ public function testNegative(): void $message = new Message( new ProfileVisited( - ProfileId::fromString('1') - ) + ProfileId::fromString('1'), + ), ); $result = $middleware($message); diff --git a/tests/Unit/Pipeline/Middleware/IncludeEventMiddlewareTest.php b/tests/Unit/Pipeline/Middleware/IncludeEventMiddlewareTest.php index 00084b326..58b8ce9cc 100644 --- a/tests/Unit/Pipeline/Middleware/IncludeEventMiddlewareTest.php +++ b/tests/Unit/Pipeline/Middleware/IncludeEventMiddlewareTest.php @@ -22,8 +22,8 @@ public function testFilterEvent(): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') - ) + Email::fromString('hallo@patchlevel.de'), + ), ); $result = $middleware($message); @@ -37,8 +37,8 @@ public function testSkipEvent(): void $message = new Message( new ProfileVisited( - ProfileId::fromString('1') - ) + ProfileId::fromString('1'), + ), ); $result = $middleware($message); diff --git a/tests/Unit/Pipeline/Middleware/OnlyArchivedEventMiddlewareTest.php b/tests/Unit/Pipeline/Middleware/OnlyArchivedEventMiddlewareTest.php index 44823d921..b379d77e7 100644 --- a/tests/Unit/Pipeline/Middleware/OnlyArchivedEventMiddlewareTest.php +++ b/tests/Unit/Pipeline/Middleware/OnlyArchivedEventMiddlewareTest.php @@ -21,8 +21,8 @@ public function testExcludedEvent(): void $message = Message::create( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') - ) + Email::fromString('hallo@patchlevel.de'), + ), )->withArchived(false); $result = $middleware($message); @@ -37,8 +37,8 @@ public function testIncludeEvent(): void $message = Message::create( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') - ) + Email::fromString('hallo@patchlevel.de'), + ), )->withArchived(true); $result = $middleware($message); diff --git a/tests/Unit/Pipeline/Middleware/RecalculatePlayheadMiddlewareTest.php b/tests/Unit/Pipeline/Middleware/RecalculatePlayheadMiddlewareTest.php index 4cb790c56..fe82c0ea1 100644 --- a/tests/Unit/Pipeline/Middleware/RecalculatePlayheadMiddlewareTest.php +++ b/tests/Unit/Pipeline/Middleware/RecalculatePlayheadMiddlewareTest.php @@ -21,7 +21,7 @@ public function testReculatePlayhead(): void $event = new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') + Email::fromString('hallo@patchlevel.de'), ); $message = Message::create($event) @@ -42,7 +42,7 @@ public function testReculatePlayheadWithSamePlayhead(): void $event = new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') + Email::fromString('hallo@patchlevel.de'), ); $message = Message::create($event) diff --git a/tests/Unit/Pipeline/Middleware/ReplaceEventMiddlewareTest.php b/tests/Unit/Pipeline/Middleware/ReplaceEventMiddlewareTest.php index 91554bb05..8d724ca6a 100644 --- a/tests/Unit/Pipeline/Middleware/ReplaceEventMiddlewareTest.php +++ b/tests/Unit/Pipeline/Middleware/ReplaceEventMiddlewareTest.php @@ -22,16 +22,16 @@ public function testReplace(): void ProfileCreated::class, static function (ProfileCreated $event) { return new ProfileVisited( - $event->profileId + $event->profileId, ); - } + }, ); $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') - ) + Email::fromString('hallo@patchlevel.de'), + ), ); $result = $middleware($message); @@ -50,16 +50,16 @@ public function testReplaceInvalidClass(): void MessagePublished::class, static function (ProfileCreated $event) { return new ProfileVisited( - $event->profileId + $event->profileId, ); - } + }, ); $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') - ) + Email::fromString('hallo@patchlevel.de'), + ), ); $result = $middleware($message); diff --git a/tests/Unit/Pipeline/Middleware/UntilEventMiddlewareTest.php b/tests/Unit/Pipeline/Middleware/UntilEventMiddlewareTest.php index 89c0f3f11..551815b2b 100644 --- a/tests/Unit/Pipeline/Middleware/UntilEventMiddlewareTest.php +++ b/tests/Unit/Pipeline/Middleware/UntilEventMiddlewareTest.php @@ -24,8 +24,8 @@ public function testPositive(): void $message = Message::create( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), )->withRecordedOn(new DateTimeImmutable('2020-02-01 00:00:00')); $result = $middleware($message); @@ -42,8 +42,8 @@ public function testNegative(): void $message = Message::create( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') - ) + Email::fromString('info@patchlevel.de'), + ), )->withRecordedOn(new DateTimeImmutable('2020-02-01 00:00:00')); $result = $middleware($message); diff --git a/tests/Unit/Pipeline/PipelineTest.php b/tests/Unit/Pipeline/PipelineTest.php index b76162712..8a830f768 100644 --- a/tests/Unit/Pipeline/PipelineTest.php +++ b/tests/Unit/Pipeline/PipelineTest.php @@ -47,7 +47,7 @@ public function testPipelineWithMiddleware(): void [ new ExcludeEventMiddleware([ProfileCreated::class]), new RecalculatePlayheadMiddleware(), - ] + ], ); self::assertSame(5, $pipeline->count()); @@ -71,17 +71,15 @@ public function testPipelineWithMiddleware(): void self::assertSame(1, $resultMessages[2]->playhead()); } - /** - * @return list - */ + /** @return list */ private function messages(): array { return [ Message::create( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') - ) + Email::fromString('hallo@patchlevel.de'), + ), ) ->withAggregateClass(Profile::class) ->withAggregateId('1') @@ -89,8 +87,8 @@ private function messages(): array Message::create( new ProfileVisited( - ProfileId::fromString('1') - ) + ProfileId::fromString('1'), + ), ) ->withAggregateClass(Profile::class) ->withAggregateId('1') @@ -98,8 +96,8 @@ private function messages(): array Message::create( new ProfileVisited( - ProfileId::fromString('1') - ) + ProfileId::fromString('1'), + ), ) ->withAggregateClass(Profile::class) ->withAggregateId('1') @@ -108,8 +106,8 @@ private function messages(): array Message::create( new ProfileCreated( ProfileId::fromString('2'), - Email::fromString('hallo@patchlevel.de') - ) + Email::fromString('hallo@patchlevel.de'), + ), ) ->withAggregateClass(Profile::class) ->withAggregateId('2') @@ -117,8 +115,8 @@ private function messages(): array Message::create( new ProfileVisited( - ProfileId::fromString('2') - ) + ProfileId::fromString('2'), + ), ) ->withAggregateClass(Profile::class) ->withAggregateId('2') diff --git a/tests/Unit/Pipeline/Source/InMemorySourceTest.php b/tests/Unit/Pipeline/Source/InMemorySourceTest.php index d6b79a28b..94d2f7001 100644 --- a/tests/Unit/Pipeline/Source/InMemorySourceTest.php +++ b/tests/Unit/Pipeline/Source/InMemorySourceTest.php @@ -17,7 +17,7 @@ final class InMemorySourceTest extends TestCase public function testLoad(): void { $message = new Message( - new ProfileCreated(ProfileId::fromString('1'), Email::fromString('foo@test.com')) + new ProfileCreated(ProfileId::fromString('1'), Email::fromString('foo@test.com')), ); $source = new InMemorySource([$message]); @@ -34,7 +34,7 @@ public function testLoad(): void public function testCount(): void { $message = new Message( - new ProfileCreated(ProfileId::fromString('1'), Email::fromString('foo@test.com')) + new ProfileCreated(ProfileId::fromString('1'), Email::fromString('foo@test.com')), ); $source = new InMemorySource([$message]); diff --git a/tests/Unit/Pipeline/Source/StoreSourceTest.php b/tests/Unit/Pipeline/Source/StoreSourceTest.php index d564eaeb7..14e6e0564 100644 --- a/tests/Unit/Pipeline/Source/StoreSourceTest.php +++ b/tests/Unit/Pipeline/Source/StoreSourceTest.php @@ -22,7 +22,7 @@ final class StoreSourceTest extends TestCase public function testLoad(): void { $message = new Message( - new ProfileCreated(ProfileId::fromString('1'), Email::fromString('foo@test.com')) + new ProfileCreated(ProfileId::fromString('1'), Email::fromString('foo@test.com')), ); $generatorFactory = static function () use ($message): Generator { @@ -46,7 +46,7 @@ public function testLoad(): void public function testLoadWithFromIndex(): void { $message = new Message( - new ProfileCreated(ProfileId::fromString('1'), Email::fromString('foo@test.com')) + new ProfileCreated(ProfileId::fromString('1'), Email::fromString('foo@test.com')), ); $generatorFactory = static function () use ($message): Generator { diff --git a/tests/Unit/Pipeline/Target/InMemoryTargetTest.php b/tests/Unit/Pipeline/Target/InMemoryTargetTest.php index c76659974..b56e08fcf 100644 --- a/tests/Unit/Pipeline/Target/InMemoryTargetTest.php +++ b/tests/Unit/Pipeline/Target/InMemoryTargetTest.php @@ -19,7 +19,7 @@ public function testSave(): void $inMemoryTarget = new InMemoryTarget(); $message = new Message( - new ProfileCreated(ProfileId::fromString('1'), Email::fromString('foo@test.com')) + new ProfileCreated(ProfileId::fromString('1'), Email::fromString('foo@test.com')), ); $inMemoryTarget->save($message); diff --git a/tests/Unit/Pipeline/Target/ProjectionHandlerTargetTest.php b/tests/Unit/Pipeline/Target/ProjectionHandlerTargetTest.php index a62fae006..e75f20bd2 100644 --- a/tests/Unit/Pipeline/Target/ProjectionHandlerTargetTest.php +++ b/tests/Unit/Pipeline/Target/ProjectionHandlerTargetTest.php @@ -21,7 +21,7 @@ final class ProjectionHandlerTargetTest extends TestCase public function testSave(): void { $message = new Message( - new ProfileCreated(ProfileId::fromString('1'), Email::fromString('foo@test.com')) + new ProfileCreated(ProfileId::fromString('1'), Email::fromString('foo@test.com')), ); $projectionHandler = $this->prophesize(ProjectionHandler::class); diff --git a/tests/Unit/Pipeline/Target/ProjectionTargetTest.php b/tests/Unit/Pipeline/Target/ProjectionTargetTest.php index 1c2d59692..6dee56170 100644 --- a/tests/Unit/Pipeline/Target/ProjectionTargetTest.php +++ b/tests/Unit/Pipeline/Target/ProjectionTargetTest.php @@ -24,11 +24,11 @@ public function testSave(): void $event = new ProfileCreated(ProfileId::fromString('1'), Email::fromString('foo@test.com')); $message = new Message( - $event + $event, ); $projection = new class implements Projection { - public static ?Message $handledMessage = null; + public static Message|null $handledMessage = null; #[Handle(ProfileCreated::class)] public function handleProfileCreated(Message $message): void diff --git a/tests/Unit/Pipeline/Target/StoreTargetTest.php b/tests/Unit/Pipeline/Target/StoreTargetTest.php index ee3456513..58c37f9d2 100644 --- a/tests/Unit/Pipeline/Target/StoreTargetTest.php +++ b/tests/Unit/Pipeline/Target/StoreTargetTest.php @@ -21,7 +21,7 @@ final class StoreTargetTest extends TestCase public function testSave(): void { $message = new Message( - new ProfileCreated(ProfileId::fromString('1'), Email::fromString('foo@test.com')) + new ProfileCreated(ProfileId::fromString('1'), Email::fromString('foo@test.com')), ); $pipelineStore = $this->prophesize(PipelineStore::class); diff --git a/tests/Unit/Projection/DummyStore.php b/tests/Unit/Projection/DummyStore.php index 9afa278f3..423b16dc8 100644 --- a/tests/Unit/Projection/DummyStore.php +++ b/tests/Unit/Projection/DummyStore.php @@ -22,9 +22,7 @@ final class DummyStore implements ProjectionStore /** @var list */ public array $removedProjectionIds = []; - /** - * @param list $projections - */ + /** @param list $projections */ public function __construct(array $projections = []) { foreach ($projections as $projection) { diff --git a/tests/Unit/Projection/MetadataAwareProjectionHandlerTest.php b/tests/Unit/Projection/MetadataAwareProjectionHandlerTest.php index fd15b9e3d..273a7bc72 100644 --- a/tests/Unit/Projection/MetadataAwareProjectionHandlerTest.php +++ b/tests/Unit/Projection/MetadataAwareProjectionHandlerTest.php @@ -26,11 +26,11 @@ public function testHandleWithNoProjections(): void { $event = new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('profile@test.com') + Email::fromString('profile@test.com'), ); $message = new Message( - $event + $event, ); $projectionRepository = new MetadataAwareProjectionHandler([]); @@ -42,7 +42,7 @@ public function testHandleWithNoProjections(): void public function testHandle(): void { $projection = new class implements Projection { - public static ?Message $handledMessage = null; + public static Message|null $handledMessage = null; #[Handle(ProfileCreated::class)] public function handleProfileCreated(Message $message): void @@ -53,11 +53,11 @@ public function handleProfileCreated(Message $message): void $event = new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('profile@test.com') + Email::fromString('profile@test.com'), ); $message = new Message( - $event + $event, ); $projectionRepository = new MetadataAwareProjectionHandler([$projection]); @@ -69,7 +69,7 @@ public function handleProfileCreated(Message $message): void public function testHandleNotSupportedEvent(): void { $projection = new class implements Projection { - public static ?Message $handledMessage = null; + public static Message|null $handledMessage = null; #[Handle(ProfileCreated::class)] public function handleProfileCreated(Message $message): void @@ -79,11 +79,11 @@ public function handleProfileCreated(Message $message): void }; $event = new ProfileVisited( - ProfileId::fromString('1') + ProfileId::fromString('1'), ); $message = new Message( - $event + $event, ); $projectionRepository = new MetadataAwareProjectionHandler([$projection]); diff --git a/tests/Unit/Projection/Projection/ProjectionCollectionTest.php b/tests/Unit/Projection/Projection/ProjectionCollectionTest.php index 56d3c9e57..e31db42c9 100644 --- a/tests/Unit/Projection/Projection/ProjectionCollectionTest.php +++ b/tests/Unit/Projection/Projection/ProjectionCollectionTest.php @@ -79,17 +79,17 @@ public function testLowestProjectionPosition(): void new Projection( new ProjectionId('foo', 1), ProjectionStatus::Active, - 10 + 10, ), new Projection( new ProjectionId('bar', 1), ProjectionStatus::Active, - 5 + 5, ), new Projection( new ProjectionId('baz', 1), ProjectionStatus::Active, - 15 + 15, ), ]); diff --git a/tests/Unit/Projection/Projection/ProjectionIdTest.php b/tests/Unit/Projection/Projection/ProjectionIdTest.php index 69c133642..4cf0cd3a9 100644 --- a/tests/Unit/Projection/Projection/ProjectionIdTest.php +++ b/tests/Unit/Projection/Projection/ProjectionIdTest.php @@ -16,7 +16,7 @@ public function testProjectionId(): void { $projectionId = new ProjectionId( 'test', - 1 + 1, ); self::assertSame('test', $projectionId->name()); @@ -28,22 +28,22 @@ public function testEquals(): void { $a = new ProjectionId( 'test', - 1 + 1, ); $b = new ProjectionId( 'test', - 1 + 1, ); $c = new ProjectionId( 'foo', - 1 + 1, ); $d = new ProjectionId( 'test', - 2 + 2, ); self::assertTrue($a->equals($b)); @@ -51,9 +51,7 @@ public function testEquals(): void self::assertFalse($a->equals($d)); } - /** - * @dataProvider validFromStringProvider - */ + /** @dataProvider validFromStringProvider */ public function testValidFromString(string $string, string $name, int $version): void { $projectionId = ProjectionId::fromString($string); @@ -63,9 +61,7 @@ public function testValidFromString(string $string, string $name, int $version): self::assertSame($string, $projectionId->toString()); } - /** - * @return Generator - */ + /** @return Generator */ public function validFromStringProvider(): Generator { yield ['hotel-1', 'hotel', 1]; @@ -73,9 +69,7 @@ public function validFromStringProvider(): Generator yield ['hotel-bar--1', 'hotel-bar-', 1]; } - /** - * @dataProvider invalidFromStringProvider - */ + /** @dataProvider invalidFromStringProvider */ public function testInvalidFromString(string $string): void { $this->expectException(InvalidArgumentException::class); @@ -83,9 +77,7 @@ public function testInvalidFromString(string $string): void ProjectionId::fromString($string); } - /** - * @return Generator - */ + /** @return Generator */ public function invalidFromStringProvider(): Generator { yield ['hotel']; diff --git a/tests/Unit/Projection/Projection/ProjectionTest.php b/tests/Unit/Projection/Projection/ProjectionTest.php index 20a362a0d..d5d802c97 100644 --- a/tests/Unit/Projection/Projection/ProjectionTest.php +++ b/tests/Unit/Projection/Projection/ProjectionTest.php @@ -30,7 +30,7 @@ public function testCreate(): void public function testBooting(): void { $projection = new Projection( - new ProjectionId('test', 1) + new ProjectionId('test', 1), ); $projection->booting(); @@ -46,7 +46,7 @@ public function testBooting(): void public function testActive(): void { $projection = new Projection( - new ProjectionId('test', 1) + new ProjectionId('test', 1), ); $projection->active(); @@ -62,7 +62,7 @@ public function testActive(): void public function testError(): void { $projection = new Projection( - new ProjectionId('test', 1) + new ProjectionId('test', 1), ); $projection->error(); @@ -78,7 +78,7 @@ public function testError(): void public function testOutdated(): void { $projection = new Projection( - new ProjectionId('test', 1) + new ProjectionId('test', 1), ); $projection->outdated(); @@ -94,7 +94,7 @@ public function testOutdated(): void public function testIncrementPosition(): void { $projection = new Projection( - new ProjectionId('test', 1) + new ProjectionId('test', 1), ); $projection->incrementPosition(); diff --git a/tests/Unit/Projection/ProjectionListenerTest.php b/tests/Unit/Projection/ProjectionListenerTest.php index bef76aa8e..6c424811c 100644 --- a/tests/Unit/Projection/ProjectionListenerTest.php +++ b/tests/Unit/Projection/ProjectionListenerTest.php @@ -23,8 +23,8 @@ public function testInvoke(): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('foo@bar.com') - ) + Email::fromString('foo@bar.com'), + ), ); $projectionRepository = $this->prophesize(ProjectionHandler::class); diff --git a/tests/Unit/Projection/Projectionist/DefaultProjectionistTest.php b/tests/Unit/Projection/Projectionist/DefaultProjectionistTest.php index 27489ffa5..fb9214d4f 100644 --- a/tests/Unit/Projection/Projectionist/DefaultProjectionistTest.php +++ b/tests/Unit/Projection/Projectionist/DefaultProjectionistTest.php @@ -50,7 +50,7 @@ public function testNothingToBoot(): void $projectionStore->reveal(), $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->boot(); @@ -88,7 +88,7 @@ public function targetProjection(): ProjectionId $projectionStore, $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->boot(); @@ -103,7 +103,7 @@ public function targetProjection(): ProjectionId public function testBootWithMethods(): void { $projector = new class implements VersionedProjector { - public ?Message $message = null; + public Message|null $message = null; public bool $created = false; public function targetProjection(): ProjectionId @@ -145,7 +145,7 @@ public function handle(Message $message): void $projectionStore, $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->boot(); @@ -163,7 +163,7 @@ public function handle(Message $message): void public function testBootWithLimit(): void { $projector = new class implements VersionedProjector { - public ?Message $message = null; + public Message|null $message = null; public bool $created = false; public function targetProjection(): ProjectionId @@ -205,7 +205,7 @@ public function handle(Message $message): void $projectionStore, $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->boot(new ProjectionCriteria(), 1); @@ -222,7 +222,7 @@ public function handle(Message $message): void public function testBootWithCreateError(): void { $projector = new class implements VersionedProjector { - public ?Message $message = null; + public Message|null $message = null; public bool $created = false; public function targetProjection(): ProjectionId @@ -254,7 +254,7 @@ public function create(): void $projectionStore, $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->boot(); @@ -268,7 +268,7 @@ public function create(): void public function testRunning(): void { $projector = new class implements VersionedProjector { - public ?Message $message = null; + public Message|null $message = null; public function targetProjection(): ProjectionId { @@ -303,7 +303,7 @@ public function handle(Message $message): void $projectionStore, $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->run(); @@ -318,7 +318,7 @@ public function handle(Message $message): void public function testRunningWithLimit(): void { $projector = new class implements VersionedProjector { - public ?Message $message = null; + public Message|null $message = null; public function targetProjection(): ProjectionId { @@ -355,7 +355,7 @@ public function handle(Message $message): void $projectionStore, $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->run(new ProjectionCriteria(), 1); @@ -370,7 +370,7 @@ public function handle(Message $message): void public function testRunningWithSkip(): void { $projector1 = new class implements VersionedProjector { - public ?Message $message = null; + public Message|null $message = null; public function targetProjection(): ProjectionId { @@ -384,7 +384,7 @@ public function handle(Message $message): void }; $projector2 = new class implements VersionedProjector { - public ?Message $message = null; + public Message|null $message = null; public function targetProjection(): ProjectionId { @@ -422,7 +422,7 @@ public function handle(Message $message): void $projectionStore, $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->run(); @@ -471,7 +471,7 @@ public function handle(Message $message): void $projectionStore, $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->run(); @@ -500,7 +500,7 @@ public function testRunningMarkOutdated(): void $projectionStore, $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->run(); @@ -513,7 +513,7 @@ public function testRunningMarkOutdated(): void public function testRunningWithoutActiveProjectors(): void { $projector = new class implements VersionedProjector { - public ?Message $message = null; + public Message|null $message = null; public function targetProjection(): ProjectionId { @@ -541,7 +541,7 @@ public function handle(Message $message): void $projectionStore, $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->run(); @@ -552,7 +552,7 @@ public function handle(Message $message): void public function testTeardownWithProjector(): void { $projector = new class implements VersionedProjector { - public ?Message $message = null; + public Message|null $message = null; public bool $dropped = false; public function targetProjection(): ProjectionId @@ -581,7 +581,7 @@ public function drop(): void $projectionStore, $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->teardown(); @@ -594,7 +594,7 @@ public function drop(): void public function testTeardownWithProjectorAndError(): void { $projector = new class implements VersionedProjector { - public ?Message $message = null; + public Message|null $message = null; public bool $dropped = false; public function targetProjection(): ProjectionId @@ -623,7 +623,7 @@ public function drop(): void $projectionStore, $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->teardown(); @@ -650,7 +650,7 @@ public function testTeardownWithoutProjector(): void $projectionStore, $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->teardown(); @@ -690,7 +690,7 @@ public function drop(): void $projectionStore, $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->remove(); @@ -724,7 +724,7 @@ public function targetProjection(): ProjectionId $projectionStore, $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->remove(); @@ -764,7 +764,7 @@ public function drop(): void $projectionStore, $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->remove(); @@ -791,7 +791,7 @@ public function testRemoveWithoutProjector(): void $projectionStore, $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->remove(); @@ -823,7 +823,7 @@ public function targetProjection(): ProjectionId $projectionStore, $projectorRepository->reveal(), $projectorResolver->reveal(), - new NullLogger() + new NullLogger(), ); $projectionist->reactivate(); diff --git a/tests/Unit/Projection/Projectionist/RunProjectionistEventBusWrapperTest.php b/tests/Unit/Projection/Projectionist/RunProjectionistEventBusWrapperTest.php index a4509b816..28c19a68b 100644 --- a/tests/Unit/Projection/Projectionist/RunProjectionistEventBusWrapperTest.php +++ b/tests/Unit/Projection/Projectionist/RunProjectionistEventBusWrapperTest.php @@ -37,7 +37,7 @@ public function testDispatch(): void $eventBus = new RunProjectionistEventBusWrapper( $parentEventBus->reveal(), - $projectionist->reveal() + $projectionist->reveal(), ); $eventBus->dispatch(...$messages); diff --git a/tests/Unit/Projection/Projector/MetadataProjectorResolverTest.php b/tests/Unit/Projection/Projector/MetadataProjectorResolverTest.php index 78e8784dd..09b4b77a9 100644 --- a/tests/Unit/Projection/Projector/MetadataProjectorResolverTest.php +++ b/tests/Unit/Projection/Projector/MetadataProjectorResolverTest.php @@ -22,7 +22,7 @@ final class MetadataProjectorResolverTest extends TestCase public function testResolveHandleMethod(): void { $projection = new class implements Projector { - public static ?Message $handledMessage = null; + public static Message|null $handledMessage = null; #[Handle(ProfileCreated::class)] public function handleProfileCreated(Message $message): void @@ -34,8 +34,8 @@ public function handleProfileCreated(Message $message): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('profile@test.com') - ) + Email::fromString('profile@test.com'), + ), ); $resolver = new MetadataProjectorResolver(); @@ -55,8 +55,8 @@ public function testNotResolveHandleMethod(): void $message = new Message( new ProfileVisited( - ProfileId::fromString('1') - ) + ProfileId::fromString('1'), + ), ); $resolver = new MetadataProjectorResolver(); diff --git a/tests/Unit/Projection/Projector/ProjectorHelperTest.php b/tests/Unit/Projection/Projector/ProjectorHelperTest.php index a3d1acfff..2242d5420 100644 --- a/tests/Unit/Projection/Projector/ProjectorHelperTest.php +++ b/tests/Unit/Projection/Projector/ProjectorHelperTest.php @@ -22,7 +22,7 @@ final class ProjectorHelperTest extends TestCase public function testHandle(): void { $projector = new class implements Projector { - public static ?Message $handledMessage = null; + public static Message|null $handledMessage = null; #[Handle(ProfileCreated::class)] public function handleProfileCreated(Message $message): void @@ -33,11 +33,11 @@ public function handleProfileCreated(Message $message): void $event = new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('profile@test.com') + Email::fromString('profile@test.com'), ); $message = new Message( - $event + $event, ); $helper = new ProjectorHelper(); @@ -49,7 +49,7 @@ public function handleProfileCreated(Message $message): void public function testHandleNotSupportedEvent(): void { $projector = new class implements Projector { - public static ?Message $handledMessage = null; + public static Message|null $handledMessage = null; #[Handle(ProfileCreated::class)] public function handleProfileCreated(Message $message): void @@ -59,11 +59,11 @@ public function handleProfileCreated(Message $message): void }; $event = new ProfileVisited( - ProfileId::fromString('1') + ProfileId::fromString('1'), ); $message = new Message( - $event + $event, ); $helper = new ProjectorHelper(); diff --git a/tests/Unit/Projection/Projector/SyncProjectorListenerTest.php b/tests/Unit/Projection/Projector/SyncProjectorListenerTest.php index 5f71fa7da..64cbe8915 100644 --- a/tests/Unit/Projection/Projector/SyncProjectorListenerTest.php +++ b/tests/Unit/Projection/Projector/SyncProjectorListenerTest.php @@ -23,7 +23,7 @@ final class SyncProjectorListenerTest extends TestCase public function testMethodHandle(): void { $projector = new class implements Projector { - public ?Message $message = null; + public Message|null $message = null; public function handleProfileCreated(Message $message): void { @@ -34,8 +34,8 @@ public function handleProfileCreated(Message $message): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('foo@bar.com') - ) + Email::fromString('foo@bar.com'), + ), ); $projectorRepository = $this->prophesize(ProjectorRepository::class); @@ -46,7 +46,7 @@ public function handleProfileCreated(Message $message): void $projectionListener = new SyncProjectorListener( $projectorRepository->reveal(), - $resolver->reveal() + $resolver->reveal(), ); $projectionListener($message); @@ -57,7 +57,7 @@ public function handleProfileCreated(Message $message): void public function testNoMethod(): void { $projector = new class implements Projector { - public ?Message $message = null; + public Message|null $message = null; public function handleProfileCreated(Message $message): void { @@ -68,8 +68,8 @@ public function handleProfileCreated(Message $message): void $message = new Message( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('foo@bar.com') - ) + Email::fromString('foo@bar.com'), + ), ); $projectorRepository = $this->prophesize(ProjectorRepository::class); @@ -80,7 +80,7 @@ public function handleProfileCreated(Message $message): void $projectionListener = new SyncProjectorListener( $projectorRepository->reveal(), - $resolver->reveal() + $resolver->reveal(), ); $projectionListener($message); diff --git a/tests/Unit/Repository/DefaultRepositoryManagerTest.php b/tests/Unit/Repository/DefaultRepositoryManagerTest.php index dea51d4a9..64a782f1a 100644 --- a/tests/Unit/Repository/DefaultRepositoryManagerTest.php +++ b/tests/Unit/Repository/DefaultRepositoryManagerTest.php @@ -30,7 +30,7 @@ public function testGetNewRepository(): void 'profile2' => ProfileWithSnapshot::class, ]), $store->reveal(), - $eventBus->reveal() + $eventBus->reveal(), ); $repository1 = $repositoryManager->get(Profile::class); @@ -47,7 +47,7 @@ public function testSameRepository(): void $repositoryManager = new DefaultRepositoryManager( new AggregateRootRegistry(['profile' => Profile::class]), $store->reveal(), - $eventBus->reveal() + $eventBus->reveal(), ); $repository1 = $repositoryManager->get(Profile::class); @@ -66,7 +66,7 @@ public function testNotDefined(): void $repositoryManager = new DefaultRepositoryManager( new AggregateRootRegistry([]), $store->reveal(), - $eventBus->reveal() + $eventBus->reveal(), ); $repositoryManager->get(Profile::class); diff --git a/tests/Unit/Repository/DefaultRepositoryTest.php b/tests/Unit/Repository/DefaultRepositoryTest.php index f538344ac..4ef04145a 100644 --- a/tests/Unit/Repository/DefaultRepositoryTest.php +++ b/tests/Unit/Repository/DefaultRepositoryTest.php @@ -56,7 +56,7 @@ public function testSaveAggregate(): void } return $message->playhead() === 2; - }) + }), )->shouldBeCalled(); $eventBus = $this->prophesize(EventBus::class); @@ -82,7 +82,7 @@ public function testSaveAggregate(): void } return $message->playhead() === 2; - }) + }), )->shouldBeCalled(); $repository = new DefaultRepository( @@ -93,7 +93,7 @@ public function testSaveAggregate(): void $aggregate = Profile::createProfile( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') + Email::fromString('hallo@patchlevel.de'), ); $aggregate->visitProfile(ProfileId::fromString('2')); @@ -115,7 +115,7 @@ public function testUpdateAggregate(): void } return $message->playhead() === 2; - }) + }), )->shouldBeCalled(); $eventBus = $this->prophesize(EventBus::class); @@ -130,7 +130,7 @@ public function testUpdateAggregate(): void } return $message->playhead() === 2; - }) + }), )->shouldBeCalled(); $repository = new DefaultRepository( @@ -141,7 +141,7 @@ public function testUpdateAggregate(): void $aggregate = Profile::createProfile( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') + Email::fromString('hallo@patchlevel.de'), ); $aggregate->releaseEvents(); // clear events @@ -169,7 +169,7 @@ public function testDecorator(): void } return $message->playhead() === 2; - }) + }), )->shouldBeCalled(); $eventBus = $this->prophesize(EventBus::class); @@ -188,7 +188,7 @@ public function testDecorator(): void } return $message->playhead() === 2; - }) + }), )->shouldBeCalled(); $decorator = new class implements MessageDecorator { @@ -203,12 +203,12 @@ public function __invoke(Message $message): Message $eventBus->reveal(), Profile::class, null, - $decorator + $decorator, ); $aggregate = Profile::createProfile( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') + Email::fromString('hallo@patchlevel.de'), ); $aggregate->releaseEvents(); // clear events @@ -231,7 +231,7 @@ public function testSaveWrongAggregate(): void $aggregate = ProfileWithSnapshot::createProfile( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') + Email::fromString('hallo@patchlevel.de'), ); $this->expectException(WrongAggregate::class); @@ -244,7 +244,7 @@ public function testSaveAggregateWithEmptyEventStream(): void { $store = $this->prophesize(Store::class); $store->save( - Argument::type(Message::class) + Argument::type(Message::class), )->shouldNotBeCalled(); $eventBus = $this->prophesize(EventBus::class); @@ -258,7 +258,7 @@ public function testSaveAggregateWithEmptyEventStream(): void $aggregate = Profile::createProfile( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') + Email::fromString('hallo@patchlevel.de'), ); $aggregate->releaseEvents(); @@ -306,9 +306,7 @@ public function testSaveAggregateWithSplitStream(): void )->shouldBeCalled(); $store->archiveMessages(Profile::class, '1', 3)->shouldBeCalledOnce(); $store->transactional(Argument::any())->will( - /** - * @param array{0: callable} $args - */ + /** @param array{0: callable} $args */ static fn (array $args): mixed => $args[0]() ); @@ -354,12 +352,12 @@ public function testSaveAggregateWithSplitStream(): void $eventBus->reveal(), Profile::class, null, - new SplitStreamDecorator(new AttributeEventMetadataFactory()) + new SplitStreamDecorator(new AttributeEventMetadataFactory()), ); $aggregate = Profile::createProfile( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') + Email::fromString('hallo@patchlevel.de'), ); $aggregate->visitProfile(ProfileId::fromString('2')); $aggregate->splitIt(); @@ -372,13 +370,13 @@ public function testLoadAggregate(): void $store = $this->prophesize(Store::class); $store->load( Profile::class, - '1' + '1', )->willReturn([ Message::create( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') - ) + Email::fromString('hallo@patchlevel.de'), + ), )->withPlayhead(1), ]); @@ -403,13 +401,13 @@ public function testLoadAggregateTwice(): void $store = $this->prophesize(Store::class); $store->load( Profile::class, - '1' + '1', )->willReturn([ Message::create( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') - ) + Email::fromString('hallo@patchlevel.de'), + ), )->withPlayhead(1), ]); @@ -435,7 +433,7 @@ public function testAggregateNotFound(): void $store = $this->prophesize(Store::class); $store->load( Profile::class, - '1' + '1', )->willReturn([]); $eventBus = $this->prophesize(EventBus::class); @@ -454,7 +452,7 @@ public function testHasAggregate(): void $store = $this->prophesize(Store::class); $store->has( Profile::class, - '1' + '1', )->willReturn(true); $eventBus = $this->prophesize(EventBus::class); @@ -473,7 +471,7 @@ public function testNotHasAggregate(): void $store = $this->prophesize(Store::class); $store->has( Profile::class, - '1' + '1', )->willReturn(false); $eventBus = $this->prophesize(EventBus::class); @@ -491,14 +489,14 @@ public function testLoadAggregateWithSnapshot(): void { $profile = ProfileWithSnapshot::createProfile( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') + Email::fromString('hallo@patchlevel.de'), ); $store = $this->prophesize(Store::class); $store->load( ProfileWithSnapshot::class, '1', - 1 + 1, )->willReturn([]); $eventBus = $this->prophesize(EventBus::class); @@ -506,14 +504,14 @@ public function testLoadAggregateWithSnapshot(): void $snapshotStore = $this->prophesize(SnapshotStore::class); $snapshotStore->load( ProfileWithSnapshot::class, - '1' + '1', )->willReturn($profile); $repository = new DefaultRepository( $store->reveal(), $eventBus->reveal(), ProfileWithSnapshot::class, - $snapshotStore->reveal() + $snapshotStore->reveal(), ); $aggregate = $repository->load('1'); @@ -529,26 +527,26 @@ public function testLoadAggregateWithSnapshotFirstTime(): void $store = $this->prophesize(Store::class); $store->load( ProfileWithSnapshot::class, - '1' + '1', )->willReturn( [ Message::create( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') - ) + Email::fromString('hallo@patchlevel.de'), + ), )->withPlayhead(1), Message::create( new ProfileVisited( ProfileId::fromString('1'), - ) + ), )->withPlayhead(2), Message::create( new ProfileVisited( ProfileId::fromString('1'), - ) + ), )->withPlayhead(3), - ] + ], ); $eventBus = $this->prophesize(EventBus::class); @@ -556,7 +554,7 @@ public function testLoadAggregateWithSnapshotFirstTime(): void $snapshotStore = $this->prophesize(SnapshotStore::class); $snapshotStore->load( ProfileWithSnapshot::class, - '1' + '1', )->willThrow(new SnapshotNotFound(ProfileWithSnapshot::class, '1')); $snapshotStore->save(Argument::type(ProfileWithSnapshot::class))->shouldBeCalled(); @@ -565,7 +563,7 @@ public function testLoadAggregateWithSnapshotFirstTime(): void $store->reveal(), $eventBus->reveal(), ProfileWithSnapshot::class, - $snapshotStore->reveal() + $snapshotStore->reveal(), ); $aggregate = $repository->load('1'); @@ -580,29 +578,29 @@ public function testLoadAggregateWithSnapshotAndSaveNewVersion(): void { $profile = ProfileWithSnapshot::createProfile( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') + Email::fromString('hallo@patchlevel.de'), ); $store = $this->prophesize(Store::class); $store->load( ProfileWithSnapshot::class, '1', - 1 + 1, )->willReturn([ Message::create( new ProfileVisited( ProfileId::fromString('1'), - ) + ), )->withPlayhead(1), Message::create( new ProfileVisited( ProfileId::fromString('1'), - ) + ), )->withPlayhead(2), Message::create( new ProfileVisited( ProfileId::fromString('1'), - ) + ), )->withPlayhead(3), ]); @@ -611,7 +609,7 @@ public function testLoadAggregateWithSnapshotAndSaveNewVersion(): void $snapshotStore = $this->prophesize(SnapshotStore::class); $snapshotStore->load( ProfileWithSnapshot::class, - '1' + '1', )->willReturn($profile); $snapshotStore->save($profile)->shouldBeCalled(); @@ -620,7 +618,7 @@ public function testLoadAggregateWithSnapshotAndSaveNewVersion(): void $store->reveal(), $eventBus->reveal(), ProfileWithSnapshot::class, - $snapshotStore->reveal() + $snapshotStore->reveal(), ); $aggregate = $repository->load('1'); @@ -638,8 +636,8 @@ public function testLoadAggregateWithoutSnapshot(): void Message::create( new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('hallo@patchlevel.de') - ) + Email::fromString('hallo@patchlevel.de'), + ), )->withPlayhead(1), ]); @@ -653,7 +651,7 @@ public function testLoadAggregateWithoutSnapshot(): void $store->reveal(), $eventBus->reveal(), ProfileWithSnapshot::class, - $snapshotStore->reveal() + $snapshotStore->reveal(), ); $aggregate = $repository->load('1'); diff --git a/tests/Unit/Schema/DoctrineSchemaDirectorTest.php b/tests/Unit/Schema/DoctrineSchemaDirectorTest.php index f92c026a3..40ffd4ffe 100644 --- a/tests/Unit/Schema/DoctrineSchemaDirectorTest.php +++ b/tests/Unit/Schema/DoctrineSchemaDirectorTest.php @@ -39,7 +39,7 @@ public function testCreate(): void $doctrineSchemaManager = new DoctrineSchemaDirector( $connection->reveal(), - $schemaConfigurator->reveal() + $schemaConfigurator->reveal(), ); $doctrineSchemaManager->create(); @@ -63,7 +63,7 @@ public function testDryRunCreate(): void $doctrineSchemaManager = new DoctrineSchemaDirector( $connection->reveal(), - $schemaConfigurator->reveal() + $schemaConfigurator->reveal(), ); $sqlStatements = $doctrineSchemaManager->dryRunCreate(); @@ -102,7 +102,7 @@ public function testUpdate(): void $doctrineSchemaManager = new DoctrineSchemaDirector( $connection->reveal(), - $schemaConfigurator->reveal() + $schemaConfigurator->reveal(), ); $doctrineSchemaManager->update(); @@ -139,7 +139,7 @@ public function testDryRunUpdate(): void $doctrineSchemaManager = new DoctrineSchemaDirector( $connection->reveal(), - $schemaConfigurator->reveal() + $schemaConfigurator->reveal(), ); $sqlStatements = $doctrineSchemaManager->dryRunUpdate(); @@ -173,7 +173,7 @@ public function testDrop(): void $doctrineSchemaManager = new DoctrineSchemaDirector( $connection->reveal(), - $schemaConfigurator->reveal() + $schemaConfigurator->reveal(), ); $doctrineSchemaManager->drop(); @@ -202,7 +202,7 @@ public function testDryRunDrop(): void $doctrineSchemaManager = new DoctrineSchemaDirector( $connection->reveal(), - $schemaConfigurator->reveal() + $schemaConfigurator->reveal(), ); $queries = $doctrineSchemaManager->dryRunDrop(); diff --git a/tests/Unit/Schema/DoctrineSchemaManagerTest.php b/tests/Unit/Schema/DoctrineSchemaManagerTest.php index e743ca510..88581dc04 100644 --- a/tests/Unit/Schema/DoctrineSchemaManagerTest.php +++ b/tests/Unit/Schema/DoctrineSchemaManagerTest.php @@ -111,9 +111,7 @@ public function testUpdate(): void $schemaManager->createSchema()->willReturn($fromSchema->reveal()); - /** - * @psalm-suppress InternalMethod - */ + /** @psalm-suppress InternalMethod */ $schemaManager->createComparator()->willReturn(new Comparator()); $connection->createSchemaManager()->willReturn($schemaManager->reveal()); @@ -163,9 +161,7 @@ public function testDryRunUpdate(): void $schemaManager->createSchema()->willReturn($fromSchema->reveal()); - /** - * @psalm-suppress InternalMethod - */ + /** @psalm-suppress InternalMethod */ $schemaManager->createComparator()->willReturn(new Comparator()); $connection->createSchemaManager()->willReturn($schemaManager->reveal()); diff --git a/tests/Unit/Serializer/DefaultEventSerializerTest.php b/tests/Unit/Serializer/DefaultEventSerializerTest.php index ceb4d19e0..c3d4ae3ba 100644 --- a/tests/Unit/Serializer/DefaultEventSerializerTest.php +++ b/tests/Unit/Serializer/DefaultEventSerializerTest.php @@ -31,12 +31,12 @@ public function testSerialize(): void { $event = new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') + Email::fromString('info@patchlevel.de'), ); self::assertEquals( new SerializedEvent('profile_created', '{"profileId":"1","email":"info@patchlevel.de"}'), - $this->serializer->serialize($event) + $this->serializer->serialize($event), ); } @@ -44,14 +44,14 @@ public function testDeserialize(): void { $expected = new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') + Email::fromString('info@patchlevel.de'), ); $event = $this->serializer->deserialize( new SerializedEvent( 'profile_created', - '{"profileId":"1","email":"info@patchlevel.de"}' - ) + '{"profileId":"1","email":"info@patchlevel.de"}', + ), ); self::assertEquals($expected, $event); @@ -74,19 +74,19 @@ public function __invoke(Upcast $upcast): Upcast (new AttributeEventRegistryFactory())->create([__DIR__ . '/../Fixture']), new MetadataEventHydrator(new AttributeEventMetadataFactory()), new JsonEncoder(), - $upcaster + $upcaster, ); $expected = new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') + Email::fromString('info@patchlevel.de'), ); $event = $serializer->deserialize( new SerializedEvent( 'profile_created_old', - '{"profileId":"1"}' - ) + '{"profileId":"1"}', + ), ); self::assertEquals($expected, $event); @@ -120,19 +120,19 @@ public function __invoke(Upcast $upcast): Upcast (new AttributeEventRegistryFactory())->create([__DIR__ . '/../Fixture']), new MetadataEventHydrator(new AttributeEventMetadataFactory()), new JsonEncoder(), - new UpcasterChain([$upcasterOne, $upcasterTwo]) + new UpcasterChain([$upcasterOne, $upcasterTwo]), ); $expected = new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') + Email::fromString('info@patchlevel.de'), ); $event = $serializer->deserialize( new SerializedEvent( 'profile_created_very_old', - '{"id":"1"}' - ) + '{"id":"1"}', + ), ); self::assertEquals($expected, $event); diff --git a/tests/Unit/Serializer/Encoder/JsonEncoderTest.php b/tests/Unit/Serializer/Encoder/JsonEncoderTest.php index 9449b2b42..85af65424 100644 --- a/tests/Unit/Serializer/Encoder/JsonEncoderTest.php +++ b/tests/Unit/Serializer/Encoder/JsonEncoderTest.php @@ -28,7 +28,7 @@ public function testEncode(): void self::assertEquals( '{"profileId":"1","email":"info@patchlevel.de"}', - $this->encoder->encode($data) + $this->encoder->encode($data), ); } @@ -41,7 +41,7 @@ public function testEncodeNotNormalizedData(): void self::assertEquals( '{"profileId":{},"email":{}}', - $this->encoder->encode($data) + $this->encoder->encode($data), ); } diff --git a/tests/Unit/Serializer/Hydrator/MetadataAggregateRootHydratorTest.php b/tests/Unit/Serializer/Hydrator/MetadataAggregateRootHydratorTest.php index 74e08af85..b95ff22e5 100644 --- a/tests/Unit/Serializer/Hydrator/MetadataAggregateRootHydratorTest.php +++ b/tests/Unit/Serializer/Hydrator/MetadataAggregateRootHydratorTest.php @@ -29,12 +29,12 @@ public function testExtract(): void { $aggregate = ProfileWithSnapshot::createProfile( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') + Email::fromString('info@patchlevel.de'), ); self::assertEquals( ['id' => '1', 'email' => 'info@patchlevel.de', 'messages' => [], '_playhead' => 1], - $this->hydrator->extract($aggregate) + $this->hydrator->extract($aggregate), ); } @@ -85,7 +85,7 @@ public function testNormalizationFailure(): void $this->expectException(NormalizationFailure::class); $this->hydrator->extract( - WrongNormalizerAggregate::createFromEvents([]) + WrongNormalizerAggregate::createFromEvents([]), ); } } diff --git a/tests/Unit/Serializer/Hydrator/MetadataEventHydratorTest.php b/tests/Unit/Serializer/Hydrator/MetadataEventHydratorTest.php index da15ffa0e..cbbe4065c 100644 --- a/tests/Unit/Serializer/Hydrator/MetadataEventHydratorTest.php +++ b/tests/Unit/Serializer/Hydrator/MetadataEventHydratorTest.php @@ -28,12 +28,12 @@ public function testExtract(): void { $event = new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') + Email::fromString('info@patchlevel.de'), ); self::assertEquals( ['profileId' => '1', 'email' => 'info@patchlevel.de'], - $this->hydrator->extract($event) + $this->hydrator->extract($event), ); } @@ -41,12 +41,12 @@ public function testHydrate(): void { $expected = new ProfileCreated( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') + Email::fromString('info@patchlevel.de'), ); $event = $this->hydrator->hydrate( ProfileCreated::class, - ['profileId' => '1', 'email' => 'info@patchlevel.de'] + ['profileId' => '1', 'email' => 'info@patchlevel.de'], ); self::assertEquals($expected, $event); @@ -58,7 +58,7 @@ public function testWithTypeMismatch(): void $this->hydrator->hydrate( ProfileCreated::class, - ['profileId' => null, 'email' => null] + ['profileId' => null, 'email' => null], ); } @@ -68,7 +68,7 @@ public function testDenormalizationFailure(): void $this->hydrator->hydrate( ProfileCreated::class, - ['profileId' => 123, 'email' => 123] + ['profileId' => 123, 'email' => 123], ); } @@ -77,7 +77,7 @@ public function testNormalizationFailure(): void $this->expectException(NormalizationFailure::class); $this->hydrator->extract( - new WrongNormalizerEvent(true) + new WrongNormalizerEvent(true), ); } } diff --git a/tests/Unit/Serializer/Upcast/UpcastTest.php b/tests/Unit/Serializer/Upcast/UpcastTest.php index b8505d1f6..deb996189 100644 --- a/tests/Unit/Serializer/Upcast/UpcastTest.php +++ b/tests/Unit/Serializer/Upcast/UpcastTest.php @@ -7,9 +7,7 @@ use Patchlevel\EventSourcing\Serializer\Upcast\Upcast; use PHPUnit\Framework\TestCase; -/** - * @covers Patchlevel\EventSourcing\Serializer\Upcast\Upcast - */ +/** @covers Patchlevel\EventSourcing\Serializer\Upcast\Upcast */ final class UpcastTest extends TestCase { public function testReplaceEventName(): void diff --git a/tests/Unit/Serializer/Upcast/UpcasterChainTest.php b/tests/Unit/Serializer/Upcast/UpcasterChainTest.php index 56bc0a4a1..45637a62a 100644 --- a/tests/Unit/Serializer/Upcast/UpcasterChainTest.php +++ b/tests/Unit/Serializer/Upcast/UpcasterChainTest.php @@ -49,7 +49,7 @@ public function __invoke(Upcast $upcast): Upcast 'bar' => 'baz', 'foo' => 'bar', ], - $upcast->payload + $upcast->payload, ); } } diff --git a/tests/Unit/Snapshot/DefaultSnapshotStoreTest.php b/tests/Unit/Snapshot/DefaultSnapshotStoreTest.php index 9b0701d04..dd656b994 100644 --- a/tests/Unit/Snapshot/DefaultSnapshotStoreTest.php +++ b/tests/Unit/Snapshot/DefaultSnapshotStoreTest.php @@ -27,14 +27,14 @@ public function testSave(): void [ 'version' => '1', 'payload' => ['id' => '1', 'email' => 'info@patchlevel.de', 'messages' => [], '_playhead' => 2], - ] + ], )->shouldBeCalled(); $store = new DefaultSnapshotStore(['memory' => $adapter->reveal()]); $aggregate = ProfileWithSnapshot::createProfile( ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de') + Email::fromString('info@patchlevel.de'), ); $aggregate->visitProfile(ProfileId::fromString('2')); @@ -46,12 +46,12 @@ public function testLoad(): void { $adapter = $this->prophesize(SnapshotAdapter::class); $adapter->load( - 'profile_with_snapshot-1' + 'profile_with_snapshot-1', )->willReturn( [ 'version' => '1', 'payload' => ['id' => '1', 'email' => 'info@patchlevel.de', 'messages' => [], '_playhead' => 2], - ] + ], ); $store = new DefaultSnapshotStore(['memory' => $adapter->reveal()]); @@ -69,7 +69,7 @@ public function testLoadLegacySnapshots(): void $adapter = $this->prophesize(SnapshotAdapter::class); $adapter->load( - 'profile_with_snapshot-1' + 'profile_with_snapshot-1', )->willReturn(['id' => '1', 'email' => 'info@patchlevel.de', 'messages' => [], '_playhead' => 2]); $store = new DefaultSnapshotStore(['memory' => $adapter->reveal()]); @@ -83,12 +83,12 @@ public function testLoadExpiredSnapshot(): void $adapter = $this->prophesize(SnapshotAdapter::class); $adapter->load( - 'profile_with_snapshot-1' + 'profile_with_snapshot-1', )->willReturn( [ 'version' => '2', 'payload' => ['id' => '1', 'email' => 'info@patchlevel.de', 'messages' => [], '_playhead' => 2], - ] + ], ); $store = new DefaultSnapshotStore(['memory' => $adapter->reveal()]); diff --git a/tests/Unit/Snapshot/SnapshotTest.php b/tests/Unit/Snapshot/SnapshotTest.php index 3b7271041..7c558461b 100644 --- a/tests/Unit/Snapshot/SnapshotTest.php +++ b/tests/Unit/Snapshot/SnapshotTest.php @@ -17,7 +17,7 @@ public function testSnapshot(): void ProfileWithSnapshot::class, '1', 1, - ['foo' => 'bar'] + ['foo' => 'bar'], ); self::assertSame(ProfileWithSnapshot::class, $snapshot->aggregate()); diff --git a/tests/Unit/Store/MultiTableStoreTest.php b/tests/Unit/Store/MultiTableStoreTest.php index 443b2f3a8..90ddd8db3 100644 --- a/tests/Unit/Store/MultiTableStoreTest.php +++ b/tests/Unit/Store/MultiTableStoreTest.php @@ -46,7 +46,7 @@ public function testLoadWithNoEvents(): void ], [ 'archived' => Types::BOOLEAN, - ] + ], )->willReturn([]); $connection->createQueryBuilder()->willReturn($queryBuilder); $connection->getDatabasePlatform()->willReturn($this->prophesize(AbstractPlatform::class)->reveal()); @@ -57,7 +57,7 @@ public function testLoadWithNoEvents(): void $connection->reveal(), $serializer->reveal(), new AggregateRootRegistry(['profile' => Profile::class]), - 'eventstore' + 'eventstore', ); $events = $singleTableStore->load(Profile::class, '1'); @@ -78,7 +78,7 @@ public function testLoadWithOneEvent(): void ], [ 'archived' => Types::BOOLEAN, - ] + ], )->willReturn( [ [ @@ -89,7 +89,7 @@ public function testLoadWithOneEvent(): void 'recorded_on' => '2021-02-17 10:00:00', 'custom_headers' => '[]', ], - ] + ], ); $connection->createQueryBuilder()->willReturn($queryBuilder); @@ -107,7 +107,7 @@ public function testLoadWithOneEvent(): void $connection->reveal(), $serializer->reveal(), new AggregateRootRegistry(['profile' => Profile::class]), - 'eventstore' + 'eventstore', ); $messages = $singleTableStore->load(Profile::class, '1'); @@ -132,7 +132,7 @@ public function testTransactionBegin(): void $connection->reveal(), $serializer->reveal(), new AggregateRootRegistry(['profile' => Profile::class]), - 'eventstore' + 'eventstore', ); $store->transactionBegin(); @@ -149,7 +149,7 @@ public function testTransactionCommit(): void $connection->reveal(), $serializer->reveal(), new AggregateRootRegistry(['profile' => Profile::class]), - 'eventstore' + 'eventstore', ); $store->transactionCommit(); @@ -166,7 +166,7 @@ public function testTransactionRollback(): void $connection->reveal(), $serializer->reveal(), new AggregateRootRegistry(['profile' => Profile::class]), - 'eventstore' + 'eventstore', ); $store->transactionRollback(); @@ -186,7 +186,7 @@ public function testTransactional(): void $connection->reveal(), $serializer->reveal(), new AggregateRootRegistry(['profile' => Profile::class]), - 'eventstore' + 'eventstore', ); $store->transactional($callback); @@ -214,7 +214,7 @@ public function testSaveWithOneEvent(): void 'aggregate' => 'profile', 'aggregate_id' => '1', 'playhead' => 1, - ] + ], )->shouldBeCalledOnce(); $innerMockedConnection->lastInsertId()->shouldBeCalledOnce()->willReturn('2'); @@ -248,9 +248,7 @@ public function testSaveWithOneEvent(): void $mockedConnection = $this->prophesize(Connection::class); $mockedConnection->transactional(Argument::any())->will( - /** - * @param array{0: callable} $args - */ + /** @param array{0: callable} $args */ static fn (array $args): mixed => $args[0]($innerMockedConnection->reveal()) ); @@ -258,7 +256,7 @@ public function testSaveWithOneEvent(): void $mockedConnection->reveal(), $serializer->reveal(), new AggregateRootRegistry(['profile' => Profile::class]), - 'eventstore_metadata' + 'eventstore_metadata', ); $multiTableStore->save($message); } @@ -278,14 +276,14 @@ public function testArchiveMessages(): void SET archived = true WHERE aggregate_id = :aggregate_id AND playhead < :playhead - AND archived = false' + AND archived = false', )->shouldBeCalledOnce()->willReturn($statement->reveal()); $multiTableStore = new MultiTableStore( $mockedConnection->reveal(), $serializer->reveal(), new AggregateRootRegistry(['profile' => Profile::class]), - 'eventstore_metadata' + 'eventstore_metadata', ); $multiTableStore->archiveMessages(Profile::class, '1', 1); } diff --git a/tests/Unit/Store/SingleTableStoreTest.php b/tests/Unit/Store/SingleTableStoreTest.php index ee723cffc..e1866123e 100644 --- a/tests/Unit/Store/SingleTableStoreTest.php +++ b/tests/Unit/Store/SingleTableStoreTest.php @@ -47,7 +47,7 @@ public function testLoadWithNoEvents(): void ], [ 'archived' => Types::BOOLEAN, - ] + ], )->willReturn([]); $connection->createQueryBuilder()->willReturn($queryBuilder); $connection->getDatabasePlatform()->willReturn($this->prophesize(AbstractPlatform::class)->reveal()); @@ -58,7 +58,7 @@ public function testLoadWithNoEvents(): void $connection->reveal(), $serializer->reveal(), new AggregateRootRegistry(['profile' => Profile::class]), - 'eventstore' + 'eventstore', ); $events = $singleTableStore->load(Profile::class, '1'); @@ -80,7 +80,7 @@ public function testLoadWithOneEvent(): void ], [ 'archived' => Types::BOOLEAN, - ] + ], )->willReturn( [ [ @@ -91,7 +91,7 @@ public function testLoadWithOneEvent(): void 'recorded_on' => '2021-02-17 10:00:00', 'custom_headers' => '[]', ], - ] + ], ); $connection->createQueryBuilder()->willReturn($queryBuilder); @@ -109,7 +109,7 @@ public function testLoadWithOneEvent(): void $connection->reveal(), $serializer->reveal(), new AggregateRootRegistry(['profile' => Profile::class]), - 'eventstore' + 'eventstore', ); $messages = $singleTableStore->load(Profile::class, '1'); @@ -134,7 +134,7 @@ public function testTransactionBegin(): void $connection->reveal(), $serializer->reveal(), new AggregateRootRegistry(['profile' => Profile::class]), - 'eventstore' + 'eventstore', ); $store->transactionBegin(); @@ -151,7 +151,7 @@ public function testTransactionCommit(): void $connection->reveal(), $serializer->reveal(), new AggregateRootRegistry(['profile' => Profile::class]), - 'eventstore' + 'eventstore', ); $store->transactionCommit(); @@ -168,7 +168,7 @@ public function testTransactionRollback(): void $connection->reveal(), $serializer->reveal(), new AggregateRootRegistry(['profile' => Profile::class]), - 'eventstore' + 'eventstore', ); $store->transactionRollback(); @@ -188,7 +188,7 @@ public function testTransactional(): void $connection->reveal(), $serializer->reveal(), new AggregateRootRegistry(['profile' => Profile::class]), - 'eventstore' + 'eventstore', ); $store->transactional($callback); @@ -228,7 +228,7 @@ public function testSaveWithOneEvent(): void 'custom_headers' => 'json', 'archived' => Types::BOOLEAN, 'new_stream_start' => Types::BOOLEAN, - ] + ], )->shouldBeCalledOnce(); $driver = $this->prophesize(Driver::class); @@ -239,9 +239,7 @@ public function testSaveWithOneEvent(): void $mockedConnection = $this->prophesize(Connection::class); $mockedConnection->transactional(Argument::any())->will( - /** - * @param array{0: callable} $args - */ + /** @param array{0: callable} $args */ static fn (array $args): mixed => $args[0]($innerMockedConnection->reveal()) ); @@ -249,7 +247,7 @@ public function testSaveWithOneEvent(): void $mockedConnection->reveal(), $serializer->reveal(), new AggregateRootRegistry(['profile' => Profile::class]), - 'eventstore' + 'eventstore', ); $singleTableStore->save($message); } @@ -271,14 +269,14 @@ public function testArchiveMessages(): void WHERE aggregate = :aggregate AND aggregate_id = :aggregate_id AND playhead < :playhead - AND archived = false' + AND archived = false', )->shouldBeCalledOnce()->willReturn($statement->reveal()); $singleTableStore = new SingleTableStore( $mockedConnection->reveal(), $serializer->reveal(), new AggregateRootRegistry(['profile' => Profile::class]), - 'eventstore' + 'eventstore', ); $singleTableStore->archiveMessages(Profile::class, '1', 1); } diff --git a/tests/Unit/WatchServer/PhpNativeMessageSerializerTest.php b/tests/Unit/WatchServer/PhpNativeMessageSerializerTest.php index 102f4d077..23df1a614 100644 --- a/tests/Unit/WatchServer/PhpNativeMessageSerializerTest.php +++ b/tests/Unit/WatchServer/PhpNativeMessageSerializerTest.php @@ -22,7 +22,7 @@ final class PhpNativeMessageSerializerTest extends TestCase public function testSerialize(): void { $event = new ProfileVisited( - ProfileId::fromString('foo') + ProfileId::fromString('foo'), ); $message = Message::create($event) @@ -44,7 +44,7 @@ public function testSerialize(): void public function testDeserialize(): void { $event = new ProfileVisited( - ProfileId::fromString('foo') + ProfileId::fromString('foo'), ); $eventSerializer = $this->prophesize(EventSerializer::class); @@ -68,7 +68,7 @@ public function testDeserialize(): void public function testEquals(): void { $event = new ProfileVisited( - ProfileId::fromString('foo') + ProfileId::fromString('foo'), ); $message = Message::create($event)