When I run any drush command or even just drush I get the fatal error:

Fatal error: Declaration of Drupal\Core\Logger\LoggerChannel::log($level, $message, array $context = []) must be compatible with Psr\Log\LoggerTrait::log($level, Stringable|string $message, array $context = []): void in /core/lib/Drupal/Core/Logger/LoggerChannel.php on line 94

I updated drupal with composer to 9.5 and I'm running PHP 8.1. Here is my composer.json requirements:

    "require": {
        "composer/installers": "^1.9",
        "drupal/bootstrap": "^3.24",
        "drupal/captcha": "^1.2",
        "drupal/core-composer-scaffold": "^9.0.0",
        "drupal/core-project-message": "^9.0.0",
        "drupal/core-recommended": "^9.5",
        "drupal/core-vendor-hardening": "^8.8",
        "drupal/feeds": "^3.0@beta",
        "drupal/feeds_ex": "^1.0@alpha",
        "drupal/field_formatter": "^3.0@RC",
        "drupal/google_tag": "^1.5",
        "drupal/gtranslate": "^1.14",
        "drupal/honeypot": "^2.0",
        "drupal/image_popup": "^2.0",
        "drupal/mailsystem": "^4.3",
        "drupal/masquerade": "^2.0@RC",
        "drupal/menu_block": "^1.8",
        "drupal/metatag": "^1.19",
        "drupal/page_manager": "^4.0@beta",
        "drupal/paragraphs": "^1.13",
        "drupal/pathauto": "^1.9",
        "drupal/recaptcha": "^3.0",
        "drupal/recaptcha_element": "^1.0",
        "drupal/redirect": "^1.7",
        "drupal/schema_metatag": "^2.3",
        "drupal/sendgrid_integration": "^2.0@beta",
        "drupal/smtp": "^1.0",
        "drupal/twig_tweak": "^3.1",
        "drupal/views_bootstrap": "^4.3",
        "drupal/webform": "^6.1",
        "drupal/webform_spam_words": "^2.0",
        "drupal/webform_validation": "^2.0@alpha",
        "drupal/yoast_seo": "^2.0@alpha",
        "drush/drush": "^11.4",
        "google/recaptcha": "^1.2"

Here are the plugins:

    "config": {
        "sort-packages": true,
        "allow-plugins": {
            "composer/installers": true,
            "drupal/core-composer-scaffold": true,
            "drupal/core-project-message": true,
            "drupal/core-vendor-hardening": true,
            "dealerdirect/phpcodesniffer-composer-installer": true

I can't run any drush command and I get the following error if I go to my site:

Fatal error: Declaration of Drupal\dblog\Logger\DbLog::emergency($message, array $context = []) must be compatible with Psr\Log\LoggerInterface::emergency(Stringable|string $message, array $context = []): void in /core/lib/Drupal/Core/Logger/RfcLoggerTrait.php on line 20

Any suggestions on how to proceed?

EDIT* Additional Info:

PHP Version: 8.1.13

Drupal Core installed packages (from composer show -i):

drupal/core                                    9.5.0        
drupal/core-composer-scaffold                  9.4.9        
drupal/core-dev                                9.4.9       
drupal/core-project-message                    9.4.9 
drupal/core-recommended                        9.5.0  
drupal/core-vendor-hardening                   8.9.20       
  • Show us the plugins section of composer.json.
    – cilefen
    Dec 16, 2022 at 15:10
  • @cilefen Done. I also tried running php code sniffer. I got no errors in my modules. But I got a bunch of errors in core. Why would there be php 8 errors in core?
    – AlxVallejo
    Dec 16, 2022 at 15:22
  • Absent any technical information at all about what you did with php code sniffer it is not possible to comment on that matter. The error you are reporting in the question is the kind of thing that could happen if there is an opcache problem or in some cases, two installs of Drupal, which has happened if the composer/installers plugin is disabled. What is the specific PHP version? What are the actual versions of the drupal-core* projects?
    – cilefen
    Dec 16, 2022 at 15:53
  • @cilefen See the edit
    – AlxVallejo
    Dec 16, 2022 at 17:24
  • There is a comment on this other, current question which may be helpful: drupal.stackexchange.com/questions/314074/…
    – cilefen
    Dec 16, 2022 at 17:28

1 Answer 1


We discovered in chat that the reason this occurred is because there is a custom module installing its own Composer dependencies which clash with the ones loaded by Drupal.

Not the answer you're looking for? Browse other questions tagged or ask your own question.