From b293c688f630e6999a7be26a4d2ea30cda35142b Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Sat, 14 Dec 2024 08:50:33 +0100 Subject: [PATCH] Add property types --- src/Doctrine/Event/PreAppendEvent.php | 5 +-- src/Domain/Model/EventId.php | 5 +-- src/Domain/Model/StoredEvent.php | 40 +++++-------------- src/Domain/Model/Traits/DomainEventTrait.php | 14 ++----- .../Model/Traits/EventRecorderTrait.php | 2 +- .../NoEnvelopeDomainEventDispatcher.php | 5 +-- .../PublishDomainEventSubscriber.php | 20 ++-------- 7 files changed, 22 insertions(+), 69 deletions(-) diff --git a/src/Doctrine/Event/PreAppendEvent.php b/src/Doctrine/Event/PreAppendEvent.php index 1e89dc9..6a253ad 100644 --- a/src/Doctrine/Event/PreAppendEvent.php +++ b/src/Doctrine/Event/PreAppendEvent.php @@ -14,10 +14,7 @@ */ class PreAppendEvent extends Event { - /** - * @var DomainEvent - */ - protected $domainEvent; + protected DomainEvent $domainEvent; public function __construct(DomainEvent $domainEvent) { diff --git a/src/Domain/Model/EventId.php b/src/Domain/Model/EventId.php index 2e63ea2..b7a5494 100644 --- a/src/Domain/Model/EventId.php +++ b/src/Domain/Model/EventId.php @@ -17,10 +17,7 @@ final class EventId { - /** - * @var UuidInterface - */ - private $id; + private UuidInterface $id; private function __construct(UuidInterface $id) { diff --git a/src/Domain/Model/StoredEvent.php b/src/Domain/Model/StoredEvent.php index 8e9c156..a90b7f4 100644 --- a/src/Domain/Model/StoredEvent.php +++ b/src/Domain/Model/StoredEvent.php @@ -14,35 +14,17 @@ class StoredEvent { - /** - * @var string - */ - private $eventId; - - /** - * @var \DateTimeImmutable - */ - private $occurredOn; - - /** - * @var \DateTimeImmutable|null - */ - private $publishedOn; - - /** - * @var string - */ - private $aggregateRoot; - - /** - * @var string - */ - private $typeName; - - /** - * @var string - */ - private $eventBody; + private string $eventId; + + private \DateTimeImmutable $occurredOn; + + private \DateTimeImmutable|null $publishedOn; + + private string $aggregateRoot; + + private string $typeName; + + private string $eventBody; public function __construct( EventId $eventId, diff --git a/src/Domain/Model/Traits/DomainEventTrait.php b/src/Domain/Model/Traits/DomainEventTrait.php index b9f4e88..7762e54 100644 --- a/src/Domain/Model/Traits/DomainEventTrait.php +++ b/src/Domain/Model/Traits/DomainEventTrait.php @@ -14,22 +14,14 @@ trait DomainEventTrait { - /** - * @var string - */ - private $aggregateRootId; + private string $aggregateRootId; /** * The datetime the event occurred. Please use DomainEvent::MICROSECOND_DATE_FORMAT format. - * - * @var string */ - private $occurredOn; + private string $occurredOn; - /** - * @var string|null - */ - private $actorId; + private string|null $actorId; public function setActorId(?string $actorId): void { diff --git a/src/Domain/Model/Traits/EventRecorderTrait.php b/src/Domain/Model/Traits/EventRecorderTrait.php index 3612ed1..d5ee769 100644 --- a/src/Domain/Model/Traits/EventRecorderTrait.php +++ b/src/Domain/Model/Traits/EventRecorderTrait.php @@ -19,7 +19,7 @@ trait EventRecorderTrait /** * @var DomainEvent[] */ - private $messages = []; + private array $messages = []; /** * @return DomainEvent[] diff --git a/src/EventSubscriber/NoEnvelopeDomainEventDispatcher.php b/src/EventSubscriber/NoEnvelopeDomainEventDispatcher.php index 92e9e39..801e970 100644 --- a/src/EventSubscriber/NoEnvelopeDomainEventDispatcher.php +++ b/src/EventSubscriber/NoEnvelopeDomainEventDispatcher.php @@ -17,10 +17,7 @@ class NoEnvelopeDomainEventDispatcher implements DomainEventDispatcher { - /** - * @var MessageBusInterface - */ - private $eventBus; + private MessageBusInterface $eventBus; public function __construct(MessageBusInterface $eventBus) { diff --git a/src/EventSubscriber/PublishDomainEventSubscriber.php b/src/EventSubscriber/PublishDomainEventSubscriber.php index 04f2e8d..75aae28 100644 --- a/src/EventSubscriber/PublishDomainEventSubscriber.php +++ b/src/EventSubscriber/PublishDomainEventSubscriber.php @@ -25,25 +25,13 @@ final class PublishDomainEventSubscriber implements EventSubscriberInterface { - /** - * @var DomainEventDispatcher - */ - private $domainEventDispatcher; + private DomainEventDispatcher $domainEventDispatcher; - /** - * @var EventStore - */ - private $eventStore; + private EventStore $eventStore; - /** - * @var SerializerInterface - */ - private $serializer; + private SerializerInterface $serializer; - /** - * @var LockFactory - */ - private $lockFactory; + private LockFactory $lockFactory; public function __construct( DomainEventDispatcher $domainEventDispatcher,