Skip to content

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

Merged
wisyhambolu merged 1 commit into
force-2fafrom
fix/php-85-implicit-nullable-u2f
Sep 1, 2026
Merged

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

Conversation

@mikelittle

@mikelittle mikelittle commented May 18, 2026

Copy link
Copy Markdown

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.

@wisyhambolu wisyhambolu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but @mikelittle should we not also update the doc block here to have same change?

@wisyhambolu
wisyhambolu merged commit a151c71 into force-2fa Sep 1, 2026
0 of 2 checks passed
@wisyhambolu
wisyhambolu deleted the fix/php-85-implicit-nullable-u2f branch September 1, 2026 18:34
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.

2 participants