@@ -38,25 +38,15 @@ public function __construct(
3838
3939 public function recordOutboxes (array $ outboxes ): void
4040 {
41- /**
42- * @var list<string> $insertData
43- */
4441 $ insertData = [];
4542
46- /**
47- * @var list<string> $placeholders
48- */
4943 $ placeholders = [];
50- /**
51- * @var Outbox $outbox
52- */
44+
5345 foreach ($ outboxes as $ outbox ) {
54- array_push ($ insertData ,
55- $ this ->endpoint ->toString (),
56- $ outbox ->incomingMessageId ,
57- new PostgresByteA (serialize ($ outbox ->commands )),
58- new PostgresByteA (serialize ($ outbox ->events )),
59- );
46+ $ insertData [] = $ this ->endpoint ->toString ();
47+ $ insertData [] = $ outbox ->incomingMessageId ;
48+ $ insertData [] = new PostgresByteA (serialize ($ outbox ->commands ));
49+ $ insertData [] = new PostgresByteA (serialize ($ outbox ->events ));
6050
6151 $ placeholders [] = '(?, ?, ?, ?, ' . ($ outbox ->dispatched ? 'now() ' : 'null ' ) . ') ' ;
6252 }
@@ -72,13 +62,13 @@ public function recordOutboxes(array $outboxes): void
7262 SQL ,
7363 $ insertData ,
7464 );
75-
76- if ($ result ->getRowCount () !== count ($ outboxes )) {
77- throw new OutboxAlreadyExists ();
78- }
7965 } catch (SqlTransactionError $ exception ) {
8066 throw new TransactionClosed (previous: $ exception );
8167 }
68+
69+ if ($ result ->getRowCount () !== count ($ outboxes )) {
70+ throw new OutboxAlreadyExists ();
71+ }
8272 }
8373
8474 public function commitIfBegun (): void
0 commit comments