Skip to content

fix typing of nullable parameters#39199

Closed
shu-yusa wants to merge 6 commits intogrpc:masterfrom
shu-yusa:master
Closed

fix typing of nullable parameters#39199
shu-yusa wants to merge 6 commits intogrpc:masterfrom
shu-yusa:master

Conversation

@shu-yusa
Copy link
Copy Markdown
Contributor

@shu-yusa shu-yusa commented Apr 9, 2025

From PHP8.4, a parameter that has null as a default value has to be typed as a nullable type: https://www.php.net/manual/en/migration84.deprecated.php
In the code base, the factory methods of Status class have to be fixed to comply with this syntax. On the other hand, nullable type is not available in 7.0 (https://www.php.net/manual/en/migration71.new-features.php), which is supported in this library now.
Since the versions 7.0 - 8.0 have already reached the EOL (https://www.php.net/supported-versions.php) as of now, I would like to propose dropping support of these versions, and adding support of 8.4.
cc: @stanley-cheung

@shu-yusa shu-yusa marked this pull request as ready for review April 9, 2025 08:19
@shu-yusa
Copy link
Copy Markdown
Contributor Author

@wanlin31 @XuanWang-Amos @alto-php I wonder if there is anyone who could look at this 🙇‍♂️

"version": "1.73.0",
"require": {
"php": ">=7.0.0",
"php": ">=8.1.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why change this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

since the typing of a nullable functional parameter was introduced in 7.1, minimum compatible version with this syntax is 7.1. I also noticed the versions under 8.0 have reached EOL. So, I bumped the version to 8.1. But considering the impact, should we maximize acceptable versions?

@chschneider
Copy link
Copy Markdown

I think the same change should also be done to ServerCallWriter::addSendInitialMetadataOpIfNotSent

@shu-yusa
Copy link
Copy Markdown
Contributor Author

@chschneider nice catch, thank you!

@mhv666
Copy link
Copy Markdown

mhv666 commented May 12, 2025

Hi, do we know when this changes will be merged? Thank you 🙇🏽

@drakegens
Copy link
Copy Markdown

waiting on this

@shu-yusa
Copy link
Copy Markdown
Contributor Author

@stanley-cheung wouldn't you be able to take a look at this PR?
I also saw a conversation in #37563. @bshaffer wouldn't you have some advice how we can get this merged?

@stanley-cheung stanley-cheung added release notes: yes Indicates if PR needs to be in release notes kokoro:run labels Jun 24, 2025
"version": "1.73.0",
"require": {
"php": ">=7.0.0",
"php": ">=7.1.0",
Copy link
Copy Markdown
Contributor

@stanley-cheung stanley-cheung Jun 24, 2025

Choose a reason for hiding this comment

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

Sorry there's some non-obvious things about the code base here, where some template files need to match up.

Can you please make the same change in this file as well? https://github.com/grpc/grpc/blob/master/templates/src/php/composer.json.inja#L7

Thanks.

@stanley-cheung
Copy link
Copy Markdown
Contributor

This is merged. Thanks for the contributions. This will go onto the next 1.74.0 release which should happen in the next couple of weeks.

@Nyholm
Copy link
Copy Markdown
Contributor

Nyholm commented Jun 24, 2025

Wohoo, This is great news. Thank you

I have a strong recommendation for 1.74.0: This PR: #37563

It adds one line of comment (not code). This will help static analyzer tools like PHPStan to understand the types which means I will write fewer bugs in my application. That would be a BIG improvement.

@shu-yusa
Copy link
Copy Markdown
Contributor Author

@stanley-cheung thank you so much for the support! could you take a look at this PR in the mirror repository after the release? grpc/grpc-php#38

anniefrchz pushed a commit to anniefrchz/grpc that referenced this pull request Jun 25, 2025
From PHP8.4, a parameter that has `null` as a default value has to be typed as a nullable type: https://www.php.net/manual/en/migration84.deprecated.php
In the code base, the factory methods of `Status` class have to be fixed to comply with this syntax. On the other hand, nullable type is not available in 7.0 (https://www.php.net/manual/en/migration71.new-features.php), which is supported in this library now.
<strike>Since the versions 7.0 - 8.0 have already reached the EOL (https://www.php.net/supported-versions.php) as of now, I would like to propose dropping support of these versions, and adding support of 8.4.</strike>
cc: @stanley-cheung

Closes grpc#39199

COPYBARA_INTEGRATE_REVIEW=grpc#39199 from shu-yusa:master 29cc63f
PiperOrigin-RevId: 775306237
paulosjca pushed a commit to paulosjca/grpc that referenced this pull request Aug 23, 2025
From PHP8.4, a parameter that has `null` as a default value has to be typed as a nullable type: https://www.php.net/manual/en/migration84.deprecated.php
In the code base, the factory methods of `Status` class have to be fixed to comply with this syntax. On the other hand, nullable type is not available in 7.0 (https://www.php.net/manual/en/migration71.new-features.php), which is supported in this library now.
<strike>Since the versions 7.0 - 8.0 have already reached the EOL (https://www.php.net/supported-versions.php) as of now, I would like to propose dropping support of these versions, and adding support of 8.4.</strike>
cc: @stanley-cheung

Closes grpc#39199

COPYBARA_INTEGRATE_REVIEW=grpc#39199 from shu-yusa:master 29cc63f
PiperOrigin-RevId: 775306237
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang/php release notes: yes Indicates if PR needs to be in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants