Skip to content

docs: Improve array support documentation#2

Merged
koriym merged 2 commits into1.xfrom
docs/improve-array-documentation
Jul 3, 2025
Merged

docs: Improve array support documentation#2
koriym merged 2 commits into1.xfrom
docs/improve-array-documentation

Conversation

@koriym
Copy link
Member

@koriym koriym commented Jul 3, 2025

Summary

  • Remove outdated Input Format Requirements section that contradicted array support
  • Add comprehensive HTML form examples for better understanding
  • Include examples for both object arrays and simple arrays (checkboxes, multi-select)

Changes

  • Removed the misleading "Input Format Requirements" section that stated nested arrays weren't supported
  • Added HTML form examples showing how to submit array data
  • Added examples for checkbox groups and multi-select elements
  • Used Jingu and Horikawa as sample names (longtime BEAR framework contributors)

Impact

This makes the documentation clearer and more comprehensive, helping developers understand:

  • How to structure HTML forms for array inputs
  • What PHP data structures they'll receive
  • How to handle both complex object arrays and simple value arrays

🤖 Generated with Claude Code

Summary by Sourcery

Improve array input documentation by removing outdated restrictions, adding detailed HTML form examples for object and simple arrays, and clarifying resulting PHP data structures and naming conventions.

Documentation:

  • Remove outdated Input Format Requirements section contradicting nested arrays
  • Add HTML form examples for indexed object arrays and resulting PHP data
  • Include examples for simple arrays such as checkboxes and multi-select elements
  • Clarify naming conventions for flat (non-array) parameters

Summary by CodeRabbit

  • Documentation
    • Expanded and clarified guidance on formatting array inputs in forms.
    • Added detailed examples for indexed and simple array structures and their PHP mappings.
    • Removed previous restriction against nested array structures in input data.

- Remove outdated Input Format Requirements section that contradicted array support
- Add comprehensive HTML form examples with Jingu and Horikawa as sample names
- Include checkbox and multi-select examples for simple array handling
- Clarify data flow from HTML forms to PHP data structures
- Maintain existing nested object and key normalization documentation

This update makes the documentation more cohesive and removes the confusing
restriction about nested arrays that no longer applies with the array support feature.

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

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

sourcery-ai bot commented Jul 3, 2025

Reviewer's Guide

This PR refines array support in the README by removing outdated restrictions and adding clear HTML form examples for both object-based and simple arrays.

Class diagram for controller method input handling with array support

