[PHP 8.4] Fix implicitly nullable type declarations

Created on 15 March 2024, 8 months ago
Updated 17 June 2024, 5 months ago

Problem/Motivation

ppl

In PHP 8.4, declaring functions/methods with parameters containing null as a default value, but without null as one of the types (either as a nullable syntax or as a Union type with null) is deprecated.

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

Steps to reproduce

Run Drupal in PHP 8.4.

Proposed resolution

Update all instances of such declarations to use Union types or nullable types.

This is a rather big set of changes. To replicate the results:

cd core
../vendor/bin/phpcbf --standard=SlevomatCodingStandard --sniffs=SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue lib modules themes profiles tests

or
php-cs-fixer fix . --rules nullable_type_declaration_for_default_null_value

Add SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue sniffer to prevent new issues

Remaining tasks

- decide on merge strategy (all at once after fixing manual set or split per module/system)
- patch/commit

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

Several fixes in Drupal core to fix the deprecation notices due on implicitly nullable function/method parameter declarations.

See:

📌 Task
Status

Fixed

Version

10.3

Component
Base 

Last updated about 12 hours ago

Created by

🇱🇰Sri Lanka Ayesh Everywhere

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024