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

Make nullable parameters explicitly nullable #1205

Merged
merged 1 commit into from
Nov 1, 2024

Conversation

barryhughes
Copy link
Member

For improved compatibility with PHP 8.4, and to reduce the amount of error noise we see when running under that version, this change fixes a number of method signatures where parameters are implicitly nullable. For example:

public function __construct( ActionScheduler_Store $store = null, $batch_size = 20 )

$store must be of type ActionScheduler_Store, but if not specified by the caller it is set to null. This is fine, but as of PHP 8.4 we are encouraged to be explicit about it, so we need:

public function __construct( ?ActionScheduler_Store $store = null, $batch_size = 20 ) {

The problem with the above is that ?Type is only valid from PHP 7.1 onwards, whereas we still support PHP 7.0. We also cannot yet use type unions. So, we have a decision to make:

  • Bump the minimum supported version of PHP (feels reasonable if it's a small adjustment, from 7.0 to 7.1).
  • Dispense with this change and put up with the warning/error noise.

@barryhughes barryhughes force-pushed the fix/php84-nullables-must-be-explicit branch from d3bbfa8 to f0fd32d Compare October 30, 2024 21:38
@barryhughes barryhughes requested review from a team and coreymckrill and removed request for a team October 30, 2024 21:39
@barryhughes
Copy link
Member Author

barryhughes commented Oct 30, 2024

💡 Please note that (assuming we are ultimately happy with this change) we should not merge ahead of #1212, which increases the minimum required PHP version to 7.1. Even so, it felt like there was no particular reason to delay review and testing.

(The test fails you will see all relate to PHP 7.0 ... that version will be removed from the test matrix via the other PR I mentioned.)

@barryhughes barryhughes force-pushed the fix/php84-nullables-must-be-explicit branch from 9c65d1c to 2720a77 Compare November 1, 2024 18:04
@barryhughes
Copy link
Member Author

Thanks for the review. Rebased following the merge of #1212, and will merge this if/once all our checks pass.

@barryhughes barryhughes merged commit a2e0549 into trunk Nov 1, 2024
34 checks passed
@barryhughes barryhughes deleted the fix/php84-nullables-must-be-explicit branch November 1, 2024 18:06
@barryhughes barryhughes added this to the 3.9.0 milestone Nov 1, 2024
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