Skip to content

Conversation

@koriym
Copy link
Member

@koriym koriym commented Nov 23, 2025

Summary

The opening quick start example in README was incomplete - it referenced a User entity without ever showing how to define it. This PR improves the example to be self-contained and aligned with the existing codebase conventions.

Changes

  • Added User class definition - The example now shows how to create the Entity class using constructor property promotion
  • Updated naming conventions to match existing codebase:
    • UserRepositoryUserQueryInterface (aligns with project name "MediaQuery")
    • find()item() (consistent with demo/tests codebase)
    • user_by_id.sqluser_item.sql (follows existing naming conventions)
  • Improved step 3 - Shows actual usage with getInstance() and method call instead of just a comment
  • Clearer step 1 label - Now explicitly says "Define your interface (and Entity)"

Benefits

  • Beginners can now understand the complete 1-2-3 flow without gaps
  • Consistent with existing code in demo/ and tests/ directories
  • Entity definition pattern is immediately visible
  • Project naming philosophy (MediaQuery) is better reflected

Test plan

  • README renders correctly with updated example
  • All naming conventions match existing codebase patterns
  • Example is self-contained and understandable

🤖 Generated with Claude Code

Summary by Sourcery

Improve the README quick start example to be self-contained and consistent with existing naming and usage patterns.

Documentation:

  • Expand the quick start example to include a concrete User entity definition and matching SQL query.
  • Align interface, method, and SQL file names in the README example with the conventions used in the existing codebase.
  • Clarify the step-by-step usage example by showing actual dependency injection and method invocation.

Summary by CodeRabbit

  • New Features

    • Introduced new User class with id and name properties
  • Refactor

    • Renamed user query interface and updated method signatures for improved consistency
    • Updated database queries to align with new naming conventions
  • Documentation

    • Updated examples and references to reflect API changes

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

The opening example now:
- Includes User class definition (previously missing)
- Uses UserQueryInterface naming (aligns with MediaQuery project name)
- Uses item() method (consistent with demo/tests codebase)
- Uses user_item.sql filename (follows existing conventions)
- Shows actual usage in step 3 (previously just commented)

This makes the 1-2-3 flow complete and self-contained for beginners.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 23, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the README quick start example to be self-contained by adding the User entity definition and aligning interface, method, and SQL naming with existing MediaQuery conventions, while demonstrating concrete usage of the query interface.

Sequence diagram for README quick start usage with getInstance and item

sequenceDiagram
  actor Developer
  participant Injector
  participant "UserQueryInterface implementation" as UserQueryImpl
  participant Database
  participant "SQL file user_item.sql" as SqlFile

  Developer->>Injector: "getInstance(UserQueryInterface::class)"
  Injector-->>Developer: "$userQuery (UserQueryInterface implementation)"
  Developer->>UserQueryImpl: "item(\"user-123\")"
  UserQueryImpl->>SqlFile: "load query \"user_item\" via DbQuery attribute"
  SqlFile-->>UserQueryImpl: "SQL: SELECT id, name FROM users WHERE id = :id"
  UserQueryImpl->>Database: "execute SQL with id = \"user-123\""
  Database-->>UserQueryImpl: "result row with id, name"
  UserQueryImpl-->>Developer: "User instance (or null if not found)"
Loading

Updated class diagram for README UserQueryInterface and User Entity

classDiagram
  class UserQueryInterface {
    +item(id: string) : ?User
  }

  class User {
    +string id
    +string name
  }

  class DbQuery {
    +string value
  }

  UserQueryInterface ..> User : returns ?User
  UserQueryInterface ..> DbQuery : uses DbQuery(user_item) attribute
Loading

File-Level Changes

Change Details Files
Make the README quick start example self-contained by defining the User entity and aligning all names with project conventions.
  • Rename the example interface from UserRepository to UserQueryInterface and adjust the DbQuery attribute to use user_item with a nullable User return type
  • Introduce a User entity class using constructor property promotion with readonly id and name fields in the example
  • Update the SQL snippet filename and query to user_item.sql and select only id and name columns from users
  • Replace the vague step 3 comment with a concrete usage example showing getInstance(UserQueryInterface::class) and calling item('user-123')
  • Clarify the step 1 comment to explicitly mention defining both the interface and the Entity
README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 23, 2025

Walkthrough

This pull request refactors the user query functionality by renaming the UserRepository interface to UserQueryInterface, updating the find() method to item() with a nullable return type, introducing a new User class with readonly properties, and updating associated SQL query file references and documentation.

Changes

Cohort / File(s) Summary
Interface and Class Definitions
src/UserQueryInterface.php, src/User.php
Renamed interface from UserRepository to UserQueryInterface; updated method from find(string $id): User to item(string $id): ?User; added new User class with constructor-promoted readonly properties (id, name); updated DbQuery attribute from 'user_by_id' to 'user_item'
SQL Query Files
queries/user_item.sql
Renamed file from user_by_id.sql to user_item.sql; updated query content to SELECT id, name FROM users WHERE id = :id
Documentation
README.md
Updated examples and type documentation to reflect renamed interface, new method signature, and new User class definition

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Note: Verify all usages of the renamed interface throughout the codebase are updated to use UserQueryInterface
  • Check that callers of the find() method are updated to use item() and handle the nullable return type appropriately
  • Confirm SQL query file references in configuration or loader code are updated to point to user_item.sql

Poem

🐰 From user_by_id to user_item we hop,
Interfaces renamed, method calls won't stop,
Readonly properties in a User so neat,
This refactor's cleanup makes the code complete! ✨

Pre-merge checks and finishing touches

✅ 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 accurately summarizes the main change: adding a User Entity definition to improve the README quick start example, which aligns with the core objective of making the example more complete and self-contained.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docs/improve-readme-quick-start

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1ac8430 and 3724255.

📒 Files selected for processing (1)
  • README.md (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Sourcery review
🔇 Additional comments (1)
README.md (1)

14-35: Excellent quick start example refactor—self-contained and aligned with project conventions.

The changes successfully deliver on all PR objectives:

  • The User entity with constructor property promotion demonstrates modern PHP patterns and is immediately useful.
  • The interface and method naming (UserQueryInterface, item()) clearly aligns with project conventions.
  • Explicit column selection in the SQL (SELECT id, name) is more maintainable than SELECT *.
  • The usage example with getInstance() and an actual method call is concrete and actionable for beginners.

This progression (1. Define interface and entity → 2. Write SQL → 3. Use it) is clear, complete, and self-contained. Beginners can now follow the full flow without looking elsewhere.


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

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@koriym
Copy link
Member Author

koriym commented Nov 23, 2025

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 23, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@koriym koriym merged commit dc592e0 into 1.x Nov 23, 2025
20 checks passed
@koriym koriym deleted the docs/improve-readme-quick-start branch November 23, 2025 15:42
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.

2 participants