Deprecation Warning for Nullable Parameters in PHP 8.4

Created on 6 May 2025, 6 days ago

Problem/Motivation

In PHP 8.4, it is deprecated to implicitly mark a parameter as nullable without explicitly declaring the type as nullable using a ?.
This triggers a deprecation warning when a parameter has a default value of null but is not type-hinted as nullable.

Steps to reproduce

php -l src/Plugin/Action/CopyPathAction.php

Resulting in this output:
Deprecated: Drupal\fieldable_path\Plugin\Action\CopyPathAction::access(): Implicitly marking parameter $account as nullable is deprecated, the explicit nullable type must be used instead in src/Plugin/Action/CopyPathAction.php on line 44

Proposed resolution

Update the affected method signature to explicitly declare the parameter as nullable using a ? before the type name.

Before:

public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE)

After:

public function access($object, ?AccountInterface $account = NULL, $return_as_object = FALSE)
🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024