Problem/Motivation

PHP 8.4 has deprecated implicit nullable types.

Steps to reproduce

Use in a PHP 8.4 environment

Proposed resolution

Use explicit nullable types (compatible with PHP 7.1+ so no compatibility concerns given Drupal core PHP minimums)

NOTE: this will almost certainly break backwards compatibility with other modules that extend this given the number of changed function signatures. It may be worthwhile/necessary to create a new major release.

Issue fork search_api-3492380

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nickdickinsonwilde created an issue. See original summary.

nickdickinsonwilde’s picture

Status: Active » Needs review
drunken monkey’s picture

Status: Needs review » Fixed

Thanks a lot for creating this issue and already providing a great merge request!

I don’t think we’ll have any problems with backwards compatibility here since making the nullability explicit makes no difference to PHP (except for the deprecation warning in PHP 8.4+). To test, just run the following locally (or run it on 3v4l.org):

class A {
  function foo(array $a = NULL) {}
}
class B extends A {
  function foo(?array $a = NULL) {}
}
class C extends B {
  function foo(array $a = NULL) {}
}

No warnings at all for PHP 8.3 and lower, just the expected deprecation warnings for 8.4.

No idea what went wrong with your pipeline there, but just re-running it worked fine. So, merged.
Thanks again!

drunken monkey’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

liam morland’s picture

It would be very helpful to get a release with this change. Modules that depend on this module also display messages about this on PHP 8.4.

PHP does not see this as a change in the function signature, so a major version update is not needed.