Refact "/autoload.php" literal to constant
continuous-integration/drone/push Build is passing Details

main
Hugo Thunnissen 2 years ago
parent f9d2feb9cb
commit 3d0b46c8b0

@ -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');

Loading…
Cancel
Save