Problem/Motivation

Method "Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents()" will return "array" as of its next major version.

Steps to reproduce

Proposed resolution

Add "array" return type hint.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#8 3232097-8.patch78.76 KBlongwave
#2 3232097-2.patch81.41 KBdaffie

Comments

daffie created an issue. See original summary.

daffie’s picture

Status: Active » Needs review
StatusFileSize
new81.41 KB

The problem for adding this return type hint is that a lot of contrib modules override the method. See: http://grep.xnddx.ru/search?text=public+static+function+getSubscribedEve.... Maybe we need to wait for D10.0 to commit this patch.

catch’s picture

We should be OK to commit a patch for all the non-base classes in Drupal 9. The base classes will need to wait for Drupal 10 though.

larowlan’s picture

We should be OK to commit a patch for all the non-base classes in Drupal 9. The base classes will need to wait for Drupal 10 though.

Agree

daffie’s picture

Priority: Normal » Critical
Issue tags: +Drupal 10

Part of the Symfony 6 in D10 initiative.

longwave’s picture

Status: Needs review » Needs work

Needs work to handle the non-base classes here and a new issue to postpone the base classes until Drupal 10.

daffie’s picture

Version: 9.3.x-dev » 10.0.x-dev

Moving this to the 10.0 branch.

longwave’s picture

Version: 10.0.x-dev » 9.4.x-dev
Status: Needs work » Needs review
StatusFileSize
new78.76 KB

The abstract classes that implement this method are:

core/lib/Drupal/Core/Config/ConfigFactoryOverrideBase.php:abstract class ConfigFactoryOverrideBase implements EventSubscriberInterface {
core/lib/Drupal/Core/Config/ConfigImportValidateEventSubscriberBase.php:abstract class ConfigImportValidateEventSubscriberBase implements EventSubscriberInterface {
core/lib/Drupal/Core/EventSubscriber/HttpExceptionSubscriberBase.php:abstract class HttpExceptionSubscriberBase implements EventSubscriberInterface {
core/lib/Drupal/Core/Routing/RouteSubscriberBase.php:abstract class RouteSubscriberBase implements EventSubscriberInterface {

I reverted these changes from the patch so only concrete classes remain. I agree with #3/#4 that extending existing event subscribers is likely a non-standard thing to do and so we should be able to commit this to 9.4.x.

longwave’s picture

#2 can go into 10.0.x as it changes all classes, #8 should be able to go into 9.4.x as it changes concrete classes only.

catch’s picture

Status: Needs review » Reviewed & tested by the community

Sent #2 for a retest, think that was from when 10.x testing was broken.

Agreed both patches look ready.

alexpott’s picture

Status: Reviewed & tested by the community » Needs review

Committed 1359e7a and pushed to 10.0.x. Thanks!

I've committed #2 to 10.0.x

I think we need a little bit more discussion about committing #8 to 9.4.x. I'm not sure because I know people do extend events and potentially override getSubscribedEvents... see http://grep.xnddx.ru/search?text=parent%3A%3AgetSubscribedEvents&filename=

Personally I think we should only make this change in Drupal 10 to give people a chance to update their code because if they extend core and add the return typehint they can be 9 & 10 compatible. Setting back to needs review for more discussion.

  • alexpott committed 1359e7a on 10.0.x
    Issue #3232097 by daffie, longwave: [Symfony 6] Add "array" type hint to...
daffie’s picture

For me this is a 10.0.x change only. For me this issues can be marked as fixed.

catch’s picture

Version: 9.4.x-dev » 10.0.x-dev
Status: Needs review » Fixed

I think we should mark this fixed for 10.0.x, then re-open for backport if we discover a reason to.

Status: Fixed » Closed (fixed)

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