1
0
Fork 0

Add `dumpautoload --dry-run` option (#11608)

pull/11616/head
Travis Carden 2023-08-31 04:35:02 -04:00 committed by GitHub
parent 6fd145f01e
commit 1c4ac1c437
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -70,6 +70,11 @@ class AutoloadGenerator
*/
private $apcuPrefix;
/**
* @var bool
*/
private $dryRun = false;
/**
* @var bool
*/
@ -127,6 +132,14 @@ class AutoloadGenerator
$this->runScripts = $runScripts;
}
/**
* Whether to run in drymode or not
*/
public function setDryRun(bool $dryRun = true): void
{
$this->dryRun = $dryRun;
}
/**
* Whether platform requirements should be ignored.
*
@ -398,6 +411,10 @@ EOF;
}
}
if ($this->dryRun) {
return $classMap;
}
$filesystem->filePutContentsIfModified($targetDir.'/autoload_namespaces.php', $namespacesFile);
$filesystem->filePutContentsIfModified($targetDir.'/autoload_psr4.php', $psr4File);
$filesystem->filePutContentsIfModified($targetDir.'/autoload_classmap.php', $classmapFile);

View File

@ -37,6 +37,7 @@ class DumpAutoloadCommand extends BaseCommand
new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize`.'),
new InputOption('apcu', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
new InputOption('apcu-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu'),
new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything.'),
new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables autoload-dev rules. Composer will by default infer this automatically according to the last install or update --no-dev state.'),
new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables autoload-dev rules. Composer will by default infer this automatically according to the last install or update --no-dev state.'),
new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
@ -83,6 +84,9 @@ EOT
}
$generator = $composer->getAutoloadGenerator();
if ($input->getOption('dry-run')) {
$generator->setDryRun(true);
}
if ($input->getOption('no-dev')) {
$generator->setDevMode(false);
}