jhedstrom / drupalextension

An integration layer between Behat, Mink Extension, and Drupal.
GNU General Public License v2.0
209 stars 192 forks source link

PHP Fatal Error with PHP 8.2 when using `drupal` api driver #659

Open bserem opened 5 months ago

bserem commented 5 months ago

On projects that get updated to PHP 8.2 we get the following issue when trying to run API tests:

PHP Fatal error:  Declaration of Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::addListener($event_name, $listener, $priority = 0) must be compatible with Symfony\Component\EventDispatcher\EventDispatcherInterface::addListener(string $eventName, callable $listener, int $priority = 0): void in /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php on line 217

I suspect it's the PHP version, if someone else can also verify

bserem commented 5 months ago

As a temporary workaround, passing php 8.1 as a dependency in composer.json gets the jb done:

  "config": {
    "bin-dir": "bin/",
    "platform": {
        "php": "8.1"
    }
  },
pfrenssen commented 4 months ago

Are you sure this is caused by drupalextension code? It is not clear from the report where the error is originating or how to replicate it. It could also be possible it is thrown in Drupal itself or in the jhedstrom/DrupalDriver project. Can you perhaps provide a full backtrace?

bserem commented 3 weeks ago

@pfrenssen how can I generate a full backtrace?

The problem seems to be that Drupal requires symfony/event-dispatcher:6.4.2 whereas drupalextension install symfony/event-dispatcher:7.1.1 unless you restrict it manually.

(sorry for the late reply, life got in the way)