docs: fix broken and inaccurate README examples#90
Conversation
- The Basic Usage match() example used named arguments (ok:, err:)
that do not match the actual parameter names ($ok_fn, $err_fn),
so it fataled with "Unknown named parameter $ok". Use positional
arguments so the example runs as written.
- strlen("Something went wrong") is 20, not 19.
- Drop the unused `use Valbeat\Result\Result;` import from the snippet.
- Soften the "impossible to accidentally ignore errors" claim: PHP has
no must-use enforcement, so describe what the type actually provides.
Claude-Session: https://claude.ai/code/session_017XTM7pxbWPVNLV639i5WgK
|
Warning Review limit reached
Next review available in: 57 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request updates the README.md to clarify the library's description, remove an unused import, update the match() method example to use positional arguments, and correct the character count comment for unwrapOrElse. The reviewer suggests renaming the comment describing the match() method to avoid confusion with PHP's native match expression, providing a direct code suggestion.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| $failure = new Err("Something went wrong"); | ||
|
|
||
| // Pattern matching with match expression | ||
| // Pattern matching with the match() method |
There was a problem hiding this comment.
match() メソッドによる分岐は、厳密な意味での「パターンマッチング(Pattern matching)」とは異なり、単に成功時と失敗時のコールバック関数を適用する処理(Catamorphism / Fold)です。PHPには言語機能として match 式が存在するため、読者がそれと混同する可能性があります。\n\nより正確に Handling results with the match() method や Branching with the match() method と表現することを提案します。
| // Pattern matching with the match() method | |
| // Handling results with the match() method |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #90 +/- ##
===========================================
Coverage 100.00% 100.00%
Complexity 40 40
===========================================
Files 2 2
Lines 80 80
===========================================
Hits 80 80
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
…name PR Review feedback: rewriting the example to positional args and then back once #91 renames the parameters to ok/err is patch-then-revert churn on the same lines. Keep the named-argument form here and merge this PR after #91, which makes it valid. Claude-Session: https://claude.ai/code/session_017XTM7pxbWPVNLV639i5WgK
There was a problem hiding this comment.
Pull request overview
Updates README examples and wording to accurately reflect the library’s current PHP API behavior and avoid runnable-snippet failures.
Changes:
- Replaced the
match(ok: ..., err: ...)named-argument example with positional arguments to match the actual parameter names ($ok_fn,$err_fn). - Corrected the
strlen("Something went wrong")inline comment result (19→20) and removed an unusedusestatement. - Revised the introductory claim to avoid implying Rust-like
#[must_use]enforcement in PHP.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
概要
コードレビューで見つかった README の誤りを修正します。
変更内容
match()の例が実行するとフェイタルエラーになる問題を修正実装のパラメータ名は
$ok_fn/$err_fnのため、match(ok: ..., err: ...)はError: Unknown named parameter $okで落ちます(PHP 8.4 で実行して確認)。位置引数に変更し、例がそのまま動くようにしました。strlen("Something went wrong")のコメントを// 19→// 20に修正(実測値)use Valbeat\Result\Result;を削除#[must_use]相当の仕組みがなく、Result を無視してもエラーにはならないため)備考
パラメータ名を
ok:/err:に改名して名前付き引数の例を復活させる案は別 PR で提案します(そちらがマージされる場合、この PR の match 例の変更は巻き戻して構いません)。検証
"Success: 42"/20を確認https://claude.ai/code/session_017XTM7pxbWPVNLV639i5WgK