Fata error: Declaration of Drupal\Tests\preprocess_event_dispatcher\Unit\Helpers\SpyEventDispatcher::dispatch()

Created on 10 August 2023, 11 months ago

Problem/Motivation

I am not running your tests, but trying to run custom tests and getting this error

Fatal error: Declaration of Drupal\Tests\preprocess_event_dispatcher\Unit\Helpers\SpyEventDispatcher::dispatch(object $event, ?string $eventName = null): object must be compatible with Symfony\Contracts\EventDispatcher\EventDispatcherInterface::dispatch($event) in /var/www/web/modules/contrib/hook_event_dispatcher/modules/preprocess_event_dispatcher/tests/src/Unit/Helpers/SpyEventDispatcher.php on line 45

It's the object type for the $event parameter in modules/contrib/hook_event_dispatcher/modules/preprocess_event_dispatcher/tests/src/Unit/Helpers/SpyEventDispatcher.php::dispatch() that is causing the error.

version: "drupal/hook_event_dispatcher": "^4.0@beta"

Steps to reproduce

An easy way to reproduce would be to try to list the test groups with

./vendor/bin/phpunit --list-groups

Proposed resolution

I think the fix is to delete the object parameter type.

If you look at Symfony\Contracts\EventDispatcher\EventDispatcherInterface::dispatch() there isn't a type defined.

Remaining tasks

🐛 Bug report
Status

Closed: works as designed

Version

4.0

Component

Code

Created by

🇺🇸United States kamkejj WI

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

Comments & Activities

  • Issue created by @kamkejj
  • @kamkejj opened merge request.
  • Status changed to Closed: works as designed 11 months ago
  • 🇮🇩Indonesia el7cosmos 🇮🇩 GMT+7

    I assume you are using D9, 4.x branch will be targeted for D10 once it reaches RC.
    You can still use 3.x branch for D9.

  • 🇺🇸United States kamkejj WI

    We're on Drupal 9.5.x and it's an error and the modules requirement is Drupal 9.3 and above per your
    core_version_requirement: ^9.3 || ^10 in the module's .info file.

    You can close the issue, but the fact is it's broken in 9.5, which is allowed by your version requirement, so it sounds like your 4.0 branch should only be Drupal 10, core_version_requirement: ^10, and not `^9.3 || ^10`.

Production build 0.69.0 2024