Slim CollectionRequestOptions: drop webmozart/assert and new() - #8
Merged
Conversation
CollectionRequestOptions was the ONLY user of webmozart/assert in src/, so the two >= 1 checks now throw plain \InvalidArgumentException inline and the runtime dependency is gone from every consumer's tree (along with the phpstan-webmozart-assert dev extension). Webmozart's exception extended \InvalidArgumentException, so catch sites see no difference - the tests already expected \InvalidArgumentException. Also removes the new() static constructor: it existed only to start fluent wither chains, which constructor named arguments express better (new CollectionRequestOptions(pageSize: 50)). The withers stay - paginate() itself uses withPage() to advance pages. BC note: removing new() breaks callers using CollectionRequestOptions::new() - last-cheap-moment change before 1.0.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 1.x #8 +/- ##
=========================================
Coverage 98.50% 98.50%
- Complexity 146 147 +1
=========================================
Files 24 24
Lines 401 401
=========================================
Hits 395 395
Misses 6 6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the "is
CollectionRequestOptionsoverkill?" discussion. The class stays — it's load-bearing (paginate()advances viawithPage(), and it's the BC-safe growth point for future list params) — but two things around it were heavier than needed:webmozart/assert → inline guards
CollectionRequestOptionswas the only user ofwebmozart/assertinsrc/— a runtime dependency carried in every consumer's tree for two>= 1checks. They're now plain inlineif (...) throw new \InvalidArgumentException(...)guards, and bothwebmozart/assertand thephpstan/phpstan-webmozart-assertdev extension are removed. Webmozart's exception extended\InvalidArgumentException, so catch sites see no behavioral difference (the tests already expected\InvalidArgumentExceptionand pass unchanged).Removed
new()Pre-named-arguments ceremony: its only purpose was starting fluent chains (
::new()->withPageSize(50)), whichnew CollectionRequestOptions(pageSize: 50)expresses better. The withers stay —paginate()itself useswithPage().BC
Removing
new()breaks callers usingCollectionRequestOptions::new()— the deliberate last-cheap-moment cleanup while still in pre-1.0 (flagged for the next release notes). Dropping a dependency is BC-safe.Checks
109 tests, PHPStan max, ECS, Rector, composer-dependency-analyser ("no composer issues"), Infection MSI 85% / covered 85% — all green. Both
lowestandhighestmatrices will validate the dependency change across PHP 8.1–8.5 in CI.