Skip to content

Fix PHP 8.4 implicitly nullable parameter deprecations #657

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

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

Conversation

MauricioFauth
Copy link

This pull request fixes the implicitly nullable parameter types PHP 8.4 deprecation for the 1.x branch.

For example:

Deprecated: Safe\curl_init(): Implicitly marking parameter $url as nullable is deprecated, the explicit nullable type must be used instead

It would be great if a v1.3.4 version was released with these fixes.

Signed-off-by: Maurício Meneghini Fauth <[email protected]>
@OskarStark
Copy link
Collaborator

OskarStark commented Apr 24, 2025

What prevents you from upgrading to version 3? Thanks

@shish
Copy link
Collaborator

shish commented Apr 24, 2025

1.x (and 2.x) have more serious and fundamental incompatibilities with 8.4 which can't be fixed short of a rewrite (which is what 3.x is) -- personally I'd rather not give people the false impression that they are compatible (though if one of the other maintainers wishes to support that use-case, I won't stop them)

Upgrading from older versions to 3.x should be nearly a drop-in replacement, so I'd strongly recommend doing that instead

(As to the code itself - you seem to have edited the auto-generated files, and not changed the generator to make it output differently? 👀 )

@MauricioFauth
Copy link
Author

What prevents you from upgrading to version 3? Thanks

It's a dependency of dependency. I have no control over it.

1.x (and 2.x) have more serious and fundamental incompatibilities with 8.4 which can't be fixed short of a rewrite

The issue with this deprecation specifically is that it's triggered when the file is loaded. Which means that just having this package as dependency will trigger deprecation for all affected functions when requiring the Composer autoloader, even if none of the functions are used. So this creates a lot a of noise if you are logging deprecations.

@MauricioFauth
Copy link
Author

As to the code itself - you seem to have edited the auto-generated files, and not changed the generator to make it output differently?

I'm not sure if it's worth regenerating all the files, as 1.x is not maintained anymore.

I used the PHP_CodeSniffer with the SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue rule to fix the functions.

@OskarStark
Copy link
Collaborator

You can, but I won't recommend that write a composer plugin which does some hacks to rewrite the code. I would rather recommend contributing to the dependency and bring support for version 3 of this library

@MauricioFauth
Copy link
Author

I meant that I used phpcs to create this PR, as I think it's not worth fixing the generator as it looks like it updates this library with new functions (unless there's a way to get the doc-en that was used to generate v1.3.3).
And newer versions of the dependency I mentioned does not use this library anymore, so there's no reason to contribute there.

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.

3 participants