Skip to content

Add Nested definition to support nested result structures - #13

Merged
1blankz7 merged 1 commit into
masterfrom
fix/php-object-query-6-nested-structures
Aug 21, 2026
Merged

Add Nested definition to support nested result structures#13
1blankz7 merged 1 commit into
masterfrom
fix/php-object-query-6-nested-structures

Conversation

@1blankz7

Copy link
Copy Markdown
Collaborator

Summary

  • Adds Lemonade\ObjectQuery\Definition\Nested, a new DefinitionInterface implementation that lets a query return a nested data structure instead of only flat scalars.
  • Nested navigates to a sub-source via any other definition (typically a Path), then applies its own set of queries to it:
    • Single object → nested associative array.
    • Collection → list of nested associative arrays (one per entry).
    • UnresolvedValue from an optional() navigation propagates correctly, so the key is omitted from the result set as usual.
  • Nested definitions can be nested inside each other to build arbitrarily deep structures.
  • Documents the new definition in the README with examples.

Closes #6.

Test plan

  • composer tests:all (phpunit, 21 tests / 23 assertions, all green)
  • composer lint:all (phpcs PSR12 + phpstan level 8, no errors)

Closes #6. Adds a new `Definition\Nested` that resolves one or more
queries against a sub-source (navigated to via any other definition,
typically a Path). Depending on whether the navigation resolves to a
single object or a collection, it returns a nested associative array
or a list of nested associative arrays, and can be composed to build
arbitrarily deep structures. Propagates UnresolvedValue so optional()
navigation still omits the key as expected.
@1blankz7
1blankz7 merged commit 6b9972f into master Aug 21, 2026
1 check passed
@1blankz7
1blankz7 deleted the fix/php-object-query-6-nested-structures branch August 21, 2026 23:55
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.

Allow nested structures in result

1 participant