From 6e851edd701f8ce11fdfadaf28bc0e9198826c33 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 7 Jun 2021 15:48:37 +0200 Subject: [PATCH] Add `--dev` to `dump-autoload` command to allow force-dumping dev autoload rules even if dev requirements are not present, fixes #9946 --- doc/03-cli.md | 2 ++ src/Composer/Command/DumpAutoloadCommand.php | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/doc/03-cli.md b/doc/03-cli.md index 2933a2168..c35eabb61 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -865,6 +865,8 @@ performance. Implicitly enables `--apcu`. * **--no-dev:** Disables autoload-dev rules. Composer will by default infer this automatically according to the last `install` or `update` `--no-dev` state. +* **--dev:** Enables autoload-dev rules. Composer will by default infer this + automatically according to the last `install` or `update` `--no-dev` state. * **--ignore-platform-reqs:** ignore all `php`, `hhvm`, `lib-*` and `ext-*` requirements and skip the [platform check](07-runtime.md#platform-check) for these. See also the [`platform`](06-config.md#platform) config option. diff --git a/src/Composer/Command/DumpAutoloadCommand.php b/src/Composer/Command/DumpAutoloadCommand.php index e6fe3d7e5..7a5fcd5c7 100644 --- a/src/Composer/Command/DumpAutoloadCommand.php +++ b/src/Composer/Command/DumpAutoloadCommand.php @@ -35,6 +35,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('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).'), new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'), @@ -81,6 +82,12 @@ EOT if ($input->getOption('no-dev')) { $generator->setDevMode(false); } + if ($input->getOption('dev')) { + if ($input->getOption('no-dev')) { + throw new \InvalidArgumentException('You can not use both --no-dev and --dev as they conflict with each other.'); + } + $generator->setDevMode(true); + } $generator->setClassMapAuthoritative($authoritative); $generator->setApcu($apcu, $apcuPrefix); $generator->setIgnorePlatformRequirements($ignorePlatformReqs);