Skip to content

docs: fix broken and inaccurate README examples#90

Merged
valbeat merged 2 commits into
mainfrom
docs/fix-readme-examples
Jul 7, 2026
Merged

docs: fix broken and inaccurate README examples#90
valbeat merged 2 commits into
mainfrom
docs/fix-readme-examples

Conversation

@valbeat

@valbeat valbeat commented Jul 7, 2026

Copy link
Copy Markdown
Owner

概要

コードレビューで見つかった README の誤りを修正します。

変更内容

  • Basic Usage の 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; を削除
  • 冒頭の "makes it impossible to accidentally ignore errors" を実態に合わせた表現に変更(PHP には Rust の #[must_use] 相当の仕組みがなく、Result を無視してもエラーにはならないため)

備考

パラメータ名を ok: / err: に改名して名前付き引数の例を復活させる案は別 PR で提案します(そちらがマージされる場合、この PR の match 例の変更は巻き戻して構いません)。

検証

  • 修正後のスニペットを PHP 8.4.7 で実行し、"Success: 42" / 20 を確認

https://claude.ai/code/session_017XTM7pxbWPVNLV639i5WgK

- 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
@valbeat valbeat self-assigned this Jul 7, 2026
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@valbeat, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 57 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8dc74bfa-1d96-40ec-a5b5-dd3dbbbdd5ee

📥 Commits

Reviewing files that changed from the base of the PR and between 98a2fcb and 3d544d6.

📒 Files selected for processing (1)
  • README.md
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/fix-readme-examples

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread README.md
$failure = new Err("Something went wrong");

// Pattern matching with match expression
// Pattern matching with the match() method

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

match() メソッドによる分岐は、厳密な意味での「パターンマッチング(Pattern matching)」とは異なり、単に成功時と失敗時のコールバック関数を適用する処理(Catamorphism / Fold)です。PHPには言語機能として match 式が存在するため、読者がそれと混同する可能性があります。\n\nより正確に Handling results with the match() methodBranching with the match() method と表現することを提案します。

Suggested change
// Pattern matching with the match() method
// Handling results with the match() method

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (98a2fcb) to head (3d544d6).
✅ All tests successful. No failed tests found.

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           
Flag Coverage Δ
unittests 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@valbeat valbeat marked this pull request as ready for review July 7, 2026 04:35
Copilot AI review requested due to automatic review settings July 7, 2026 04:35
…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
@valbeat

valbeat commented Jul 7, 2026

Copy link
Copy Markdown
Owner Author

レビュー指摘への対応: match の例は名前付き引数のまま維持し、#91(パラメータ改名)のマージ後にこの PR をマージする順序にしました。#91 マージ後はこの例がそのまま有効になります。また API Reference の $okFn/$errFn 誤記(レビュー指摘 5 件目)は #91 が同じ行を正しく書き換えるため、そちらで解消されます。

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 (1920) and removed an unused use statement.
  • 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.

@valbeat valbeat merged commit b74250b into main Jul 7, 2026
9 checks passed
@valbeat valbeat deleted the docs/fix-readme-examples branch July 7, 2026 06:34
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