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

Fixing PHP 8.4 Implicitly nullable parameter declarations deprecated #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mafftor
Copy link

@mafftor mafftor commented Jan 6, 2025

This dependency In PHP 8.4 now throws deprecation:

Fluent\Logger\FluentLogger::__construct(): Implicitly marking parameter $packer as nullable is deprecated, the explicit nullable type must be used instead

Recommendation from PHP 8.4: Implicitly nullable parameter declarations deprecated the solution is to explicitly mark the parameter as nullable, or avoid implicit nullability.

To maintain compatibility with PHP 5.6 while addressing this deprecation, I opted to:

  • Remove the type hint for the $packer parameter to avoid the nullable deprecation in PHP 8.4.
  • Manually check the $packer parameter type within the constructor, ensuring it either implements PackerInterface or is null. If it's not, an InvalidArgumentException is thrown.

This change ensures the code works as expected across all supported PHP versions, including PHP 5.6 and PHP 8.4.

@mafftor mafftor force-pushed the fix-implicitly-nullable-parameter-declarations-deprecated branch from 12f14bc to d7f2850 Compare January 6, 2025 12:36
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