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

Drupal multisite compatibility.

Open dpagini opened this issue 1 year ago • 2 comments

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 avatar Jun 12 '24 16:06 dpagini

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

dpagini avatar Jun 12 '24 16:06 dpagini

I also encountered this today so +1 on this, thanks for the issue and workaround tip.

vever001 avatar Dec 03 '24 17:12 vever001