diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 953079d3b..30bb2c1df 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -37,6 +37,9 @@ use Composer\Json\JsonFile; */ class AutoloadGenerator { + + private const AUTOLOAD_FILE = "/autoload.php"; + /** * @var EventDispatcher */ @@ -379,8 +382,8 @@ EOF; $suffix = $config->get('autoloader-suffix'); // carry over existing autoload.php's suffix if possible and none is configured - if (null === $suffix && Filesystem::isReadable($vendorPath.'/autoload.php')) { - $content = file_get_contents($vendorPath.'/autoload.php'); + if (null === $suffix && Filesystem::isReadable($vendorPath.self::AUTOLOAD_FILE)) { + $content = file_get_contents($vendorPath.self::AUTOLOAD_FILE); if (Preg::isMatch('{ComposerAutoloaderInit([^:\s]+)::}', $content, $match)) { $suffix = $match[1]; } @@ -421,7 +424,7 @@ EOF; } elseif (file_exists($targetDir.'/platform_check.php')) { unlink($targetDir.'/platform_check.php'); } - $filesystem->filePutContentsIfModified($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix)); + $filesystem->filePutContentsIfModified($vendorPath.self::AUTOLOAD_FILE, $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix)); $filesystem->filePutContentsIfModified($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $checkPlatform)); $filesystem->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');