Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (7)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe pull request documents input-validation and mixed-argument exceptions in PHPDoc, adds tests for mixed array and named-argument calls, and updates PHPStan settings and development-tool constraints. It does not change executable behavior or public signatures. ChangesException documentation and analysis
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Refactor Merge Risk: ⚪ Minimal · up to The changes document existing exception behavior, add tests, and update static-analysis configuration. No issue requiring a fix before merge is established. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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. A rabbit reads the throws with care, Comment |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The exception annotations match the implementations, and the targeted PHPStan configuration passes lint validation.
Review effort: Balanced
Findings: None
What changed in this PR
Enables PHPStan checked-exception analysis and documents exceptions exposed by request-building APIs.
Changes:
- Enables checked-exception validation with targeted exclusions.
- Adds missing
@throwsdeclarations. - Records the documentation change in the changelog.
| File | Description |
|---|---|
CHANGELOG.md |
Documents updated exception annotations. |
phpstan.neon |
Enables checked-exception analysis and scoped ignores. |
src/MinFraud.php |
Documents request-building exceptions. |
src/MinFraud/ReportTransaction.php |
Documents report() exceptions. |
src/MinFraud/ServiceClient.php |
Documents validation-helper exceptions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Turn on exceptions.check.missingCheckedExceptionInThrows so PHPStan reports a checked exception that a method throws but does not declare in its @throws tag. Tests are excluded, because PHPUnit handles any exception a test throws. Configure Error and LogicException as unchecked. They signal programmer errors, such as mixing the $values array with named arguments. Setting them explicitly also makes the result independent of the PHPStan version, because older 2.2 releases treat Error as checked by default. Declare the InvalidInputException that the request methods and their private validation helpers throw when input validation is enabled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The with*() methods and ReportTransaction::report() throw InvalidArgumentException if $values is non-empty and named arguments are provided. No test covered this. Also add withDevice to the withMethods data provider, so the unknown-key test covers it too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
composer.lock is not committed, so the require-dev constraints alone decide which tool versions CI and developers install. PHPStan and PHP_CodeSniffer used "*", which allows any version, including a future major release that changes behavior. php-cs-fixer allowed any 3.x release. Require the major and minor versions that CI installs now: PHPStan 2.2, PHP_CodeSniffer 4.0, and php-cs-fixer 3.95. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5253e38 to
3a8c923
Compare
This enables PHPStan checked-exception analysis for the library.
exceptions.check.missingCheckedExceptionInThrows. PHPStan now reports a checked exception that a method throws but does not declare in its@throwstag.ErrorandLogicExceptionas unchecked. They signal programmer errors, such as mixing the$valuesarray with named arguments. Setting them explicitly makes the result the same on all PHPStan 2.2 releases. 2.2.5 treatsErroras checked by default, and 2.2.16 does not.@throws InvalidInputExceptionto the request methods and their validation helpers. They throw it when input validation is enabled.@throws, because PHPUnit handles any exception a test throws. A path-scopedignoreErrorsentry ignoresmissingType.checkedExceptionundertests/.InvalidArgumentExceptionthat thewith*()methods andreport()throw if$valuesis non-empty and named arguments are provided.^2.2), PHP_CodeSniffer (^4.0), and php-cs-fixer (^3.95).composer.lockis not committed, so these constraints decide what CI installs.tooWideThrowTypeis not enabled.When
web-service-common-phpreleases its new@throwstags (maxmind/web-service-common-php#142), PHPStan will report theRuntimeExceptionfrom theClientconstructor,get(), andpost(). We will then need to declare it here.🤖 Generated with Claude Code
Summary by CodeRabbit
InvalidInputExceptionfor invalid values, types, or keys.InvalidArgumentExceptionis thrown when a non-empty values array is combined with named arguments.with()andwith*()methods.