-
Notifications
You must be signed in to change notification settings - Fork 42
Description
I've just manually triggered a test run and it shows that, as things are, the tests are failing badly (100% failure rate) when running on PHP 8.4.
While there may be more deprecations impacting Patchwork, the biggest and first problem which needs to be overcome is the deprecation of implicitly nullable parameters, i.e. typed parameter with a null default value, which are not explicitly declared as nullable.
Now, the typical fix for these is to make the parameter explicitly nullable, like so:
-function relay(array $args = null)
+function relay(?array $args = null)... however, this codebase currently still has a minimum supported PHP version of PHP 5.4, which makes that impossible as the nullable parameter syntax is only available as of PHP 7.1.
Okay, so the first thing to do is decide how to solve this.
The options are:
- Remove type declarations from optional parameters which have a
nulldefault value and do in-function type validation instead.
This is a BC-break for any overloadable methods (non-finalclass, non-privatemethod) as it effectively widens the type and can cause signature mismatches for the overloaded methods. - Remove the
nulldefault value from parameters.
Well, this is a 100% BC break and not a good idea. The only case where this option would be valid is required parameters with anulldefault, but even then, it would be a BC-break for overloaded methods. - Raise the minimum supported PHP version to PHP 7.1 and make the type declarations nullable.
Note: this is not a BC-break for overloaded methods as parameters with anulldefault are already implicitly nullable, so this will not trigger a signature mismatch.
I would personally recommend option 3 and releasing this in a new minor.
Composer can do the version negotiations and install the last 2.1.x version for users still on PHP < 7.1 and the latest 2.2.x (or higher) version for PHP 7.1+.
If I look at the Packagist PHP version stats for Patchwork, PHP 5.4 - 7.0 currently translates to 6.2% of the usage of Patchwork, with the bulk of this (5.8%) being PHP 7.0, so the fast majority of users could move onto 2.2.x without issue and only a small percentage of users would need 2.1 + 2.2.
@antecedent @anomiex Care to give me your opinion ?
If support for PHP < 7.1 is dropped in the 2.2.0 release, a decision would also be needed about whether or not the 2.1 branch will still be supported for pertinent bug fixes or not.
Note: I'm willing to put in the work to create an initial patch to drop support for PHP < 7.1 and fix the implicitly nullable parameters, but would like a "go ahead" before investing the time.
Also note that this initial patch will only do the version drop and PHP 8.4 compat fixes. Other modernizations of the codebase/cleaning up of code which becomes redundant after the version drop, may need follow-up PRs.