“Declaration of <function> must be compatible with <interface>” in Drupal 8.6.10
-
07-02-2021 - |
Question
Up until Saturday I had a functioning Drupal 8.6.x instance. The I did
composer update
and Drupal 8.6.10 was installed. Since then I get the following in my error logs:
Declaration of Drupal\Core\Template\TwigTransTokenParser::parse(Twig_Token $token) must be compatible with Twig\TokenParser\TokenParserInterface::parse(Twig\Token $token)
and Drush fails with
Robo\Robo::configureContainer() must be an instance of Robo\Config\Config, instance of Drush\Config\DrushConfig given
I use PHP 7.2 on Ubuntu 18.04.
I did a clean reinstall of Drupal 8.6.10 and the same things occur. I've tried to replace 8.6.10 with 8.6.9 and even 8.6.0 but I still get these errors. If it were Java, I would suspect that the interface and the class had been compiled with different versions of the compiler. But I don't know PHP well enough to know where to start. These errors seem to me to be in core: all my code is under modules/xxx.
Any hints?
Steve
Solution
It is a global issue on this new Twig version 1.38.0.
I can be temporarily fixed by downgrading its version using composer require twig/twig:1.37.1
You can follow this issue to know when the Twig version can be updated again.