Skip to content

Clarify Collection APIs#27

Merged
alganet merged 1 commit intoRespect:masterfrom
alganet:immutable
Apr 1, 2026
Merged

Clarify Collection APIs#27
alganet merged 1 commit intoRespect:masterfrom
alganet:immutable

Conversation

@alganet
Copy link
Copy Markdown
Member

@alganet alganet commented Apr 1, 2026

  • Rename next to connectsTo and more to hasMore for clarity
  • Make mapper and hydrator properties private(set), add bindMapper()
  • Remove $changes from Collection::persist() — identity map merge handles it
  • Remove EntityFactory::withChanges() and AbstractMapper::replaceTracked()
  • Register entities in identity map at insert time for pre-flush dedup
  • Preserve original pending operation in tryMergeWithIdentityMap

- Rename `next` to `connectsTo` and `more` to `hasMore` for clarity
- Make `mapper` and `hydrator` properties `private(set)`, add `bindMapper()`
- Remove `$changes` from Collection::persist() — identity map merge handles it
- Remove EntityFactory::withChanges() and AbstractMapper::replaceTracked()
- Register entities in identity map at insert time for pre-flush dedup
- Preserve original pending operation in tryMergeWithIdentityMap
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.96%. Comparing base (4055991) to head (b0b67ce).

Additional details and impacted files
@@             Coverage Diff              @@
##             master      #27      +/-   ##
============================================
- Coverage     98.23%   97.96%   -0.28%     
+ Complexity      300      290      -10     
============================================
  Files            17       17              
  Lines           624      590      -34     
============================================
- Hits            613      578      -35     
- Misses           11       12       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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 clarifies and tightens the Collection API while simplifying persistence behavior by relying on identity-map merges (instead of “persist with changes”), and it updates hydration/iteration logic and tests accordingly.

Changes:

  • Rename nextconnectsTo and morehasMore across Collection traversal/hydration/iteration and tests.
  • Make Collection::$mapper / Collection::$hydrator private(set) and introduce Collection::bindMapper() for mapper binding.
  • Remove EntityFactory::withChanges() and the Collection persist(...$changes) API, shifting partial updates to identity-map merge behavior in AbstractMapper.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/InMemoryMapper.php Updates relationship attachment logic to use connectsTo / hasMore.
tests/EntityFactoryTest.php Removes test coverage for removed EntityFactory::withChanges().
tests/Collections/TypedTest.php Updates assertions to connectsTo.
tests/Collections/FilteredTest.php Updates assertions to connectsTo.
tests/Collections/CompositeTest.php Updates assertions to connectsTo.
tests/Collections/CollectionTest.php Updates chaining/flags to connectsTo / hasMore, switches mapper binding to bindMapper(), and rewrites persist tests around partial entities + identity map.
tests/AbstractMapperTest.php Updates chaining to connectsTo and rewrites “withChanges” persistence tests to use partial entities + identity map behavior.
src/Hydrators/Nested.php Updates nested hydration to traverse via connectsTo.
src/EntityFactory.php Removes withChanges() implementation and now-unused imports.
src/Collections/Collection.php Renames chain pointer/flag, restricts mapper/hydrator setters, adds bindMapper(), and removes persist(...$changes) support.
src/CollectionIterator.php Updates recursive iteration logic to use hasMore / connectsTo.
src/AbstractMapper.php Updates Filtered chaining to connectsTo, registers inserts in identity map earlier, removes replaceTracked(), and preserves pending ops when merging via identity map.

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

@alganet alganet marked this pull request as ready for review April 1, 2026 08:56
@alganet alganet merged commit f95b89c into Respect:master Apr 1, 2026
7 checks passed
@alganet alganet deleted the immutable branch April 1, 2026 08:56
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.

3 participants