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

Fix deprecation warnings thrown when used with PHP 8.4 #32

Merged
merged 3 commits into from
Nov 4, 2024

Conversation

acelaya
Copy link
Contributor

@acelaya acelaya commented Nov 1, 2024

Description

This PR fixes some warnings reported when used with PHP 8.4, due to the deprecation of implicit nullability for typed method arguments.

Motivation and context

PHP 8.4 now warns when doing things like GeneratorInterface $generator = null instead of explicitly marking the argument as nullable: ?GeneratorInterface $generator = null.

In PHP 9 this will throw an error.

This issue was reported in #31

How has this been tested?

I checked the execution of PHPUnit does not print any warning when run in PHP 8.4

Screenshots (if appropriate)

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Technically speaking, this is a bug fix, although, the approach used to solve the warning (mark arguments as nullable), requires to bump the minimum supported PHP version to 7.1

An alternative approach would be to remove the native type from arguments entirely, and rely on types defined in PHPDocs. That would allow to keep compatibility with all versions. I'm ok going in that direction if preferred.

src/Client.php Show resolved Hide resolved
@hidehalo hidehalo merged commit 3aa4f87 into hidehalo:master Nov 4, 2024
18 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