Skip to content

refactor(helpers): drop variadic, take an explicit array argument#886

Merged
Spomky merged 1 commit into5.4.xfrom
refactor/no-variadic-on-helpers
May 6, 2026
Merged

refactor(helpers): drop variadic, take an explicit array argument#886
Spomky merged 1 commit into5.4.xfrom
refactor/no-variadic-on-helpers

Conversation

@Spomky
Copy link
Copy Markdown
Contributor

@Spomky Spomky commented May 6, 2026

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 ...\$xxx to array \$xxx:

Before After
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-arguments constraint, and adds noise at the call site when the list is computed at runtime. An explicit array \$xxx parameter 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.md and the migration page.

BC

The 5.4 helper API is unreleased — this is BC-safe.

Tests

544/544 green. Rector / ECS / PHPStan clean.

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 Spomky added this to the 5.4.0 milestone May 6, 2026
@Spomky Spomky added the DX Developer Experience label May 6, 2026
@Spomky Spomky self-assigned this May 6, 2026
@Spomky Spomky merged commit 8559a55 into 5.4.x May 6, 2026
18 of 19 checks passed
@Spomky Spomky deleted the refactor/no-variadic-on-helpers branch May 6, 2026 07:30
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DX Developer Experience

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant