1 | <?php |
||
16 | class InMemoryEventStore implements EventStore |
||
17 | { |
||
18 | /** @var EventsCommit[] */ |
||
19 | public $commitsByAggregate = []; |
||
20 | private $versions = []; |
||
21 | private $latestSequence = 0; |
||
22 | |||
23 | 10 | public function loadEventsForAggregate(string $aggregateClass, $aggregateId): AggregateEventStream |
|
28 | |||
29 | /** |
||
30 | * @inheritdoc |
||
31 | */ |
||
32 | 10 | public function appendEventsForAggregate($aggregateId, string $aggregateClass, $eventsWithMetaData, int $expectedVersion, int $expectedSequence) |
|
40 | |||
41 | 11 | public function appendEventsForAggregateWithoutChecking($aggregateId, $aggregateClass, $newEvents, int $expectedVersion, int $expectedSequence) |
|
42 | { |
||
43 | 11 | $this->addEventsToArrayForAggregate( |
|
44 | 11 | $aggregateId, |
|
45 | 11 | $aggregateClass, |
|
46 | 11 | $this->decorateEventsWithMetadata($aggregateClass, $aggregateId, $newEvents), |
|
47 | 11 | $expectedVersion, |
|
48 | 11 | $expectedSequence |
|
49 | ); |
||
50 | |||
51 | 11 | $constructKey = $this->constructKey($aggregateClass, $aggregateId); |
|
52 | |||
53 | 11 | if (!isset($this->versions[$constructKey])) { |
|
54 | 11 | $this->versions[$constructKey] = 0; |
|
55 | } |
||
56 | |||
57 | 11 | $this->versions[$constructKey]++; |
|
58 | 11 | $this->latestSequence++; |
|
59 | 11 | } |
|
60 | |||
61 | 10 | private function getEventsArrayForAggregate(string $aggregateClass, $aggregateId) |
|
69 | |||
70 | 11 | private function addEventsToArrayForAggregate($aggregateId, $aggregateClass, $newEvents, int $expectedVersion, int $expectedSequence) |
|
71 | { |
||
72 | 11 | $this->commitsByAggregate[$this->constructKey($aggregateClass, $aggregateId)][] = new EventsCommit( |
|
73 | 11 | $expectedSequence, $expectedVersion, $newEvents |
|
74 | ); |
||
75 | 11 | } |
|
76 | |||
77 | public function loadEventsByClassNames(array $eventClasses): EventStreamGroupedByCommit |
||
85 | |||
86 | private function extractEventsFromCommits(array $commits = []) |
||
94 | |||
95 | 11 | public function getAggregateVersion(string $aggregateClass, $aggregateId) |
|
101 | |||
102 | /** |
||
103 | * @param $aggregateClass |
||
104 | * @param $aggregateId |
||
105 | * @param $priorEvents |
||
106 | * @return EventWithMetaData[] |
||
107 | */ |
||
108 | public function decorateEventsWithMetadata($aggregateClass, $aggregateId, array $priorEvents) |
||
123 | |||
124 | 3 | public function fetchLatestSequence(): int |
|
128 | |||
129 | 14 | private function constructKey(string $aggregateClass, $aggregateId): string |
|
133 | |||
134 | 1 | public function findEventById(string $eventId): ?EventWithMetaData |
|
155 | } |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: