Skip to content

Commit

Permalink
src/Composer/Composer.php: fix autoloading when analyzing scip-php
Browse files Browse the repository at this point in the history
Since composer 2.6.4 [0], the autoloader suffix reuses the content-hash
from the lock file in order to make the builds more reproducible [1].
This lead to a conflict when analyzing scip-php itself when using the
Docker container.

[0] https://github.com/composer/composer/releases/tag/2.6.4
[1] composer/composer#11663
  • Loading branch information
davidrjenni committed Oct 28, 2023
1 parent ab832c2 commit 39be99a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Composer/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ public function __construct(private readonly string $projectRoot)
$vendorDir = trim($json['config']['vendor-dir'], '/');
}
$this->vendorDir = self::join($projectRoot, $vendorDir);
$this->loader = require self::join($this->vendorDir, 'autoload.php');

$projectAutoload = Reader::read(self::join($this->vendorDir, 'autoload.php'));
$scipPhpAutoload = Reader::read(self::join($this->scipPhpVendorDir, 'autoload.php'));
$autoloadDir = $projectAutoload === $scipPhpAutoload ? $this->scipPhpVendorDir : $this->vendorDir;
$this->loader = require self::join($autoloadDir, 'autoload.php');

$installed = require self::join($this->vendorDir, 'composer', 'installed.php');
$this->pkgName = $installed['root']['name'];
Expand Down

0 comments on commit 39be99a

Please sign in to comment.