Fix PHP 8.4 deprecations

Created on 30 November 2024, 22 days ago

Problem/Motivation

PHP 8.4 deprecates implicitly marking parameters as nullable. A fresh install of metatag results in deprecation warnings like this:

Deprecated: Drupal\metatag\MetatagToken::replace(): Implicitly marking parameter $bubbleable_metadata as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/metatag/src/MetatagToken.php on line 60

Deprecated: Drupal\metatag\MetatagManager::form(): Implicitly marking parameter $included_groups as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/metatag/src/MetatagManager.php on line 327

Deprecated: Drupal\metatag\MetatagManager::form(): Implicitly marking parameter $included_tags as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/metatag/src/MetatagManager.php on line 327

Deprecated: Drupal\metatag\MetatagManager::getDefaultMetatags(): Implicitly marking parameter $entity as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/metatag/src/MetatagManager.php on line 458

Deprecated: Drupal\metatag\MetatagManager::generateRawElements(): Implicitly marking parameter $cache as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/metatag/src/MetatagManager.php on line 582

This is fixed by the latest Drupal coding standards, but the phpcs issue for this module is stalled ( 📌 Resolve phpcs issues in 2.0.x / 2.1.x Active ), so I'm creating a fix for only the nullable deprecation warning here.

📌 Task
Status

Active

Version

2.1

Component

Code

Created by

🇯🇵Japan ptmkenny

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