Skip to content

Remove stdClass support, enable pure entity trees#108

Merged
alganet merged 1 commit into
Respect:masterfrom
alganet:pk-track
Mar 26, 2026
Merged

Remove stdClass support, enable pure entity trees#108
alganet merged 1 commit into
Respect:masterfrom
alganet:pk-track

Conversation

@alganet

@alganet alganet commented Mar 25, 2026

Copy link
Copy Markdown
Member

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.

@alganet alganet marked this pull request as ready for review March 25, 2026 23:25
@alganet alganet requested a review from Copilot March 25, 2026 23:25
@codecov-commenter

codecov-commenter commented Mar 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.32%. Comparing base (325dea6) to head (e86946f).

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.
📢 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.

Copilot AI left a comment

Copy link
Copy Markdown

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 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 to EntityFactory::extractColumns() plus existing column filtering.
  • Update test stubs and mapper tests to use typed entities (and relation properties like $post->author, $comment->post) rather than stdClass / 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.

Comment thread tests/MapperTest.php Outdated
Comment thread tests/MapperTest.php Outdated
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.
@alganet alganet merged commit f0f0ba4 into Respect:master Mar 26, 2026
3 checks passed
@alganet alganet deleted the pk-track branch March 26, 2026 00:37
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