Skip to content

Slim CollectionRequestOptions: drop webmozart/assert and new() - #8

Merged
loevgaard merged 1 commit into
1.xfrom
slim-collection-request-options
Aug 10, 2026
Merged

Slim CollectionRequestOptions: drop webmozart/assert and new()#8
loevgaard merged 1 commit into
1.xfrom
slim-collection-request-options

Conversation

@loevgaard

Copy link
Copy Markdown
Member

Follow-up to the "is CollectionRequestOptions overkill?" discussion. The class stays — it's load-bearing (paginate() advances via withPage(), 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

CollectionRequestOptions was the only user of webmozart/assert in src/ — a runtime dependency carried in every consumer's tree for two >= 1 checks. They're now plain inline if (...) throw new \InvalidArgumentException(...) guards, and both webmozart/assert and the phpstan/phpstan-webmozart-assert dev extension are removed. Webmozart's exception extended \InvalidArgumentException, so catch sites see no behavioral difference (the tests already expected \InvalidArgumentException and pass unchanged).

Removed new()

Pre-named-arguments ceremony: its only purpose was starting fluent chains (::new()->withPageSize(50)), which new CollectionRequestOptions(pageSize: 50) expresses better. The withers stay — paginate() itself uses withPage().

BC

Removing new() breaks callers using CollectionRequestOptions::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 lowest and highest matrices will validate the dependency change across PHP 8.1–8.5 in CI.

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

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.50%. Comparing base (419fb53) to head (a16b5f9).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@loevgaard
loevgaard merged commit 18b4362 into 1.x Aug 10, 2026
35 checks passed
@loevgaard
loevgaard deleted the slim-collection-request-options branch August 10, 2026 11:29
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.

1 participant