Skip to content

Fix PHP 8.4+ implicit-nullable deprecation in U2F Error constructor#9

Open
mikelittle wants to merge 1 commit into
force-2fafrom
fix/php-85-implicit-nullable-u2f
Open

Fix PHP 8.4+ implicit-nullable deprecation in U2F Error constructor#9
mikelittle wants to merge 1 commit into
force-2fafrom
fix/php-85-implicit-nullable-u2f

Conversation

@mikelittle
Copy link
Copy Markdown

@mikelittle mikelittle commented May 18, 2026

Summary

includes/Yubico/U2F.php:504 declares \Exception $previous = null — an implicit-nullable parameter, deprecated in PHP 8.4 and 8.5. This one-line change adds the explicit ? to silence the deprecation notice. The docblock already says @param \Exception|null $previous, so behaviour is unchanged.

Repro

Under PHP 8.5, loading any code path that touches U2F.php emits:

Deprecated: u2flib_server\Error::__construct(): Implicitly marking parameter $previous as nullable is deprecated, the explicit nullable type must be used instead in .../vendor/humanmade/two-factor/includes/Yubico/U2F.php on line 504

In Altis this fires on every WP request inside the local stack on the PHP 8.5 image.

Context

Targeting force-2fa because that's the branch Altis ships from (currently pinned at ^0.3.3 via altis/security).

  Add explicit ?\Exception type to the $previous parameter. Implicit
  nullable parameters (Type $x = null) are deprecated as of PHP 8.4 and
  emit a deprecation notice on every class load under PHP 8.5.

  Matches the existing @param \Exception|null docblock.
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