Problem
src/Drupal/DrupalAutoloader.php uses DrupalFinder\DrupalFinder and its locateRoot() method, which were deprecated in drupal-finder 1.3.0 and removed in 2.0.0. Currently phpstan-baseline.neon suppresses 5 errors related to this usage:
Call to deprecated method locateRoot() of class DrupalFinder\DrupalFinder
Instantiation of deprecated class DrupalFinder\DrupalFinder
- Two type mismatch errors caused by the old API returning
bool|string
When the composer constraint eventually allows drupal-finder 2.x, this will cause a hard runtime crash during analysis.
Proposed resolution
Replace DrupalFinder\DrupalFinder with DrupalFinder\DrupalFinderComposerRuntime, which accepts a starting path in its constructor and provides the same getDrupalRoot() / getVendorDir() methods without the deprecated locateRoot() call.
// Before
$finder = new DrupalFinder();
$finder->locateRoot(getcwd());
$this->drupalRoot = $finder->getDrupalRoot();
// After
$finder = new DrupalFinderComposerRuntime();
$this->drupalRoot = $finder->getDrupalRoot();
After migrating, the 5 baseline suppressions in phpstan-baseline.neon for DrupalAutoloader.php should be removed.
Problem
src/Drupal/DrupalAutoloader.phpusesDrupalFinder\DrupalFinderand itslocateRoot()method, which were deprecated in drupal-finder 1.3.0 and removed in 2.0.0. Currentlyphpstan-baseline.neonsuppresses 5 errors related to this usage:Call to deprecated method locateRoot() of class DrupalFinder\DrupalFinderInstantiation of deprecated class DrupalFinder\DrupalFinderbool|stringWhen the composer constraint eventually allows drupal-finder 2.x, this will cause a hard runtime crash during analysis.
Proposed resolution
Replace
DrupalFinder\DrupalFinderwithDrupalFinder\DrupalFinderComposerRuntime, which accepts a starting path in its constructor and provides the samegetDrupalRoot()/getVendorDir()methods without the deprecatedlocateRoot()call.After migrating, the 5 baseline suppressions in
phpstan-baseline.neonforDrupalAutoloader.phpshould be removed.