Problem/Motivation
Running most drush commands results in this error:
In SiteProcess.php line 214:
The command "/__w/backend/backend/vendor/bin/drush updatedb --no-cache-clea
r --yes --uri=default --root=/__w/backend/backend/web" failed.
Exit Code: 1(General error)
Working directory:
Output:
================
Fatal error: Type of Drupal\do_username\Commands\DOCopyFieldValues::$logger
must be ?Psr\Log\LoggerInterface (as in class Drush\Commands\DrushCommands
) in /__w/backend/backend/web/modules/contrib/do_username/src/Commands/DOCo
pyFieldValues.php on line 15
Error Output:
================
Warning: [warning] Drush command terminated abnormally.
This happens for both Drush 11 and 12.
Steps to reproduce
Run a command such as `drush deploy`.
Proposed resolution
Fix the argument type error.
Comments
Comment #3
hussainwebJust removing the $logger property on the class is sufficient. That property is made available by LoggerAwareTrait anyway and the error was due to different types (it needed to be `?LoggerInterface` whereas it was missing and assumed `mixed` in the module's class).
We can still set to the property in the constructor because LoggerInterface is compatible with Drupal's `\Drupal\Core\Logger\LoggerChannelInterface`.