feat(#116): add reusable parameter sets with ParameterSet interface#131
Merged
Conversation
- Create ParameterSet interface with getParameters() method - Add #[UseParameterSet] attribute for declarative usage on methods - Add WebService::addParameterSet() for traditional usage - Update getMethodParameters() to handle positional injection from sets - Sets are processed before #[RequestParam], enabling combined usage - Add example in examples/01-core/07-reusable-parameter-sets/ - Update README with parameter sets documentation - 12 new tests covering interface, attribute, validation, edge cases
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #131 +/- ##
============================================
- Coverage 93.64% 93.63% -0.02%
+ Complexity 1316 1303 -13
============================================
Files 39 39
Lines 3180 3174 -6
============================================
- Hits 2978 2972 -6
Misses 202 202
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
added 2 commits
June 1, 2026 17:02
- Create OpenAPIObject with shared description property and addIfNotNull/addIfTruthy helpers - HeaderObj and ParameterObj extend OpenAPIObject, removing duplicate description property/methods - Refactor toJSON() methods to use helpers instead of repeated if-null-add blocks - Reduces ~60 lines of duplicated code
|
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.


Summary
Add a
ParameterSetinterface and#[UseParameterSet]attribute for grouping related parameters into reusable, shareable sets.Motivation
Multiple services often need the same parameter groups (pagination, address, date range). Currently these must be duplicated in each service. This violates DRY and makes updates error-prone. Fixes #116.
Changes
WebFiori\Http\ParameterSetinterface withgetParameters(): array#[UseParameterSet(ClassName::class)]attribute (repeatable, method-level)WebService::addParameterSet(ParameterSet $set)for traditional usageconfigureParametersFromMethod()to process#[UseParameterSet]before#[RequestParam]getMethodParameters()for correct positional injection (set params first, then explicit params)examples/01-core/07-reusable-parameter-sets/UI Changes
N/A
How to Test / Verify
12 new tests, 39 assertions. Full suite: 542 tests pass.
Breaking Changes and Migration Steps
None. Purely additive — new interface, new attribute, new method.
Checklist
Related issues
Closes #116