Skip to content

Split structural equality and hashing into Internal collaborators.#22

Merged
gustavofreze merged 2 commits into
mainfrom
feature/develop
May 18, 2026
Merged

Split structural equality and hashing into Internal collaborators.#22
gustavofreze merged 2 commits into
mainfrom
feature/develop

Conversation

@gustavofreze
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings May 18, 2026 15:14
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

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 expose hashCode() through ValueObject / 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.

Comment thread composer.json
Comment thread src/Internal/ValueObjectEquality.php
Comment thread src/Internal/StructuralHash.php
Comment thread src/Internal/ArrayHash.php
Comment thread tests/Unit/ValueObjectBehaviorHashCodeTest.php
Comment thread tests/Unit/ValueObjectBehaviorEqualsTest.php
@gustavofreze gustavofreze merged commit 9a1292c into main May 18, 2026
6 checks passed
@gustavofreze gustavofreze deleted the feature/develop branch May 18, 2026 15:22
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