Split structural equality and hashing into Internal collaborators.#22
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors value-object equality and hashing by introducing src/Internal/* collaborators, expands the public ValueObject contract with hashCode(), and updates tests/documentation/tooling to reflect the new behavior and repository standards.
Changes:
- Add recursive structural equality + hashing engine under
src/Internal/, and exposehashCode()throughValueObject/ValueObjectBehavior. - Replace the previous equality tests with focused unit tests covering arrays, nested value objects, enums, and external-object identity semantics.
- Align repo tooling/docs/CI configuration with tiny-blocks ecosystem conventions (reports paths, stricter PHPUnit flags, static analysis, templates, etc.).
Reviewed changes
Copilot reviewed 48 out of 49 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/ValueObjectTest.php | Removes the old broad equality test suite. |
| tests/Unit/ValueObjectBehaviorHashCodeTest.php | Adds behavioral tests for deterministic structural hashing and hash/equality pairing. |
| tests/Unit/ValueObjectBehaviorEqualsTest.php | Adds behavioral tests for recursive structural equality across scalars/arrays/nested objects/enums/external objects. |
| tests/Models/Profile.php | Adds a nullable-property VO fixture for equality/hash coverage. |
| tests/Models/Product.php | Removes unused fixture from previous test approach. |
| tests/Models/Point.php | Adds same-shape/different-class fixture to validate class-sensitive semantics. |
| tests/Models/Period.php | Adds external-object identity fixture (DateTimeImmutable) for equality semantics. |
| tests/Models/Order.php | Updates fixture shape to emphasize array behavior and key ordering. |
| tests/Models/Money.php | Adds VO fixture with scalar + enum properties to exercise base cases. |
| tests/Models/Invoice.php | Adds nested-VO fixture for recursive behavior coverage. |
| tests/Models/Currency.php | Adds backed enum fixture to validate enum identity hashing/equality behavior. |
| tests/Models/Coordinate.php | Adds same-shape/different-class fixture to validate class-sensitive hashing. |
| tests/Models/Amount.php | Removes unused fixture from previous test approach. |
| src/ValueObjectBehavior.php | Routes equality and hashing through new internal collaborators and adds hashCode(). |
| src/ValueObject.php | Documents and formalizes the equality contract and introduces hashCode() in the public interface. |
| src/Internal/ValueObjectHash.php | Implements VO-level serialization and hashing for structural hashing. |
| src/Internal/ValueObjectEquality.php | Implements VO-level recursive property-by-property equality. |
| src/Internal/StructuralHash.php | Adds a dispatcher for hashing scalars, arrays, value objects, and other subjects. |
| src/Internal/StructuralEquality.php | Adds a dispatcher for equality across value objects, arrays, and strict identity for other types. |
| src/Internal/ArrayHash.php | Implements deterministic array serialization for inclusion in VO hashing. |
| src/Internal/ArrayEquality.php | Implements deterministic recursive array equality (keys + element-wise). |
| SECURITY.md | Adds a repository security policy file. |
| README.md | Expands documentation for declaring VOs, equals semantics, hashCode contract, and nested-type behavior. |
| phpunit.xml | Tightens PHPUnit configuration and updates report output paths to reports/. |
| phpstan.neon.dist | Raises analysis strictness and scopes analysis to src + tests, with targeted ignores. |
| phpcs.xml | Adds PHPCS ruleset configuration for PSR-12 across src and tests. |
| Makefile | Aligns targets with composer scripts and standardizes report paths and dev workflows. |
| infection.json.dist | Updates Infection report paths and keeps MSI thresholds. |
| composer.json | Adds keywords and standardizes public scripts to canonical tiny-blocks tooling shape. |
| .gitignore | Updates ignored artifacts and standardizes report/cache entries. |
| .github/workflows/codeql.yml | Adds concurrency control and timeouts; normalizes formatting. |
| .github/workflows/ci.yml | Refactors CI into canonical job chain with PHP version resolved from composer.json. |
| .github/workflows/auto-assign.yml | Adds concurrency/permissions normalization and pins action tag style. |
| .github/PULL_REQUEST_TEMPLATE.md | Adds a canonical PR template for consistent contributions. |
| .github/ISSUE_TEMPLATE/feature_request.md | Adds canonical feature request issue template. |
| .github/ISSUE_TEMPLATE/bug_report.md | Adds canonical bug report issue template. |
| .github/copilot-instructions.md | Updates Copilot instructions to reference .claude rule sources clearly. |
| .gitattributes | Adjusts wording and extends export-ignore list for reports/cache. |
| .editorconfig | Adds max line length and aligns editor defaults with tooling rules. |
| .claude/rules/php-library-tooling.md | Adds canonical tiny-blocks PHP library tooling configuration rules. |
| .claude/rules/php-library-testing.md | Expands and formalizes PHPUnit + BDD + mutation/coverage discipline rules. |
| .claude/rules/php-library-modeling.md | Expands modeling/nomenclature rules and examples for library design. |
| .claude/rules/php-library-github-workflows.md | Adds canonical workflow structure/pinning/ordering rules for tiny-blocks PHP libs. |
| .claude/rules/php-library-documentation.md | Expands README/doc structure rules and canonical templates. |
| .claude/rules/php-library-commits.md | Adds Conventional Commits guidance for commit message generation. |
| .claude/rules/php-library-code-style.md | Expands semantic PHP code style rules, including PHPDoc boundaries and formatting overrides. |
| .claude/rules/php-library-architecture.md | Adds canonical architecture and public/internal boundary rules. |
| .claude/rules/github-workflows.md | Removes legacy generalized workflow rules in favor of PHP-library-specific ones. |
| .claude/CLAUDE.md | Updates entrypoint docs to reference the expanded .claude/rules set. |
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.