Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly mark $directory as nullable in otp function to resolve PHP 8.1+ deprecation warning #391

Merged
merged 1 commit into from
Mar 2, 2025

Conversation

SoftHeroes
Copy link
Contributor

Description:
This PR fixes a deprecation warning in PHP 8.1+ caused by the implicit nullable parameter $directory in the otp function. The warning occurs because PHP now requires explicitly marking nullable parameters with ?.

Changes Made:

  • Updated the otp function signature in src/Helper.php from:
    function otp(string $directory = null): Otp
    to:
    function otp(?string $directory = null): Otp
  • This ensures compatibility with PHP 8.1+ and prevents deprecation warnings.

Why This Is Needed:

  • Without this change, users see a deprecation warning when running the package on PHP 8.1+.
  • This update does not affect backward compatibility with older PHP versions.
  • It aligns the function with best practices for defining nullable parameters.

Testing & Verification:

  • Ensured that the function still works as expected with and without the $directory parameter.
  • Checked compatibility with PHP versions prior to 8.1.

@tzsk tzsk merged commit 0af2d9b into tzsk:master Mar 2, 2025
9 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.

2 participants