-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- psalm set to level 3 - [WiP] phpstan set to level 6
- Loading branch information
Showing
17 changed files
with
63 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
parameters: | ||
level: 2 | ||
level: 3 | ||
paths: | ||
- src/ | ||
- tests/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ | |
use Streak\Domain\Id\UUID; | ||
|
||
/** | ||
* @template T of object | ||
* | ||
* @author Alan Gabriel Bem <[email protected]> | ||
*/ | ||
interface Envelope extends ValueObject | ||
|
@@ -24,6 +26,9 @@ public function uuid(): UUID; | |
|
||
public function name(): string; | ||
|
||
/** | ||
* @return T | ||
*/ | ||
public function message(); | ||
|
||
/** | ||
|
@@ -33,5 +38,8 @@ public function message(); | |
*/ | ||
public function get($name); | ||
|
||
/** | ||
* @return array<scalar, scalar> | ||
*/ | ||
public function metadata(): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
* @author Alan Gabriel Bem <[email protected]> | ||
* | ||
* @template T of Event | ||
* @implements Domain\Envelope<T> | ||
* | ||
* @see \Streak\Domain\Event\EnvelopeTest | ||
*/ | ||
|
@@ -51,9 +52,6 @@ public function __construct(UUID $uuid, string $name, private Event $message, Do | |
} | ||
} | ||
|
||
/** | ||
* @return Envelope<T> | ||
*/ | ||
public static function new(Event $message, Domain\Id $producerId, ?int $version = null): self | ||
{ | ||
return new self(UUID::random(), $message::class, $message, $producerId, $producerId, $version); | ||
|
@@ -69,10 +67,7 @@ public function name(): string | |
return $this->get(self::METADATA_NAME); | ||
} | ||
|
||
/** | ||
* @return T | ||
*/ | ||
public function message(): Event | ||
public function message() | ||
{ | ||
return $this->message; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,20 +15,25 @@ | |
|
||
use Streak\Domain\Event; | ||
use Streak\Domain\Event\Exception\InvalidEventGiven; | ||
use Streak\Domain\Event\Listener; | ||
use Streak\Domain\Exception\InvalidIdGiven; | ||
|
||
/** | ||
* @template T of Event\Listener | ||
* | ||
* @author Alan Gabriel Bem <[email protected]> | ||
*/ | ||
interface Factory | ||
{ | ||
/** | ||
* @return T | ||
* | ||
* @throws InvalidIdGiven | ||
*/ | ||
public function create(Listener\Id $id): Listener; | ||
public function create(Event\Listener\Id $id): Event\Listener; | ||
|
||
/** | ||
* @return T | ||
* | ||
* @throws InvalidEventGiven | ||
*/ | ||
public function createFor(Event\Envelope $event): Event\Listener; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,14 @@ | |
use Streak\Domain\Event; | ||
|
||
/** | ||
* @template T of Event\Subscription | ||
* | ||
* @author Alan Gabriel Bem <[email protected]> | ||
*/ | ||
interface Factory | ||
{ | ||
/** | ||
* @return T | ||
*/ | ||
public function create(Event\Listener $listener): Event\Subscription; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ | |
use Streak\Infrastructure\Domain\Event\LoggingListener; | ||
|
||
/** | ||
* @implements Event\Listener\Factory<LoggingListener> | ||
* | ||
* @author Alan Gabriel Bem <[email protected]> | ||
* | ||
* @see \Streak\Infrastructure\Domain\Event\LoggingListener\FactoryTest | ||
|
@@ -28,14 +30,14 @@ public function __construct(private Event\Listener\Factory $factory, private Log | |
{ | ||
} | ||
|
||
public function create(Event\Listener\Id $id): Event\Listener | ||
public function create(Event\Listener\Id $id): LoggingListener | ||
{ | ||
$saga = $this->factory->create($id); | ||
|
||
return new LoggingListener($saga, $this->logger); | ||
} | ||
|
||
public function createFor(Event\Envelope $event): Event\Listener | ||
public function createFor(Event\Envelope $event): LoggingListener | ||
{ | ||
$listener = $this->factory->createFor($event); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ | |
use Streak\Infrastructure\Domain\UnitOfWork; | ||
|
||
/** | ||
* @implements Event\Subscription\Factory<CommittingSubscription> | ||
* | ||
* @author Alan Gabriel Bem <[email protected]> | ||
* | ||
* @see \Streak\Infrastructure\Domain\Event\Subscription\CommittingSubscription\FactoryTest | ||
|
@@ -29,7 +31,7 @@ public function __construct(private Subscription\Factory $factory, private UnitO | |
{ | ||
} | ||
|
||
public function create(Event\Listener $listener): Event\Subscription | ||
public function create(Event\Listener $listener): CommittingSubscription | ||
{ | ||
$subscription = $this->factory->create($listener); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,9 +15,11 @@ | |
|
||
use Streak\Domain\Clock; | ||
use Streak\Domain\Event; | ||
use Streak\Infrastructure\Domain\Event\Subscription\DAO\Subscription; | ||
use Streak\Infrastructure\Domain\Event\Subscription\DAO; | ||
|
||
/** | ||
* @implements Event\Subscription\Factory<DAO\Subscription> | ||
* | ||
* @author Alan Gabriel Bem <[email protected]> | ||
* | ||
* @see \Streak\Infrastructure\Domain\Event\Subscription\DAO\Subscription\FactoryTest | ||
|
@@ -28,8 +30,8 @@ public function __construct(private Clock $clock) | |
{ | ||
} | ||
|
||
public function create(Event\Listener $listener): Event\Subscription | ||
public function create(Event\Listener $listener): DAO\Subscription | ||
{ | ||
return new Subscription($listener, $this->clock); | ||
return new DAO\Subscription($listener, $this->clock); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ | |
use Streak\Infrastructure\Domain\Event\Subscription\DbalTransactionalSubscription; | ||
|
||
/** | ||
* @implements Event\Subscription\Factory<DbalTransactionalSubscription> | ||
* | ||
* @author Alan Gabriel Bem <[email protected]> | ||
* | ||
* @see \Streak\Infrastructure\Domain\Event\Subscription\DbalTransactionalSubscription\FactoryTest | ||
|
@@ -35,7 +37,7 @@ public function __construct(private Event\Subscription\Factory $factory, private | |
$this->maxTransactionSize = $maxTransactionSize; | ||
} | ||
|
||
public function create(Event\Listener $listener): Event\Subscription | ||
public function create(Event\Listener $listener): DbalTransactionalSubscription | ||
{ | ||
$subscription = $this->factory->create($listener); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters