parent
bb0edce095
commit
0a8dfe6ef7
|
@ -315,8 +315,8 @@ with other autoloaders.
|
||||||
|
|
||||||
## autoloader-suffix
|
## autoloader-suffix
|
||||||
|
|
||||||
Defaults to `null`. String to be used as a suffix for the generated Composer
|
Defaults to `null`. Non-empty string to be used as a suffix for the generated
|
||||||
autoloader. When null a random one will be generated.
|
Composer autoloader. When null a random one will be generated.
|
||||||
|
|
||||||
## optimize-autoloader
|
## optimize-autoloader
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ parameters:
|
||||||
- '../src/Composer/Console/HtmlOutputFormatter.php'
|
- '../src/Composer/Console/HtmlOutputFormatter.php'
|
||||||
|
|
||||||
reportUnmatchedIgnoredErrors: false
|
reportUnmatchedIgnoredErrors: false
|
||||||
|
treatPhpDocTypesAsCertain: false
|
||||||
|
|
||||||
ignoreErrors:
|
ignoreErrors:
|
||||||
# unused parameters
|
# unused parameters
|
||||||
|
|
|
@ -159,12 +159,12 @@ class AutoloadGenerator
|
||||||
/**
|
/**
|
||||||
* @param string $targetDir
|
* @param string $targetDir
|
||||||
* @param bool $scanPsrPackages
|
* @param bool $scanPsrPackages
|
||||||
* @param string $suffix
|
* @param string|null $suffix
|
||||||
* @return int
|
* @return int
|
||||||
* @throws \Seld\JsonLint\ParsingException
|
* @throws \Seld\JsonLint\ParsingException
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
*/
|
*/
|
||||||
public function dump(Config $config, InstalledRepositoryInterface $localRepo, RootPackageInterface $rootPackage, InstallationManager $installationManager, $targetDir, $scanPsrPackages = false, $suffix = '')
|
public function dump(Config $config, InstalledRepositoryInterface $localRepo, RootPackageInterface $rootPackage, InstallationManager $installationManager, $targetDir, $scanPsrPackages = false, $suffix = null)
|
||||||
{
|
{
|
||||||
if ($this->classMapAuthoritative) {
|
if ($this->classMapAuthoritative) {
|
||||||
// Force scanPsrPackages when classmap is authoritative
|
// Force scanPsrPackages when classmap is authoritative
|
||||||
|
@ -374,16 +374,23 @@ EOF;
|
||||||
}
|
}
|
||||||
$classmapFile .= ");\n";
|
$classmapFile .= ");\n";
|
||||||
|
|
||||||
if (!$suffix) {
|
if ('' === $suffix) {
|
||||||
if (!$config->get('autoloader-suffix') && Filesystem::isReadable($vendorPath.'/autoload.php')) {
|
$suffix = null;
|
||||||
|
}
|
||||||
|
if (null === $suffix) {
|
||||||
|
$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');
|
$content = file_get_contents($vendorPath.'/autoload.php');
|
||||||
if (Preg::isMatch('{ComposerAutoloaderInit([^:\s]+)::}', $content, $match)) {
|
if (Preg::isMatch('{ComposerAutoloaderInit([^:\s]+)::}', $content, $match)) {
|
||||||
$suffix = $match[1];
|
$suffix = $match[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$suffix) {
|
// generate one if we still haven't got a suffix
|
||||||
$suffix = $config->get('autoloader-suffix') ?: md5(uniqid('', true));
|
if (null === $suffix) {
|
||||||
|
$suffix = md5(uniqid('', true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -427,6 +427,13 @@ class Config
|
||||||
|
|
||||||
return $protos;
|
return $protos;
|
||||||
|
|
||||||
|
case 'autoloader-suffix':
|
||||||
|
if ($this->config[$key] === '') { // we need to guarantee null or non-empty-string
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->process($this->config[$key], $flags);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (!isset($this->config[$key])) {
|
if (!isset($this->config[$key])) {
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue