Problem/Motivation

PHPunit tests at Next Major give the following error:

Method "Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents()" might add "array" as a native return type declaration in the future. Do the same in implementation "Drupal\scheduler_api_test\EventSubscriber" now to avoid errors or add an explicit @return annotation to suppress this message.

Triggered by: Drupal\Tests\scheduler\Functional\SchedulerEventsTest::testNodeEvents

Next Major (D11) composer shows symfony/event-dispatcher (v7.1.1)
Current and Next Minor (D10) composer jobs show symfony/event-dispatcher (v6.4.8)

Proposed resolution

Add return type hint array to the EventSubscriber definition

Issue fork scheduler-3465213

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jonathan1055 created an issue. See original summary.

jonathan1055’s picture

Status: Active » Needs review

Without this fix, group 'scheduler' has this error 24 x for "Drupal\entity\EventSubscriber\EntityDuplicateSubscriber"
'scheduler_api' has 7 (4 for Drupal\entity\EventSubscriber\EntityDuplicateSubscriber, 3 for Drupal\scheduler_api_test\EventSubscriber)
javascript tests has 2 x Drupal\entity\EventSubscriber\EntityDuplicateSubscriber
rules tests shows none, but that could be because the module can't be installed.
kernel has none.

With the correction, the scheduler_api test no longer has the 3 errors for scheduler_api_test\EventSubscriber, but still just has the 4 that are for Drupal\entity\EventSubscriber\EntityDuplicateSubscriber. The main scheduler group still has the 24 errors for Drupal\entity\EventSubscriber. This is the core module, so why has that not been fixed?

jonathan1055’s picture

jonathan1055’s picture

Issue summary: View changes

In the last commit, using the repo from Entity API mr35, the deprecation errors have all been removed. Composer Next Major has drupal/entity (dev-3465393-EntityDuplicateSubscriber-array-return 4aef0ed) which shows that the MR repo is being used.

  • jonathan1055 committed 6d46db4f on 2.x
    Issue #3465213 by jonathan1055: Add 'array' return type in...
jonathan1055’s picture

Status: Needs review » Fixed

I decided to commit this as-is. There is no need to wait until #3465393: Add 'array' return type in Drupal\entity\EventSubscriber\EntityDuplicateSubscriber is committed. When that does happen, the composer_next_major.json may cause a problem, in which case it can be modified to use the dev branch of Entity instead of the MR.

But for now, this fixes lots of errors in the Next Major test, and is a big step forward in getting clean PHPUnit tests, and hence readable and usable logs (not filled with error messages)

  • jonathan1055 committed 72fe92cf on 8.x-1.x
    Issue #3465213 by jonathan1055: Add 'array' return type in...
jonathan1055’s picture

Backported to 8.x-1.x
Drupal 11 PHPUnit and PHPstan jobs are now all green for 8.x-1.x

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.