1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Gember\EventSourcing\UseCase; |
||
6 | |||
7 | /** |
||
8 | * @phpstan-require-implements EventSourcedUseCase |
||
9 | */ |
||
10 | trait EventSourcedUseCaseBehaviorTrait |
||
11 | { |
||
12 | private ?string $lastEventId = null; |
||
13 | |||
14 | /** |
||
15 | * @var list<object> |
||
0 ignored issues
–
show
|
|||
16 | */ |
||
17 | private array $appliedEvents = []; |
||
18 | |||
19 | 5 | public function apply(object $event): void |
|
20 | { |
||
21 | 5 | $this->appliedEvents[] = $event; |
|
22 | 5 | $this->applyEventInUseCase($event); |
|
23 | } |
||
24 | |||
25 | 3 | public function getDomainIds(): array |
|
26 | { |
||
27 | 3 | return array_map( |
|
28 | 3 | fn($property) => $this->{$property}, |
|
29 | 3 | UseCaseAttributeRegistry::getDomainIdPropertiesForUseCase($this::class), |
|
30 | 3 | ); |
|
31 | } |
||
32 | |||
33 | 2 | public function getLastEventId(): ?string |
|
34 | { |
||
35 | 2 | return $this->lastEventId; |
|
36 | } |
||
37 | |||
38 | 3 | public function getAppliedEvents(): array |
|
39 | { |
||
40 | 3 | $appliedEvents = $this->appliedEvents; |
|
0 ignored issues
–
show
It seems like
$this->appliedEvents of type array is incompatible with the declared type Gember\EventSourcing\UseCase\list of property $appliedEvents .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
41 | |||
42 | 3 | $this->appliedEvents = []; |
|
43 | |||
44 | 3 | return $appliedEvents; |
|
45 | } |
||
46 | |||
47 | 3 | public static function reconstitute(DomainEventEnvelope ...$envelopes): self |
|
0 ignored issues
–
show
The type
Gember\EventSourcing\UseCase\DomainEventEnvelope was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
48 | { |
||
49 | 3 | $useCase = new self(); |
|
50 | |||
51 | 3 | foreach ($envelopes as $envelope) { |
|
52 | 3 | $useCase->applyEventInUseCase($envelope->event); |
|
53 | 3 | $useCase->lastEventId = $envelope->eventId; |
|
54 | } |
||
55 | |||
56 | 3 | return $useCase; |
|
57 | } |
||
58 | |||
59 | 8 | private function applyEventInUseCase(object $event): void |
|
60 | { |
||
61 | 8 | $method = UseCaseAttributeRegistry::getUseCaseSubscriberMethodForEvent($this::class, $event::class); |
|
62 | |||
63 | 8 | if ($method !== null) { |
|
64 | 6 | $this->{$method}($event); |
|
65 | } |
||
66 | } |
||
67 | } |
||
68 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths