phpstan-drupal
phpstan-drupal copied to clipboard
Drupal multisite compatibility.
Feature request
From #phpstan Drupal slack:
In my project, I am using Drupal multisite, and have modules defined at docroot/sites/mysite/modules/____.
So let's say I have 2 modules... docroot/sites/mysite/modules/mySiteModule1 and docroot/sites/mysite/modules/mySiteModule2 - in mySiteModule2 I am referencing a class defined in mySiteModule1, but PHPStan is telling me that class doesn't exist.
I'm referencing a class like use Drupal\mySiteModule1\Controller\MyBaseController.
From @mglaman, in case anyone stumbles on this issue...
phpstan-drupal does not support modules in sites directories for discovery.
A manual fix, is to add scanDirectories for the sites directories per https://phpstan.org/user-guide/discovering-symbols#third-party-code-outside-of-composer-dependencies
phpstan-drupal could get a feature request to try and parse sites/sites.php and try to do extension discovery and such for known site directories
I also encountered this today so +1 on this, thanks for the issue and workaround tip.