Skip to content

[BUGFIX] Ensure PHP 8.4 compatibility for nullable parameters #677

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

Closed
wants to merge 1 commit into from

Conversation

oliverklee
Copy link
Collaborator

Ensure that parameters that have a null default value also have null as part of their type annotations.

Also remove native type declarations for nullable parameters (as nullable parameters are not possible with some of the PHP versions we currently support).

https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated

Fixes #634

@oliverklee oliverklee added this to the 8.6.1 or 8.7.0 milestone Aug 26, 2024
@oliverklee oliverklee self-assigned this Aug 26, 2024
@oliverklee
Copy link
Collaborator Author

oliverklee commented Aug 26, 2024

This is the backport of #643.

@oliverklee
Copy link
Collaborator Author

oliverklee commented Aug 26, 2024

Another note: This blocks PHP 8.4 support for Emogrifier: MyIntervals/emogrifier#1278

@oliverklee oliverklee force-pushed the backport/nullable-paramter branch 2 times, most recently from c6c9f34 to e421dd4 Compare August 26, 2024 16:05
Copy link
Collaborator

@JakeQZ JakeQZ left a comment

Choose a reason for hiding this comment

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

I think something has gone awry in the merge.

The original change affected only 4 files. This affects 22. It looks like you have omitted a git pull.

Comment on lines +60 to +64
* @param OutputFormat $oOutputFormat
*
* @return string
*/
public function render(OutputFormat $oOutputFormat)
public function render($oOutputFormat)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't look right. It seems to be reverting a previous change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it's removing the type declaration.

The reason for this that there are two possible ways to fix the implicit nullable parameters:

  1. make the parameters explicitly nullable using a native type declaration (which is not possible with PHP 5.6, which we support in this branch)
  2. drop the native type declaration for this parameter and use PHPDoc type annotations instead

I'll create a separate pre-PR to do 2. first (without changing the type).

Copy link
Collaborator

Choose a reason for hiding this comment

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

There is another way, which is to make a 9.0 release with where we're at. The only breaking change I'm aware of is requiring PHP >= 7.2.

@oliverklee oliverklee marked this pull request as draft August 27, 2024 07:26
@oliverklee oliverklee force-pushed the backport/nullable-paramter branch from e421dd4 to 39a7c72 Compare August 28, 2024 22:05
Ensure that parameters that have a `null` default value also
have `null` as part of their type annotations.

Also remove native type declarations for nullable parameters
(as nullable parameters are not possible with some of the PHP
versions we currently support).

https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated

Fixes #634
@oliverklee oliverklee force-pushed the backport/nullable-paramter branch from 39a7c72 to f65d376 Compare September 1, 2024 15:03
@oliverklee
Copy link
Collaborator Author

According to #701, this change does not seem to be necessary after all. Closing.

@oliverklee oliverklee closed this Sep 3, 2024
@oliverklee oliverklee deleted the backport/nullable-paramter branch September 3, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants