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

`PluginManagerSetsCacheBackendRule` is currently too strict.

Open Boegie opened this issue 1 year ago • 3 comments

Feature request

Torn between a bug report or a feature request, but the latter sounds more friendly...

After the excellent work #592 landed in 1.1.37, we looked at dropping the ignore for the Missing cache backend declaration for performance. in Drupal core in https://www.drupal.org/project/drupal/issues/3320569.

As it turns out, for that the current rule is a tad too strict.

In https://www.drupal.org/project/drupal/issues/3377000#comment-15167041 I tried to boil down the requirements:

We want setCacheBackend() in every plugin class __construct(), unless:

  • it's the base class, where we define the base class as being the class that has the implementation of setCacheBackend().
  • it's a test class.
  • it has a parent that already has a setCacheBackend() in it's __construct().

Boegie avatar Aug 20 '23 13:08 Boegie

Yeah, it is a bug if it's not detecting from a parent class.

mglaman avatar Aug 20 '23 13:08 mglaman

Working on a PR as we speak/type/whatever.

Boegie avatar Aug 20 '23 14:08 Boegie