Delegate identityEquals to Identity::equals for strict typed comparison#3
Merged
gustavofreze merged 1 commit intomainfrom Apr 22, 2026
Merged
Delegate identityEquals to Identity::equals for strict typed comparison#3gustavofreze merged 1 commit intomainfrom
gustavofreze merged 1 commit intomainfrom
Conversation
…parison, resolve event short name via string ops and throw LogicException when aggregate lacks when<event> handler</event>.
There was a problem hiding this comment.
Pull request overview
This PR updates identity equality to rely on Identity::equals() (value-object semantics) and aligns several related APIs/tests with updated naming and dependency changes across the library.
Changes:
- Delegate
EntityBehavior::identityEquals()toIdentity::equals()(value-object equality) and adjust related Identity interfaces. - Rename upcaster payload hook (
doUpcast()→rewrite()), and rename snapshot state payload (data→payload) with corresponding test updates. - Add an explicit failure path when an event-sourced aggregate is missing a
when*handler (currently via a native exception), plus accompanying tests and docs/config updates.
Reviewed changes
Copilot reviewed 47 out of 48 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Upcast/UpcastersTest.php | Renames local variables for clarity/consistency in upcaster chaining tests. |
| tests/Upcast/SingleUpcasterBehaviorTest.php | Renames local variables in single-upcaster behavior tests. |
| tests/Upcast/IntermediateEventTest.php | Expands IntermediateEvent::equals() test coverage; updates mapper serialization calls. |
| tests/Snapshot/SnapshotterBehaviorTest.php | Updates FileSnapshotter import after namespace move to tests/Mocks. |
| tests/Snapshot/SnapshotTest.php | Renames equality result variable in snapshot equality tests. |
| tests/Snapshot/SnapshotConditionTest.php | Improves BDD step clarity and renames boolean result variable. |
| tests/Models/ProductV2Upcaster.php | Updates hook name to rewrite() and payload naming. |
| tests/Models/ProductV1Upcaster.php | Updates hook name to rewrite() and payload naming. |
| tests/Models/CartWithoutHandler.php | Adds fixture aggregate lacking a when* handler to test missing-handler behavior. |
| tests/Mocks/FileSnapshotter.php | Moves mock snapshotter into Test\\...\\Mocks namespace. |
| tests/Event/SnapshotDataTest.php | Updates SnapshotData constructor arg name (data → payload) and renames locals. |
| tests/Event/SequenceNumberTest.php | Renames locals and minor formatting changes around exception message assertions. |
| tests/Event/RevisionTest.php | Renames locals and minor formatting changes around exception message assertions. |
| tests/Event/EventTypeTest.php | Renames locals and normalizes data provider array formatting. |
| tests/Event/EventRecordsTest.php | Renames locals; updates SnapshotData ctor arg name. |
| tests/Event/EventRecordTest.php | Updates SnapshotData ctor arg name; renames equality result locals. |
| tests/Entity/SingleIdentityBehaviorTest.php | Renames locals in identity equality tests. |
| tests/Entity/EntityBehaviorTest.php | Renames locals in identity/identityEquals tests to reflect boolean meaning. |
| tests/Entity/CompoundIdentityBehaviorTest.php | Renames locals in compound identity equality tests. |
| tests/Aggregate/EventSourcingRootBehaviorTest.php | Adds test asserting behavior when a when* handler method is missing. |
| src/Upcast/Upcaster.php | Updates docs to reflect rewrite() hook naming. |
| src/Upcast/SingleUpcasterBehavior.php | Renames abstract hook to rewrite() and updates call site. |
| src/Upcast/IntermediateEvent.php | Adds explicit equals() implementation using strict comparisons for payload. |
| src/Snapshot/Snapshot.php | Removes named args from native calls (ReflectionObject, in_array) per style rules. |
| src/Internal/Exceptions/MissingIdentityProperty.php | Reorders ctor params; updates message to reference identityName(); removes named args for native ctor. |
| src/Internal/Exceptions/InvalidSequenceNumber.php | Removes named arg usage to native exception ctor. |
| src/Internal/Exceptions/InvalidRevision.php | Removes named arg usage to native exception ctor. |
| src/Internal/Exceptions/InvalidEventType.php | Removes named arg usage to native exception ctor. |
| src/Event/SnapshotData.php | Renames internal field/ctor arg to $payload; removes named args from json_encode. |
| src/Event/EventType.php | Removes named args from preg_match and ReflectionClass construction. |
| src/Entity/SingleIdentity.php | Simplifies interface inheritance (now covered via Identity extends ValueObject). |
| src/Entity/Identity.php | Changes Identity to extend ValueObject and updates immutability wording in docs. |
| src/Entity/EntityBehavior.php | Delegates identityEquals() to Identity::equals() and updates exception ctor call. |
| src/Entity/CompoundIdentity.php | Simplifies interface inheritance (now covered via Identity extends ValueObject). |
| src/Aggregate/EventualAggregateRootBehavior.php | Updates collection add call to named argument (elements). |
| src/Aggregate/EventSourcingRootBehavior.php | Adds missing-handler detection and throws on absent when* method (currently native exception). |
| src/Aggregate/AggregateRootBehavior.php | Updates SnapshotData ctor arg name (payload). |
| composer.json | Updates dependency set (removes immutable-object; bumps value-object major) and adjusts package description. |
| README.md | Updates overview language to match current feature set and design positioning. |
| LICENSE | Updates copyright year. |
| .gitignore | Expands ignored files/dirs (IDE, Composer lock, PHPUnit caches, coverage). |
| .gitattributes | Refines export-ignore set for Packagist tarball contents. |
| .claude/rules/php-library-testing.md | Updates/normalizes testing rules text and references. |
| .claude/rules/php-library-modeling.md | Adds/updates modeling rules document. |
| .claude/rules/php-library-documentation.md | Normalizes documentation rules and adds example requirements. |
| .claude/rules/php-library-code-style.md | Expands style rules (complexity, brace placement, default-arg omission, etc.). |
| .claude/rules/php-domain.md | Removes deprecated rules file in favor of new modeling rules. |
| .claude/CLAUDE.md | Updates project framing as a library and clarifies command expectations. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.