classDiagram
    class UserListController {
        +list(#[Input] array users)
    }
    class UserInput {
        +string id
        +string name
    }
    UserListController --> "*" UserInput : receives array of

    class PreferencesController {
        +updatePreferences(#[Input] array hobbies, #[Input] array categories)
    }
    PreferencesController : receives array of strings for hobbies and categories
Loading

File-Level Changes

Change Details Files
Removed outdated Input Format Requirements section
  • Deleted the entire ‘### Input Format Requirements’ block
  • Removed flat key-value requirement examples and warnings about nested arrays
  • Eliminated related HTML form avoidance guidance
README.md
Added object array HTML form examples
  • Inserted HTML snippet showing users[0] and users[1] inputs
  • Updated PHP example to use Jingu and Horikawa as sample data
README.md
Added simple array examples for checkboxes and multi-select
  • Added checkbox group HTML snippet for hobbies[]
  • Added multi-select HTML snippet for categories[]
  • Included PHP mapping and controller signature for simple string arrays
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

coderabbitai bot commented Jul 3, 2025

Walkthrough

The README documentation for Ray.InputQuery was updated to provide expanded and clearer guidance on handling array and simple array input formats in HTML forms, including detailed examples. Restrictions on nested array structures were removed, reflecting a change in documented usage. No code or public API changes were made.

Changes

File(s) Change Summary
README.md Expanded documentation for array/simple array input formats with examples; removed nesting restriction and related notes.

Possibly related PRs

Poem

In README fields where arrays once hid,
Now examples shine, no secrets amid.
Brackets and indices, clearly displayed,
The rules of the past have gently decayed.
So form your arrays, let inputs parade—
The rabbit approves of the progress you've made! 🐇


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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 @koriym - 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.

Copy link

@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: 0

🧹 Nitpick comments (4)
README.md (4)

156-160: Promote subsection to a proper Markdown heading for TOC consistency

Within the “### Array Support” section you switched to bold text instead of a level-4 heading. Using #### Query data format for arrays keeps the document hierarchy machine-navigable and matches other parts of the README (e.g., “### Basic Usage”, “### Nested Objects”).

-**Query data format for arrays:**
+#### Query data format for arrays

160-169: Add a closing </form> tag and blank line after the HTML snippet

Minor markup hygiene: although browsers forgive the missing closing tag, including it avoids confusing copy-paste errors and keeps the example symmetrical.

-    <input name="users[1][name]" value="Horikawa">
-</form>
+    <input name="users[1][name]" value="Horikawa">
+</form>
+

185-202: Convert bold label to heading & group checkbox / select examples inside <form>

For symmetry with the previous example and better formatting in some Markdown renderers, promote the label to a heading and wrap the inputs in a <form> so that readers instantly see both belong to one submission context.

-**Simple array values (e.g., checkboxes):**
+#### Simple array values (e.g., checkboxes)

-<!-- Checkbox group -->
-<input name="hobbies[]" type="checkbox" value="music">
+<form method="post">
+  <!-- Checkbox group -->
+  <input name="hobbies[]" type="checkbox" value="music">
   ...
-</select>
+</select>
+</form>

220-226: Remove extraneous colon inside fenced code block

The colon after “Note” is outside the code fence and renders as plain text, breaking visual flow. Either move the colon inside the bold text or drop it.

-**Note:** For non-array parameters, use flat naming without brackets:
+**Note** For non-array parameters, use flat naming without brackets:
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a788bf0 and fdbf0a3.

📒 Files selected for processing (1)
  • README.md (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/**/*.php : Every parameter sourced from query data must have the #[Input] attribute.
README.md (9)
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/**/*.php : Every parameter sourced from query data must have the #[Input] attribute.
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/src/InputQuery.php : For parameters with #[Input] and object type, extract prefixed keys from flat query and recursively create nested objects.
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/src/InputQuery.php : Implement a reasonable recursion depth limit (e.g., 10 levels) to prevent infinite recursion in nested input resolution.
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/src/InputQuery.php : Convert all query keys to camelCase, handling snake_case, kebab-case, and PascalCase.
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/src/InputQuery.php : Parameters with #[Input] but missing from query: use parameter default or null if allowed.
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/src/InputQuery.php : For parameters without #[Input], resolve them from the DI container, supporting #[Named] for scalar DI values.
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/src/InputQuery.php : Parameters without #[Input] that can't be resolved by DI: use parameter default or throw exception.
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/src/InputQueryInterface.php : InputQueryInterface must define getArguments(ReflectionMethod $method, array $query): array and create(string $class, array $query): object.
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/src/Attribute/Input.php : Attribute class Input must be defined as #[Attribute(Attribute::TARGET_PARAMETER)] in src/Attribute/Input.php.

- Convert bold text to proper markdown headings for better TOC
- Add closing form tag and blank line for proper HTML structure
- Wrap checkbox/select examples in form tag for consistency
- Fix Note formatting by removing extraneous colon

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

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

@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: 0

🧹 Nitpick comments (3)
README.md (3)

156-184: Consider mentioning how non-sequential or missing numeric indexes are handled
Great example – it makes the object-array mapping crystal-clear. One minor clarification that could save readers troubleshooting time: PHP will preserve the provided numeric keys (and will fill in indexes automatically if [] is used), while Ray\InputQuery only cares that the values are arrays. Explicitly stating that gaps / non-0-based indexes are tolerated (or not) would make expectations unambiguous.


186-204: Add a note that [] MUST be present for check-box groups & multi-selects
The snippet is correct, but a short sentence such as “Remember: omitting the trailing [] will cause only the last value to be sent” prevents a common pitfall for newcomers who copy / paste the HTML.


214-221: Explicitly document element type expectations for simple arrays
In the controller example the array is implicitly an array of strings. Readers may wonder whether they can declare #[Input(item: int::class)] array $ids for primitive conversions. Adding a parenthetical (“primitive arrays don’t require item, only object arrays do”) would tighten the mental model.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fdbf0a3 and bc129bc.

📒 Files selected for processing (1)
  • README.md (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/**/*.php : Every parameter sourced from query data must have the #[Input] attribute.
README.md (9)
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/**/*.php : Every parameter sourced from query data must have the #[Input] attribute.
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/src/InputQuery.php : For parameters with #[Input] and object type, extract prefixed keys from flat query and recursively create nested objects.
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/src/InputQuery.php : Parameters with #[Input] but missing from query: use parameter default or null if allowed.
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/src/InputQueryInterface.php : InputQueryInterface must define getArguments(ReflectionMethod $method, array $query): array and create(string $class, array $query): object.
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/src/InputQuery.php : For parameters without #[Input], resolve them from the DI container, supporting #[Named] for scalar DI values.
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/src/InputQuery.php : Parameters without #[Input] that can't be resolved by DI: use parameter default or throw exception.
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/src/InputQuery.php : Convert all query keys to camelCase, handling snake_case, kebab-case, and PascalCase.
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/src/InputQuery.php : Implement a reasonable recursion depth limit (e.g., 10 levels) to prevent infinite recursion in nested input resolution.
Learnt from: CR
PR: ray-di/Ray.InputQuery#0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-07-03T12:18:36.698Z
Learning: Applies to docs/src/Attribute/Input.php : Attribute class Input must be defined as #[Attribute(Attribute::TARGET_PARAMETER)] in src/Attribute/Input.php.

@koriym koriym merged commit e69bc94 into 1.x Jul 3, 2025
19 of 21 checks passed
@koriym koriym deleted the docs/improve-array-documentation branch July 3, 2025 15:54
koriym added a commit that referenced this pull request Jul 6, 2025
docs: Improve array support documentation
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.

1 participant