phpstan-drupal
phpstan-drupal copied to clipboard
`PluginManagerSetsCacheBackendRule` is currently too strict.
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()
.
Yeah, it is a bug if it's not detecting from a parent class.
Working on a PR as we speak/type/whatever.