Open
Description
Feature request
Various hacks are needed if drupal/core
is in the vendor directory. The drupal-finder
package doesn't support this (and probably shouldn't.) But we can in the autoloader: https://github.com/mglaman/phpstan-drupal/blob/main/src/Drupal/DrupalAutoloader.php#L60-L69
$drupalRoot = $finder->getDrupalRoot();
$drupalVendorRoot = $finder->getVendorDir();
if (! (bool) $drupalRoot || ! (bool) $drupalVendorRoot) {
throw new \RuntimeException("Unable to detect Drupal at {$drupalParams['drupal_root']}");
}
Instead of throwing a runtime exception here, try using Composer's installed paths to find drupal/core
:
\Composer\InstalledVersions::getInstallPath('drupal/core')
Then less hacks are needed.