Skip to content

Conversation

@fogelito
Copy link
Contributor

@fogelito fogelito commented Jan 19, 2026

Summary by CodeRabbit

  • New Features

    • Added a helper to retrieve cursor-related queries.
    • Added an option to control whether returned query items are clones or returned by reference.
  • Tests

    • Added tests covering the new helper and cloning-vs-reference behavior, including mutation scenarios to verify original vs returned items.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

Added an optional boolean $clone parameter to Query::getByType to control whether matching queries are cloned or returned by reference, and introduced Query::getCursorQueries(array $queries, bool $clone = true) as a convenience wrapper delegating to getByType for cursor-related types.

Changes

Cohort / File(s) Summary
Query method enhancement
src/Database/Query.php
Changed signature to public static function getByType(array $queries, array $types, bool $clone = true): array to optionally clone matches; added public static function getCursorQueries(array $queries, bool $clone = true): array which calls getByType with TYPE_CURSOR_AFTER and TYPE_CURSOR_BEFORE.
Test coverage for clone vs reference
tests/unit/Validator/QueryTest.php
Extended tests to assert default cloning behavior, reference behavior when $clone = false, mutations propagation, and added tests covering getCursorQueries semantics and resulting item counts/types.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hop through queries, soft and spry,
Clone or share — I choose which lie.
Cursors pair and dance in view,
Tweak one, watch the other too.
A little nibble, changes new.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Get by type reference' directly relates to the main change: adding a $clone parameter to getByType() that controls whether queries are cloned or returned by reference.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@tests/unit/Validator/QueryTest.php`:
- Around line 252-254: The use of reset($queries_1) yields Query|false and
triggers static analysis; since you already assert the collection size, replace
reset(...) with an explicit index access ($queries_1[0]) or add a guard that
throws/fails if reset returns false to narrow the type; update occurrences
around the blocks using $cursor = reset($queries_1) (and the similar spots at
the other two locations) so $cursor is unambiguously a Query before calling
setValue/new Document.

@abnegate abnegate merged commit 53c674f into main Jan 19, 2026
18 checks passed
@abnegate abnegate deleted the get-by-type-reference branch January 19, 2026 09:02
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