phpstan-drupal icon indicating copy to clipboard operation
phpstan-drupal copied to clipboard

Detect deprecated Drupal\Core\Routing\RouteSubscriberBase::getSubscribedEvents(): array

Open joachim-n opened this issue 1 year ago • 4 comments

Feature request

I had a custom class that extended Drupal\Core\Routing\RouteSubscriberBase.

The old code had:

  public static function getSubscribedEvents(): {

which was not compatible with D10 RouteSubscriberBase's

  public static function getSubscribedEvents(): array {

joachim-n avatar Dec 05 '23 17:12 joachim-n

This also happened with classes that implement EventSubscriberInterface without a base class.

joachim-n avatar Dec 05 '23 17:12 joachim-n

This should have been caught by PHPStan at level 2. I thought.

mglaman avatar Dec 05 '23 20:12 mglaman

I was using the Upgrade Status module -- sorry I don't know whether issues with deprecations should go on that module or here.

It didn't report any deprecations about getSubscribedEvents -- I had about 8 in total.

joachim-n avatar Dec 05 '23 20:12 joachim-n

Ah yeah it does level nothing.

But even if it did, I forgot this wouldn't be caught. Because Symfony would still be old. So it's a valid thing to have and catch.

A forward checking return type rule.

mglaman avatar Dec 06 '23 01:12 mglaman