From 0a65846e9e5f0926bc2e42495dd2222a51230ca8 Mon Sep 17 00:00:00 2001 From: David Jenni Date: Sat, 28 Oct 2023 08:30:17 +0200 Subject: [PATCH] src/Composer/Composer.php: fix autoloading when analyzing scip-php 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] https://github.com/composer/composer/pull/11663 --- src/Composer/Composer.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Composer/Composer.php b/src/Composer/Composer.php index 99d78e1..e771b95 100644 --- a/src/Composer/Composer.php +++ b/src/Composer/Composer.php @@ -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'];