Remove stdClass support, enable pure entity trees#22
Merged
alganet merged 1 commit intoRespect:masterfrom Mar 25, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #22 +/- ##
============================================
+ Coverage 97.58% 98.45% +0.86%
+ Complexity 206 204 -2
============================================
Files 16 16
Lines 456 453 -3
============================================
+ Hits 445 446 +1
+ Misses 11 7 -4 ☔ 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 as a fallback entity type and shifts hydration/persistence toward “pure entity trees” where relationships are represented by object properties (e.g. $post->author) and persisted via derived FK columns (e.g. author_id).
Changes:
- Make
EntityFactory::createByName()throw for unknown entity classes (nostdClassfallback) and remove dynamic property set/get behavior. - Add
EntityFactory::extractColumns()to convert relation-object properties into FK columns for persistence. - Update hydrators/collections/tests to support array-based typed discrimination and collection-tree-based relationship wiring.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Stubs/Post.php | Adds Post stub for pure entity-tree relationship modeling. |
| tests/Stubs/Issue.php | Adds Issue stub for typed entity hydration tests. |
| tests/Stubs/Foo.php | Adds Foo stub used as a generic entity in tests (replacing stdClass). |
| tests/Stubs/Comment.php | Adds Comment stub using relation property (post) instead of FK scalar. |
| tests/Stubs/Category.php | Adds Category stub for test fixtures. |
| tests/Stubs/Bug.php | Adds Bug stub for typed discriminator hydration tests. |
| tests/Stubs/Author.php | Adds Author stub for relationship and persistence tests. |
| tests/InMemoryMapper.php | Switches persistence extraction from properties to derived columns (extractColumns). |
| tests/Hydrators/NestedTest.php | Updates Nested hydrator tests to use stub namespace + typed entities without stdClass. |
| tests/Hydrators/FlatTest.php | Updates Flat hydrator typed-entity test to use stubs instead of stdClass. |
| tests/EntityFactoryTest.php | Updates expectations for unknown entities (exception) and adds extractColumns unit coverage. |
| tests/Collections/TypedTest.php | Updates typed discriminator tests to use array rows (no stdClass). |
| tests/Collections/CollectionTest.php | Replaces stdClass usage with stub entity instances. |
| tests/AbstractMapperTest.php | Reworks relationship wiring assertions for pure entity trees and updates mapper setup to use stubs. |
| src/Hydrators/Nested.php | Passes raw array into resolveEntityName() for Nested hydration compatibility. |
| src/Hydrators/Base.php | Replaces FK-scanning wiring with collection-tree parent matching. |
| src/EntityFactory.php | Removes stdClass fallback + dynamic props, adds extractColumns(), updates extraction/hydration logic. |
| src/Collections/Typed.php | Allows resolveEntityName() to accept `object |
| src/Collections/Collection.php | Updates resolveEntityName() signature to accept `object |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Drop stdClass as entity fallback — EntityFactory now throws DomainException for unknown classes. Remove dynamic property fallbacks from set/get/extractProperties, eliminate persistableCache and reflectPersistable(). Add EntityFactory::extractColumns() to derive FK values from entity object properties (e.g. $author -> author_id). Rewrite wireRelationships to use collection-tree parent matching instead of FK property scanning. Update resolveEntityName to accept object|array for Nested hydrator compatibility. Entity stubs use pure entity trees: relation properties ($post, $author) replace FK scalars ($post_id, $author_id). Remove redundant tests, add extractColumns unit coverage.
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 as entity fallback — EntityFactory now throws DomainException for unknown classes. Remove dynamic property fallbacks from set/get/extractProperties, eliminate persistableCache and reflectPersistable().
Add EntityFactory::extractColumns() to derive FK values from entity object properties (e.g. $author -> author_id).
Rewrite wireRelationships to use collection-tree parent matching instead of FK property scanning. Update resolveEntityName to accept object|array for Nested hydrator compatibility.
Entity stubs use pure entity trees: relation properties ($post, $author) replace FK scalars ($post_id, $author_id). Remove redundant tests, add extractColumns unit coverage.