Skip to content

Add initial implementation of domain models and event handling.#1

Merged
gustavofreze merged 1 commit into
mainfrom
feature/develop
Apr 18, 2026
Merged

Add initial implementation of domain models and event handling.#1
gustavofreze merged 1 commit into
mainfrom
feature/develop

Conversation

@gustavofreze
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings April 18, 2026 19:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the first cut of the library’s tactical DDD building blocks (entities/identities, aggregate roots with event recording, snapshots, and upcasting) along with PHPUnit coverage and project automation/docs to support ongoing development.

Changes:

  • Introduce core domain primitives in src/ (Entity/Identity, AggregateRoot variants, event records, snapshots, upcasting).
  • Add comprehensive PHPUnit tests plus test fixture models under tests/.
  • Add project tooling and automation (Composer scripts, PHPUnit/PHPStan/Infection config, GitHub workflows) and expand README documentation.

Reviewed changes

Copilot reviewed 85 out of 86 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
tests/Upcast/SingleUpcasterBehaviorTest.php Verifies single-step upcaster behavior (revision bump + payload enrich).
tests/Upcast/IntermediateEventTest.php Tests IntermediateEvent immutability helpers and equality.
tests/Upcast/DefaultValuesTest.php Tests primitive default-value map used by upcasters.
tests/Snapshot/SnapshotterBehaviorTest.php Verifies snapshotter behavior via a test snapshotter adapter.
tests/Snapshot/SnapshotTest.php Tests Snapshot creation, state capture/omissions, and equality.
tests/Snapshot/SnapshotConditionTest.php Verifies snapshot condition strategy behavior.
tests/Models/ProductV1Upcaster.php Test fixture upcaster implementation used by upcast tests.
tests/Models/ProductAdded.php Test fixture domain event for event-sourcing examples/tests.
tests/Models/OrderWithoutIdentityConstant.php Fixture aggregate used to test identity-constant error behavior.
tests/Models/OrderWithMissingIdentityProperty.php Fixture aggregate used to test identity-property error behavior.
tests/Models/OrderShipped.php Test fixture domain event for outbox-style aggregate.
tests/Models/OrderPlaced.php Test fixture domain event for outbox-style aggregate.
tests/Models/OrderId.php Test fixture single-field identity.
tests/Models/Order.php Fixture eventual aggregate root emitting outbox events.
tests/Models/FileSnapshotter.php Snapshotter adapter fixture for behavior tests.
tests/Models/EveryTwoEvents.php SnapshotCondition fixture (every 2 events).
tests/Models/CartWithoutIdentityConstant.php Fixture to exercise event-sourcing identity-constant errors.
tests/Models/CartId.php Test fixture single-field identity for Cart.
tests/Models/Cart.php Fixture event-sourced aggregate with snapshot restore and event handlers.
tests/Models/AppointmentId.php Test fixture compound identity.
tests/Event/SnapshotDataTest.php Tests snapshot-data array/JSON conversion and equality.
tests/Event/SequenceNumberTest.php Tests sequence-number invariants, operations, and equality.
tests/Event/RevisionTest.php Tests revision invariants and equality.
tests/Event/EventTypeTest.php Tests event-type validation, factories, and equality.
tests/Event/EventRecordsTest.php Tests EventRecords collection behavior (empty/add/first).
tests/Event/EventRecordTest.php Tests EventRecord value exposure and equality semantics.
tests/Entity/SingleIdentityBehaviorTest.php Tests SingleIdentityBehavior identity value and equality.
tests/Entity/EntityBehaviorTest.php Tests entity identity resolution + error conditions.
tests/Entity/CompoundIdentityBehaviorTest.php Tests CompoundIdentityBehavior identity value and equality.
tests/Aggregate/EventualAggregateRootBehaviorTest.php Tests outbox-style aggregate event recording/envelope behavior.
tests/Aggregate/EventSourcingRootBehaviorTest.php Tests event-sourced aggregate recording/reconstitution/snapshot integration.
tests/Aggregate/AggregateRootBehaviorTest.php Tests aggregate-root shared behavior (sequence/model version/name).
src/Upcast/Upcaster.php Defines upcaster contract for serialized-event migrations.
src/Upcast/SingleUpcasterBehavior.php Provides trait implementing “single-step” upcast behavior.
src/Upcast/IntermediateEvent.php Value object representing serialized event type/revision/payload during upcast.
src/Upcast/DefaultValues.php Provides primitive defaults map for upcast payload enrichment.
src/Snapshot/SnapshotterBehavior.php Snapshotter trait to capture and persist snapshots.
src/Snapshot/Snapshotter.php Snapshot persistence port interface.
src/Snapshot/SnapshotCondition.php Strategy interface for when to snapshot.
src/Snapshot/Snapshot.php Snapshot value object + reflection-based capture from aggregates.
src/Internal/Exceptions/MissingIdentityProperty.php Exception for invalid IDENTITY property reference.
src/Internal/Exceptions/MissingIdentityConstant.php Exception for missing IDENTITY constant.
src/Internal/Exceptions/InvalidSequenceNumber.php Exception for negative sequence numbers.
src/Internal/Exceptions/InvalidRevision.php Exception for invalid revision values (< 1).
src/Internal/Exceptions/InvalidEventType.php Exception for invalid event type strings.
src/Event/SnapshotData.php SnapshotData value object with JSON serialization.
src/Event/SequenceNumber.php SequenceNumber value object with invariants and helpers.
src/Event/Revision.php Revision value object with invariants.
src/Event/EventType.php EventType value object with validation + factories.
src/Event/EventRecords.php EventRecords collection type.
src/Event/EventRecord.php Event envelope value object (id/type/event/identity/etc.).
src/Event/DomainEvent.php Marker interface for domain events.
src/Entity/SingleIdentityBehavior.php Trait for scalar-backed identity value extraction.
src/Entity/SingleIdentity.php Interface for scalar identity value objects.
src/Entity/Identity.php Base identity interface for entities.
src/Entity/EntityBehavior.php Trait for identity resolution/comparison on entities.
src/Entity/Entity.php Entity contract (identity + comparisons).
src/Entity/CompoundIdentityBehavior.php Trait for multi-field identity value extraction.
src/Entity/CompoundIdentity.php Interface for compound identity value objects.
src/Aggregate/EventualAggregateRootBehavior.php Trait for outbox-style aggregates recording EventRecords.
src/Aggregate/EventualAggregateRoot.php Contract for outbox-style aggregates.
src/Aggregate/EventSourcingRootBehavior.php Trait for event-sourced aggregates (blank/reconstitute/record/apply).
src/Aggregate/EventSourcingRoot.php Contract for event-sourced aggregates.
src/Aggregate/AggregateRootBehavior.php Shared aggregate behavior (sequence/model version/event record building).
src/Aggregate/AggregateRoot.php Base aggregate root contract.
phpunit.xml PHPUnit configuration including coverage reporting.
phpstan.neon.dist PHPStan configuration (level 9 + ignored patterns).
infection.json.dist Infection mutation testing configuration.
composer.json Package definition, dependencies, and dev scripts.
README.md Expanded documentation with usage examples and design rationale.
Makefile Developer workflows via Dockerized PHP toolchain.
LICENSE MIT license text.
.gitignore Ignores vendor, reports, locks, PHPUnit cache, IDE settings.
.github/workflows/codeql.yml Adds CodeQL security workflow.
.github/workflows/ci.yml Adds CI workflow (composer validate/install, static checks, tests).
.github/workflows/auto-assign.yml Adds automation to auto-assign issues/PRs.
.github/dependabot.yml Adds Dependabot configuration for Composer + GitHub Actions.
.github/copilot-instructions.md Adds repository Copilot instructions and rule file references.
.gitattributes Sets LF normalization and export-ignore rules.
.editorconfig Editor defaults (LF, indentation, trimming).
.claude/rules/php-testing.md Defines PHPUnit testing conventions for the repo.
.claude/rules/php-domain.md Defines domain modeling rules for src/.
.claude/rules/php-code-style.md Defines cross-cutting PHP code style rules.
.claude/rules/github-workflows.md Defines workflow conventions and security/pinning rules.
.claude/rules/documentation.md Defines README/documentation standards.
.claude/CLAUDE.md Defines project-wide validation commands and formatting rules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Upcast/SingleUpcasterBehavior.php
Comment thread src/Snapshot/Snapshot.php
Comment thread README.md
Comment thread tests/Snapshot/SnapshotterBehaviorTest.php
Comment thread tests/Entity/EntityBehaviorTest.php
Comment thread src/Aggregate/EventSourcingRootBehavior.php
Comment thread src/Snapshot/Snapshot.php
Comment thread src/Event/SnapshotData.php
Comment thread .github/workflows/codeql.yml
Comment thread tests/Upcast/DefaultValuesTest.php
@gustavofreze gustavofreze merged commit 309d89f into main Apr 18, 2026
8 of 13 checks passed
@gustavofreze gustavofreze deleted the feature/develop branch April 18, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants