Fix Drupal 10 - PHP Fatal error: Type of ChecklistapiCommands::$logger must be ?Psr\Log\LoggerInterface

Created on 1 March 2023, almost 2 years ago
Updated 13 April 2023, over 1 year ago

Problem/Motivation

Having the following

PHP Fatal error:  Type of Drupal\checklistapi\Commands\ChecklistapiCommands::$logger must be ?Psr\Log\LoggerInterface (as in class Drush\Commands\DrushCommands) in /var/www/html/test/drupal10test/docroot/modules/contrib/checklistapi/src/Commands/ChecklistapiCommands.php on line 18

Change records

Update code that implements \Psr\Log\LoggerInterface due to Psr/Log version 3
#3272447: Update to PSR/log v3
#3264918: Update symfony/console to Symfony 6

Proposed resolution

Have a Drupal 9 and Drupal 10 compatible logger

As in Drupal Change records
All the methods that are on \Psr\Log\LoggerInterface have stricter typehints. Contrib and custom modules that provide logger implementations will need to be updated for Drupal 10.

Typically code that uses the \Drupal\Core\Logger\RfcLoggerTrait will only need to change:

public function log($level, $message, array $context = []) {
to

public function log($level, string|\Stringable $message, array $context = []): void {

Remaining tasks

  • N/A

User interface changes

  • N/A

API changes

  • N/A

Data model changes

  • N/A
🐛 Bug report
Status

Closed: duplicate

Version

2.1

Component

Code

Created by

🇯🇴Jordan Rajab Natshah Jordan

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

Comments & Activities

Production build 0.71.5 2024