Problem/Motivation

When using this module in tests at 10.3+ we get the deprecation message

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

Entity API is a dependency from Commerce module, and hence also needed when testing modules which integrate with Commerce

Steps to reproduce

See Scheduler MR161 which fixes the Scheduler test eventsubscriber. However, the pipelines still have many deprecations due to Entity API
https://git.drupalcode.org/project/scheduler/-/jobs/2301653#L482

Proposed resolution

Add array return type in the definition of EntityDuplicateSubscriber()

Issue fork entity-3465393

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

Looking at the pipelines for Entity API there are no errors shown for this at Next Major, so maybe the test coverage does not include this event subscriber?

I will create a MR for the oneline change, and then see if I can include it in Scheduler testing, to demonstrate the fix.

jonathan1055’s picture

Issue summary: View changes
Status: Active » Needs review

That worked nicely. I added this MR via the composer file, in this commit

Before
https://git.drupalcode.org/project/scheduler/-/jobs/2301653
Search for "EntityDuplicateSubscriber" and see 24 occcurences of the error

After
https://git.drupalcode.org/project/scheduler/-/jobs/2311391
No text "EntityDuplicateSubscriber" because that error is fixed.

ankitv18’s picture

Status: Needs review » Reviewed & tested by the community

Quite straightforward ~~ Marking this one RTBC to move things ahead.

jonathan1055’s picture

Issue summary: View changes

Thanks. I'm using this MR branch in a temporary swapped-in composer.json for D11 testing. When the change is committed, I should be able to alter the dependency from
"drupal/entity": "dev-3465393-EntityDuplicateSubscriber-array-return as 1.0",
to just
"drupal/entity": "dev-1.x as 1.0",

berdir made their first commit to this issue’s fork.

berdir’s picture

Status: Reviewed & tested by the community » Fixed

Merged.

  • berdir committed 3226dce7 on 8.x-1.x authored by jonathan1055
    Issue #3465393 by jonathan1055: Add 'array' return type in Drupal\entity...

Status: Fixed » Closed (fixed)

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