Skip to content

Upgrade to event-sourcing 4.0 and infer state types of Decision::read() - #34

Merged
DavidBadura merged 2 commits into
2.0.xfrom
decision-read
Oct 18, 2026
Merged

DavidBadura merged 2 commits into
2.0.xfrom
decision-read

Conversation

@DavidBadura

@DavidBadura DavidBadura commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

This moves the 2.0 line to event-sourcing 4.0 (the 1.x line stays for 3.x) and brings the DCB parts back, which were removed from 2.0.x while they only existed in 4.0.

The first commit is the upgrade itself. Child aggregates are gone in 4.0, so the rules only look at aggregate roots now and the child aggregate fixtures are removed. The identifiers moved to the Identifier namespace, which touches the fixtures and the docs samples.

The second commit adds the type inference for patchlevel/event-sourcing#937, which replaced the decision model builder with a Decision:

$state = $decision->read([
    'nextInvoiceNumber' => new NextInvoiceNumberProjection(),
    'invoiceCount' => new InvoiceCountProjection(),
]); // array{nextInvoiceNumber: int, invoiceCount: int}

[$next, $count] = $decision->read([...]); // array{int, int}

Without the extension the array form is only array<K, mixed>. A single projection is already typed natively through the projection generic, the extension covers it too and falls back to the return type of initialState(), so projections without @extends BasicProjection<...> get their type as well. ProjectionBuilder::build() is typed the same way. Both are always on, they don't report anything, so they have no configuration switch. The docs get a "Typed decisions" section.

The 2.0 line targets event-sourcing 4.0, the 1.x line stays for 3.x.
Child aggregates are gone in 4.0, so the rules only check aggregate roots
now, and the identifiers moved to the Identifier namespace.
patchlevel/event-sourcing#937 added the Decision for the dynamic
consistency boundary. Reading an array of projections now becomes an
array shape with the state type of each projection, a single projection
its state type. The state type is taken from the projection generic and
falls back to the return type of initialState().

ProjectionBuilder::build() is typed the same way again, it was dropped
together with the other DCB parts while they only existed in 4.0.
@DavidBadura DavidBadura changed the title Infer state types of Decision::read() Upgrade to event-sourcing 4.0 and infer state types of Decision::read() Oct 18, 2026
@DavidBadura
DavidBadura changed the base branch from event-sourcing-4.0 to 2.0.x October 18, 2026 07:27
@DavidBadura DavidBadura added BC break enhancement New feature or request labels Oct 18, 2026
@DavidBadura DavidBadura added this to the 2.0.0 milestone Oct 18, 2026
@DavidBadura
DavidBadura merged commit 01666c5 into 2.0.x Oct 18, 2026
3 of 6 checks passed
@DavidBadura
DavidBadura deleted the decision-read branch October 18, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BC break enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants