Remove stdClass support, enable pure entity trees#108
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #108 +/- ##
============================================
- Coverage 98.83% 98.32% -0.51%
+ Complexity 178 172 -6
============================================
Files 4 4
Lines 430 419 -11
============================================
- Hits 425 412 -13
- Misses 5 7 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR removes stdClass-based entity hydration in favor of always producing typed entities, and updates tests/stubs to reflect “pure entity tree” relationships (relation properties instead of FK scalars).
Changes:
- Replace
Mapper::extractColumns()custom extraction logic with delegation toEntityFactory::extractColumns()plus existing column filtering. - Update test stubs and mapper tests to use typed entities (and relation properties like
$post->author,$comment->post) rather thanstdClass/ FK scalar fields. - Adjust and streamline tests, adding coverage for non-existent row fetch and join-related edge cases.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Mapper.php | Simplifies column extraction by delegating to EntityFactory::extractColumns() and keeping existing filtering. |
| tests/MapperTest.php | Refactors tests to assert on typed entities and relation properties; adds new edge-case tests and removes redundant ones. |
| tests/Hydrators/FlatNumTest.php | Updates typed hydration test to resolve to Bug instead of stdClass and uses a namespaced EntityFactory. |
| tests/Stubs/Post.php | Shifts Post to relation-based shape (e.g., $author) consistent with pure entity trees. |
| tests/Stubs/Comment.php | Uses relation property $post instead of FK scalar + duplicate relation field. |
| tests/Stubs/OtherEntity/Post.php | Marks derived $author as #[NotPersistable] for backward-compatible setter behavior. |
| tests/Stubs/Author.php | Adds typed entity stub used by hydration/persist tests. |
| tests/Stubs/Category.php | Adds typed entity stub used by hydration/persist tests. |
| tests/Stubs/PostCategory.php | Adds typed entity stub for join-table scenarios. |
| tests/Stubs/Issue.php | Adds typed stub for singular issue table scenarios. |
| tests/Stubs/Issues.php | Adds typed stub for plural issues table scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Drop stdClass entities: all hydration now produces typed classes. Simplify extractColumns to a one-liner delegating to EntityFactory::extractColumns() + filterColumns(). Simplify getRelatedEntity keeping the FK-field fallback for backward compatibility with OtherEntity-style setters. Entity stubs use pure entity trees: relation properties ($post, $author) replace FK scalars. OtherEntity\Post marks its derived $author as #[NotPersistable] since it keeps explicit $author_id. Remove 5 redundant tests (identical duplicate + fetch/fetchAll pairs). Add coverage for LEFT JOIN null-child, non-existent row fetch, pure entity tree FK derivation on persist.
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.
Drop stdClass entities: all hydration now produces typed classes. Simplify extractColumns to a one-liner delegating to EntityFactory::extractColumns() + filterColumns(). Simplify getRelatedEntity keeping the FK-field fallback for backward compatibility with OtherEntity-style setters.
Entity stubs use pure entity trees: relation properties ($post, $author) replace FK scalars. OtherEntity\Post marks its derived $author as #[NotPersistable] since it keeps explicit $author_id.
Remove 5 redundant tests (identical duplicate + fetch/fetchAll pairs). Add coverage for LEFT JOIN null-child, non-existent row fetch, pure entity tree FK derivation on persist.