Repository navigation
Fix PHPStan alreadyNarrowedType error in value-limit test - #295
Conversation
PHPStan 2.2.16 remembers the result of a method call after an assertion. It reported the second assertSame() on the same get() call as always true. Store each lookup result in its own variable so that PHPStan checks both results. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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 (1)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe limit test now stores the results of two consecutive lookups in separate variables before asserting that each matches the expected array. The expected behavior is unchanged. ChangesLimit lookup test
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~2 minutes Change: Refactor Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change only reorganizes the limit test’s two lookups and assertions; no production behavior change or merge-blocking risk is identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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 checks each lookup twice, Comment |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The targeted test change resolves the PHPStan error without altering intended behavior.
Review effort: Lite
Findings: None
What changed in this PR
Updates the value-limit test to avoid PHPStan’s repeated-expression narrowing error while preserving both lookups.
Changes:
- Stores each lookup result separately.
- Asserts both results against the expected value.
| File | Description |
|---|---|
tests/MaxMind/Db/Test/ReaderTest.php |
Adjusts lookup assertions for PHPStan compatibility. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
PHPStan 2.2.16 fails the scheduled lint run on
main(run). It remembers the result of$reader->get('1.1.1.1')after the firstassertSame(), so it reports the second, identical assertion as always true.This change stores each lookup result in its own variable. The test still does two lookups on the same reader.
PHPStan 2.2.16 reports no errors with this change.
🤖 Generated with Claude Code
Summary by CodeRabbit