mglaman / phpstan-drupal

Extension for PHPStan to allow analysis of Drupal code.
https://phpstan-drupal.mglaman.dev/
MIT License
199 stars 76 forks source link

Drupal multisite compatibility. #771

Open dpagini opened 5 months ago

dpagini commented 5 months ago

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.

dpagini commented 5 months ago

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