refactor(helpers): drop variadic, take an explicit array argument#886
Merged
refactor(helpers): drop variadic, take an explicit array argument#886
Conversation
Sweeps the remaining variadic helper methods on the 5.4 lineage so the API is consistent with the project's "no spread/variadic" convention adopted on the new ClientOverrideRule (#885) and the rest of the typed helpers. Six methods converted from `Type ...$xxx` to `array $xxx`: * AbstractWebauthnVerifier::withAllowedOrigins(string ...) -> withAllowedOrigins(array $origins) * AbstractWebauthnOptionsBuilder::withAttestationFormats(string ...) -> withAttestationFormats(array $formats) * AbstractWebauthnOptionsBuilder::withHints(string ...) -> withHints(array $hints) * WebauthnCreationOptionsBuilder::withPubKeyCredParams(PublicKeyCredentialParameters ...) -> withPubKeyCredParams(array $params) * WebauthnRequestOptionsBuilder::withAllowCredentials(PublicKeyCredentialDescriptor ...) -> withAllowCredentials(array $descriptors) * WebauthnSignalResponse::withSignals(array $payload, Signal ...$signals) -> withSignals(array $payload, array $signals) Why: variadic forces the caller to spread (`...$myArray`) when their input is already a list, breaks named arguments through the `@no-named-arguments` constraint, and prevents a clean array call site when the list is computed at runtime. The 5.4 helper API is unreleased, so this is BC-safe. PHPDoc `@param list<Type>` annotations preserve the static-analysis guarantee. All call sites in the test suite (8 occurrences across WebauthnOptionsResponseTest / WebauthnResponseVerifierTest / SignalHelpersTest) are updated to pass an array literal. 544/544 tests green. Rector / ECS / PHPStan clean.
Spomky
added a commit
that referenced
this pull request
May 6, 2026
…ensions (#887) Drops the explicit AuthenticationExtensions wrapper at the call site. Callers pass a plain list of AuthenticationExtension value objects; the builder wraps them internally. Before: ->withExtensions(AuthenticationExtensions::create([ AuthenticationExtension::create('uvm', true), ])) After: ->withExtensions([ AuthenticationExtension::create('uvm', true), ]) The 5.4 helper API is unreleased, so dropping the AuthenticationExtensions parameter type is BC-safe. Aligned with the project's "no spread, prefer array" convention (PR #886) and the typed ClientOverrideRule shape (#885).
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
Sweeps the remaining variadic helper methods on the 5.4 lineage so the API is consistent with the project's "no spread/variadic" convention adopted on the new
ClientOverrideRule(#885) and the rest of the typed helpers.What changes
Six methods converted from
Type ...\$xxxtoarray \$xxx:AbstractWebauthnVerifier::withAllowedOrigins(string ...)withAllowedOrigins(array \$origins)AbstractWebauthnOptionsBuilder::withAttestationFormats(string ...)withAttestationFormats(array \$formats)AbstractWebauthnOptionsBuilder::withHints(string ...)withHints(array \$hints)WebauthnCreationOptionsBuilder::withPubKeyCredParams(PublicKeyCredentialParameters ...)withPubKeyCredParams(array \$params)WebauthnRequestOptionsBuilder::withAllowCredentials(PublicKeyCredentialDescriptor ...)withAllowCredentials(array \$descriptors)WebauthnSignalResponse::withSignals(array \$payload, Signal ...\$signals)withSignals(array \$payload, array \$signals)PHPDoc
@param list<Type>annotations preserve the static-analysis guarantee on each list.Why
Variadic forces the caller to spread (
...\$myArray) when their input is already a list, breaks named arguments through the@no-named-argumentsconstraint, and adds noise at the call site when the list is computed at runtime. An explicitarray \$xxxparameter is cleaner.Call site updates
Eight call sites updated across the test suite (
WebauthnOptionsResponseTest,WebauthnResponseVerifierTest,SignalHelpersTest). Before/after example:```php
// Before
->withAllowedOrigins('https://app.example.com', 'https://admin.example.com')
->withAllowCredentials($descA, $descB)
->withSignals($payload, $signalA, $signalB)
// After
->withAllowedOrigins(['https://app.example.com', 'https://admin.example.com'])
->withAllowCredentials([$descA, $descB])
->withSignals($payload, [$signalA, $signalB])
```
A companion doc PR will refresh the snippets in
options-helpers.md,verification-helpers.mdand the migration page.BC
The 5.4 helper API is unreleased — this is BC-safe.
Tests
544/544 green. Rector / ECS / PHPStan clean.