Skip to content

feat(#116): add reusable parameter sets with ParameterSet interface#131

Merged
usernane merged 3 commits into
devfrom
feat/116-reusable-parameter-sets
Jun 1, 2026
Merged

feat(#116): add reusable parameter sets with ParameterSet interface#131
usernane merged 3 commits into
devfrom
feat/116-reusable-parameter-sets

Conversation

@usernane

@usernane usernane commented Jun 1, 2026

Copy link
Copy Markdown
Member

Summary

Add a ParameterSet interface 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

  • Created WebFiori\Http\ParameterSet interface with getParameters(): array
  • Created #[UseParameterSet(ClassName::class)] attribute (repeatable, method-level)
  • Added WebService::addParameterSet(ParameterSet $set) for traditional usage
  • Updated configureParametersFromMethod() to process #[UseParameterSet] before #[RequestParam]
  • Updated getMethodParameters() for correct positional injection (set params first, then explicit params)
  • Added example in examples/01-core/07-reusable-parameter-sets/
  • Updated README with parameter sets documentation

UI Changes

N/A

How to Test / Verify

php vendor/bin/phpunit tests/WebFiori/Tests/Http/ParameterSetTest.php

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

  • I reviewed my own diff before requesting review
  • My commits follow Conventional Commits
  • The title of the pull request follows Conventional Commits
  • I added/updated tests (or explained why not)
  • I updated docs (if needed)
  • I ran lint/cs-fixer (if applicable)
  • I considered backward compatibility
  • I considered security

Related issues

Closes #116

- 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

codecov Bot commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.63%. Comparing base (c247e83) to head (04f7d99).

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              
Flag Coverage Δ
php-8.3 93.63% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

Ibrahim BinAlshikh 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
@sonarqubecloud

sonarqubecloud Bot commented Jun 1, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
6.4% Duplication on New Code (required ≤ 6%)

See analysis details on SonarQube Cloud

@usernane usernane merged commit 5bd309a into dev Jun 1, 2026
5 of 6 checks passed
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