From f29e98cdf936679b20d1e6372ad0ae3be92fbbec Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Mon, 11 Sep 2017 11:16:15 -0400 Subject: [PATCH 01/10] Fixes #6661: Allow a given package and its dependencies (including siblings) to be updated. --- src/Composer/Command/RemoveCommand.php | 2 +- src/Composer/Command/RequireCommand.php | 3 +- src/Composer/Command/UpdateCommand.php | 6 ++- src/Composer/Installer.php | 28 ++++++++++-- .../update-with-all-dependencies.test | 44 +++++++++++++++++++ tests/Composer/Test/InstallerTest.php | 3 +- 6 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 tests/Composer/Test/Fixtures/installer/update-with-all-dependencies.test diff --git a/src/Composer/Command/RemoveCommand.php b/src/Composer/Command/RemoveCommand.php index 048baace0..ec6f64308 100644 --- a/src/Composer/Command/RemoveCommand.php +++ b/src/Composer/Command/RemoveCommand.php @@ -131,7 +131,7 @@ EOT ->setApcuAutoloader($apcu) ->setUpdate(true) ->setUpdateWhitelist($packages) - ->setWhitelistDependencies(!$input->getOption('no-update-with-dependencies')) + ->setIndirectWhitelistDependencies(!$input->getOption('no-update-with-dependencies')) ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs')) ->setRunScripts(!$input->getOption('no-scripts')) ; diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index 354c661ad..012ed354a 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -169,7 +169,8 @@ EOT ->setApcuAutoloader($apcu) ->setUpdate(true) ->setUpdateWhitelist(array_keys($requirements)) - ->setWhitelistDependencies($input->getOption('update-with-dependencies')) + ->setIndirectWhitelistDependencies($input->getOption('update-with-dependencies')) + ->setAllWhitelistDependencies($input->getOption('update-with-all-dependencies')) ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs')) ->setPreferStable($input->getOption('prefer-stable')) ->setPreferLowest($input->getOption('prefer-lowest')) diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index 9444f6f77..ac047c41a 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -48,7 +48,8 @@ class UpdateCommand extends BaseCommand new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'), new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'), new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'Do not show package suggestions.'), - new InputOption('with-dependencies', null, InputOption::VALUE_NONE, 'Add also all dependencies of whitelisted packages to the whitelist.'), + new InputOption('with-dependencies', null, InputOption::VALUE_NONE, 'Add also dependencies of whitelisted packages to the whitelist, if those dependencies are not defined in root package.'), + new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Add also all dependencies of whitelisted packages to the whitelist.'), new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'), new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump.'), new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'), @@ -145,7 +146,8 @@ EOT ->setApcuAutoloader($apcu) ->setUpdate(true) ->setUpdateWhitelist($input->getOption('lock') ? array('lock') : $packages) - ->setWhitelistDependencies($input->getOption('with-dependencies')) + ->setIndirectWhitelistDependencies($input->getOption('with-dependencies')) + ->setAllWhitelistDependencies($input->getOption('with-all-dependencies')) ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs')) ->setPreferStable($input->getOption('prefer-stable')) ->setPreferLowest($input->getOption('prefer-lowest')) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 55ec51baf..932b220e2 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -126,6 +126,7 @@ class Installer */ protected $updateWhitelist = null; protected $whitelistDependencies = false; + protected $whitelistAllDependencies = false; /** * @var SuggestedPackagesReporter @@ -1351,7 +1352,7 @@ class Installer $seen[$package->getId()] = true; $this->updateWhitelist[$package->getName()] = true; - if (!$this->whitelistDependencies) { + if (!$this->whitelistDependencies && !$this->whitelistAllDependencies) { continue; } @@ -1361,7 +1362,7 @@ class Installer $requirePackages = $pool->whatProvides($require->getTarget()); foreach ($requirePackages as $requirePackage) { - if (isset($this->updateWhitelist[$requirePackage->getName()])) { + if (!$this->whitelistAllDependencies && isset($this->updateWhitelist[$requirePackage->getName()])) { continue; } @@ -1652,18 +1653,37 @@ class Installer } /** - * Should dependencies of whitelisted packages be updated recursively? + * Should indirect dependencies of whitelisted packages be updated? + * + * This will NOT whitelist any dependencies that are also directly defined + * in the root package. * * @param bool $updateDependencies * @return Installer */ - public function setWhitelistDependencies($updateDependencies = true) + public function setIndirectWhitelistDependencies($updateDependencies = true) { $this->whitelistDependencies = (bool) $updateDependencies; return $this; } + /** + * Should all dependencies of whitelisted packages be updated recursively? + * + * This will NOT whitelist any dependencies that are also defined in the + * root package. + * + * @param bool $updateAllDependencies + * @return Installer + */ + public function setAllWhitelistDependencies($updateAllDependencies = true) + { + $this->whitelistAllDependencies = (bool) $updateAllDependencies; + + return $this; + } + /** * Should packages be preferred in a stable version when updating? * diff --git a/tests/Composer/Test/Fixtures/installer/update-with-all-dependencies.test b/tests/Composer/Test/Fixtures/installer/update-with-all-dependencies.test new file mode 100644 index 000000000..7e2573f9c --- /dev/null +++ b/tests/Composer/Test/Fixtures/installer/update-with-all-dependencies.test @@ -0,0 +1,44 @@ +--TEST-- + +See Github issue #6661 ( github.com/composer/composer/issues/6661 ). + +When `with-all-dependencies` is used, Composer\Installer::whitelistUpdateDependencies should update all whitelisted dependencies, even if the dependency is a root requirement. + +--COMPOSER-- +{ + "repositories": [ + { + "type": "package", + "package": [ + { "name": "a", "version": "1.0.0" }, + { "name": "a", "version": "1.1.0" }, + { "name": "b", "version": "1.0.0", "require": { "a": "~1.0" } }, + { "name": "b", "version": "1.1.0", "require": { "a": "~1.1" } } + ] + } + ], + "require": { + "a": "~1.0", + "b": "~1.0" + } +} + +--INSTALLED-- +[ + { "name": "a", "version": "1.0.0" }, + { "name": "b", "version": "1.0.0", "require": { "a": "~1.0" } } +] + +--RUN-- +update b --with-all-dependencies + +--EXPECT-OUTPUT-- +Loading composer repositories with package information +Updating dependencies (including require-dev) +Package operations: 0 installs, 2 updates, 0 removals +Writing lock file +Generating autoload files + +--EXPECT-- +Updating a (1.0.0) to a (1.1.0) +Updating b (1.0.0) to b (1.1.0) \ No newline at end of file diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php index adac21714..d6c0734a5 100644 --- a/tests/Composer/Test/InstallerTest.php +++ b/tests/Composer/Test/InstallerTest.php @@ -224,7 +224,8 @@ class InstallerTest extends TestCase ->setUpdate(true) ->setDryRun($input->getOption('dry-run')) ->setUpdateWhitelist($input->getArgument('packages')) - ->setWhitelistDependencies($input->getOption('with-dependencies')) + ->setIndirectWhitelistDependencies($input->getOption('with-dependencies')) + ->setAllWhitelistDependencies($input->getOption('with-all-dependencies')) ->setPreferStable($input->getOption('prefer-stable')) ->setPreferLowest($input->getOption('prefer-lowest')) ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs')); From 0e192ced6943a7a6e3de7c52ec0287d115d05784 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Mon, 11 Sep 2017 11:19:24 -0400 Subject: [PATCH 02/10] Adding `update-with-all-dependencies` option. --- src/Composer/Command/RequireCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index 012ed354a..295701c8f 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -47,7 +47,8 @@ class RequireCommand extends InitCommand new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies.'), new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'), new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'), - new InputOption('update-with-dependencies', null, InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated with explicit dependencies.'), + new InputOption('update-with-dependencies', null, InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated if those dependencies are not root requirements'), + new InputOption('update-with-all-dependencies', null, InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated.'), new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore platform requirements (php & ext- packages).'), new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'), new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'), From 21722f6e424233a171198c7892601d5c9d9257af Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Mon, 11 Sep 2017 11:32:19 -0400 Subject: [PATCH 03/10] Fixing test version constraints. --- .../Test/Fixtures/installer/update-with-all-dependencies.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Composer/Test/Fixtures/installer/update-with-all-dependencies.test b/tests/Composer/Test/Fixtures/installer/update-with-all-dependencies.test index 7e2573f9c..552cad0e1 100644 --- a/tests/Composer/Test/Fixtures/installer/update-with-all-dependencies.test +++ b/tests/Composer/Test/Fixtures/installer/update-with-all-dependencies.test @@ -18,7 +18,7 @@ When `with-all-dependencies` is used, Composer\Installer::whitelistUpdateDepende } ], "require": { - "a": "~1.0", + "a": "^1.0", "b": "~1.0" } } From ad465aa769100a5638f70ec45f01f59faf74ad5f Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Mon, 11 Sep 2017 11:47:33 -0400 Subject: [PATCH 04/10] Updating var names. --- src/Composer/Installer.php | 6 +++--- .../Fixtures/installer/update-with-all-dependencies.test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 932b220e2..a88d16777 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -125,7 +125,7 @@ class Installer * @var array|null */ protected $updateWhitelist = null; - protected $whitelistDependencies = false; + protected $whitelistIndirectDependencies = false; protected $whitelistAllDependencies = false; /** @@ -1352,7 +1352,7 @@ class Installer $seen[$package->getId()] = true; $this->updateWhitelist[$package->getName()] = true; - if (!$this->whitelistDependencies && !$this->whitelistAllDependencies) { + if (!$this->whitelistIndirectDependencies && !$this->whitelistAllDependencies) { continue; } @@ -1663,7 +1663,7 @@ class Installer */ public function setIndirectWhitelistDependencies($updateDependencies = true) { - $this->whitelistDependencies = (bool) $updateDependencies; + $this->whitelistIndirectDependencies = (bool) $updateDependencies; return $this; } diff --git a/tests/Composer/Test/Fixtures/installer/update-with-all-dependencies.test b/tests/Composer/Test/Fixtures/installer/update-with-all-dependencies.test index 552cad0e1..7e2573f9c 100644 --- a/tests/Composer/Test/Fixtures/installer/update-with-all-dependencies.test +++ b/tests/Composer/Test/Fixtures/installer/update-with-all-dependencies.test @@ -18,7 +18,7 @@ When `with-all-dependencies` is used, Composer\Installer::whitelistUpdateDepende } ], "require": { - "a": "^1.0", + "a": "~1.0", "b": "~1.0" } } From 6db92eae9294438b77db31c334973eb9a2f9fe47 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Mon, 11 Sep 2017 12:27:20 -0400 Subject: [PATCH 05/10] Trying to fix update behavior. --- src/Composer/Installer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index a88d16777..70040dd96 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -1362,11 +1362,11 @@ class Installer $requirePackages = $pool->whatProvides($require->getTarget()); foreach ($requirePackages as $requirePackage) { - if (!$this->whitelistAllDependencies && isset($this->updateWhitelist[$requirePackage->getName()])) { + if (isset($this->updateWhitelist[$requirePackage->getName()])) { continue; } - if (isset($skipPackages[$requirePackage->getName()])) { + if (!$this->whitelistAllDependencies && isset($skipPackages[$requirePackage->getName()])) { $this->io->writeError('Dependency "' . $requirePackage->getName() . '" is also a root requirement, but is not explicitly whitelisted. Ignoring.'); continue; } From 2e4afaa941ca8348c2b2104e2f0fbe2bed8381bb Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Mon, 11 Sep 2017 12:30:48 -0400 Subject: [PATCH 06/10] Not skipping root packages. --- src/Composer/Installer.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 70040dd96..168429ade 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -1284,7 +1284,7 @@ class Installer * * Packages which are listed as requirements in the root package will be * skipped including their dependencies, unless they are listed in the - * update whitelist themselves. + * update whitelist themselves or `with-all-dependencies` is used. * * @param RepositoryInterface $localOrLockRepo Use the locked repo if available, otherwise installed repo will do * As we want the most accurate package list to work with, and installed @@ -1306,8 +1306,10 @@ class Installer } $skipPackages = array(); - foreach ($rootRequires as $require) { - $skipPackages[$require->getTarget()] = true; + if (!$this->whitelistAllDependencies) { + foreach ($rootRequires as $require) { + $skipPackages[$require->getTarget()] = TRUE; + } } $pool = new Pool('dev'); @@ -1366,7 +1368,7 @@ class Installer continue; } - if (!$this->whitelistAllDependencies && isset($skipPackages[$requirePackage->getName()])) { + if (isset($skipPackages[$requirePackage->getName()])) { $this->io->writeError('Dependency "' . $requirePackage->getName() . '" is also a root requirement, but is not explicitly whitelisted. Ignoring.'); continue; } From 3826e51caa99662dd67fd566188a0a8abe16b3e1 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Mon, 11 Sep 2017 12:38:54 -0400 Subject: [PATCH 07/10] Renaming some methods and props. --- src/Composer/Command/RemoveCommand.php | 2 +- src/Composer/Command/RequireCommand.php | 2 +- src/Composer/Command/UpdateCommand.php | 6 +++--- src/Composer/Installer.php | 11 ++++++----- tests/Composer/Test/InstallerTest.php | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Composer/Command/RemoveCommand.php b/src/Composer/Command/RemoveCommand.php index ec6f64308..493c6481f 100644 --- a/src/Composer/Command/RemoveCommand.php +++ b/src/Composer/Command/RemoveCommand.php @@ -131,7 +131,7 @@ EOT ->setApcuAutoloader($apcu) ->setUpdate(true) ->setUpdateWhitelist($packages) - ->setIndirectWhitelistDependencies(!$input->getOption('no-update-with-dependencies')) + ->setWhitelistNonRootDependencies(!$input->getOption('no-update-with-dependencies')) ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs')) ->setRunScripts(!$input->getOption('no-scripts')) ; diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index 295701c8f..ccb65fb53 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -170,7 +170,7 @@ EOT ->setApcuAutoloader($apcu) ->setUpdate(true) ->setUpdateWhitelist(array_keys($requirements)) - ->setIndirectWhitelistDependencies($input->getOption('update-with-dependencies')) + ->setWhitelistNonRootDependencies($input->getOption('update-with-dependencies')) ->setAllWhitelistDependencies($input->getOption('update-with-all-dependencies')) ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs')) ->setPreferStable($input->getOption('prefer-stable')) diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index ac047c41a..fb2e36834 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -48,8 +48,8 @@ class UpdateCommand extends BaseCommand new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'), new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'), new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'Do not show package suggestions.'), - new InputOption('with-dependencies', null, InputOption::VALUE_NONE, 'Add also dependencies of whitelisted packages to the whitelist, if those dependencies are not defined in root package.'), - new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Add also all dependencies of whitelisted packages to the whitelist.'), + new InputOption('with-dependencies', null, InputOption::VALUE_NONE, 'Add also dependencies of whitelisted packages to the whitelist, except those defined in root package.'), + new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Add also all dependencies of whitelisted packages to the whitelist, including those defined in root package.'), new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'), new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump.'), new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'), @@ -146,7 +146,7 @@ EOT ->setApcuAutoloader($apcu) ->setUpdate(true) ->setUpdateWhitelist($input->getOption('lock') ? array('lock') : $packages) - ->setIndirectWhitelistDependencies($input->getOption('with-dependencies')) + ->setWhitelistNonRootDependencies($input->getOption('with-dependencies')) ->setAllWhitelistDependencies($input->getOption('with-all-dependencies')) ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs')) ->setPreferStable($input->getOption('prefer-stable')) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 168429ade..bfaffefd0 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -125,7 +125,7 @@ class Installer * @var array|null */ protected $updateWhitelist = null; - protected $whitelistIndirectDependencies = false; + protected $whitelistNonRootDependencies = false; protected $whitelistAllDependencies = false; /** @@ -1354,7 +1354,7 @@ class Installer $seen[$package->getId()] = true; $this->updateWhitelist[$package->getName()] = true; - if (!$this->whitelistIndirectDependencies && !$this->whitelistAllDependencies) { + if (!$this->whitelistNonRootDependencies && !$this->whitelistAllDependencies) { continue; } @@ -1660,12 +1660,13 @@ class Installer * This will NOT whitelist any dependencies that are also directly defined * in the root package. * - * @param bool $updateDependencies + * @param bool $updateNonRootDependencies + * * @return Installer */ - public function setIndirectWhitelistDependencies($updateDependencies = true) + public function setWhitelistNonRootDependencies($updateNonRootDependencies = true) { - $this->whitelistIndirectDependencies = (bool) $updateDependencies; + $this->whitelistNonRootDependencies = (bool) $updateNonRootDependencies; return $this; } diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php index d6c0734a5..57d666189 100644 --- a/tests/Composer/Test/InstallerTest.php +++ b/tests/Composer/Test/InstallerTest.php @@ -224,7 +224,7 @@ class InstallerTest extends TestCase ->setUpdate(true) ->setDryRun($input->getOption('dry-run')) ->setUpdateWhitelist($input->getArgument('packages')) - ->setIndirectWhitelistDependencies($input->getOption('with-dependencies')) + ->setWhitelistNonRootDependencies($input->getOption('with-dependencies')) ->setAllWhitelistDependencies($input->getOption('with-all-dependencies')) ->setPreferStable($input->getOption('prefer-stable')) ->setPreferLowest($input->getOption('prefer-lowest')) From 2e9e7ddd99e578b3cc51884db7cb8f08991f73af Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Mon, 11 Sep 2017 12:43:32 -0400 Subject: [PATCH 08/10] Updating docs. --- doc/03-cli.md | 7 ++++--- src/Composer/Command/RequireCommand.php | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/03-cli.md b/doc/03-cli.md index ae1e42a6f..f86246f05 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -153,7 +153,8 @@ php composer.phar update vendor/* * **--no-progress:** Removes the progress display that can mess with some terminals or scripts which don't handle backspace characters. * **--no-suggest:** Skips suggested packages in the output. -* **--with-dependencies:** Add also all dependencies of whitelisted packages to the whitelist. +* **--with-dependencies:** Add also dependencies of whitelisted packages to the whitelist, except those that are root requirements. +* **--with-all-dependencies:** Add also all dependencies of whitelisted packages to the whitelist, including those that are root requirements. * **--optimize-autoloader (-o):** Convert PSR-0/4 autoloading to classmap to get a faster autoloader. This is recommended especially for production, but can take a bit of time to run so it is currently not done by default. @@ -199,8 +200,8 @@ php composer.phar require vendor/package:2.* vendor/package2:dev-master * **--no-update:** Disables the automatic update of the dependencies. * **--no-scripts:** Skips execution of scripts defined in `composer.json`. * **--update-no-dev:** Run the dependency update with the `--no-dev` option. -* **--update-with-dependencies:** Also update dependencies of the newly - required packages. +* **--update-with-dependencies:** Also update dependencies of the newly required packages, except those that are root requirements. +* **--update-with-all-dependencies:** Also update dependencies of the newly required packages, including those that are root requirements. * **--ignore-platform-reqs:** ignore `php`, `hhvm`, `lib-*` and `ext-*` requirements and force the installation even if the local machine does not fulfill these. See also the [`platform`](06-config.md#platform) config option. diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index ccb65fb53..5946e4d98 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -47,8 +47,8 @@ class RequireCommand extends InitCommand new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies.'), new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'), new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'), - new InputOption('update-with-dependencies', null, InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated if those dependencies are not root requirements'), - new InputOption('update-with-all-dependencies', null, InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated.'), + new InputOption('update-with-dependencies', null, InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated, except those that are root requirements.'), + new InputOption('update-with-all-dependencies', null, InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'), new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore platform requirements (php & ext- packages).'), new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'), new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'), From 11db6f90c21bc0f2a92a101fc23f699ea6c84a04 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Mon, 11 Sep 2017 12:56:51 -0400 Subject: [PATCH 09/10] Cleaning up comments --- src/Composer/Installer.php | 2 +- .../Test/Fixtures/installer/update-with-all-dependencies.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index bfaffefd0..1f8b135cc 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -1284,7 +1284,7 @@ class Installer * * Packages which are listed as requirements in the root package will be * skipped including their dependencies, unless they are listed in the - * update whitelist themselves or `with-all-dependencies` is used. + * update whitelist themselves or $whitelistAllDependencies is true. * * @param RepositoryInterface $localOrLockRepo Use the locked repo if available, otherwise installed repo will do * As we want the most accurate package list to work with, and installed diff --git a/tests/Composer/Test/Fixtures/installer/update-with-all-dependencies.test b/tests/Composer/Test/Fixtures/installer/update-with-all-dependencies.test index 7e2573f9c..f4fbfce9b 100644 --- a/tests/Composer/Test/Fixtures/installer/update-with-all-dependencies.test +++ b/tests/Composer/Test/Fixtures/installer/update-with-all-dependencies.test @@ -2,7 +2,7 @@ See Github issue #6661 ( github.com/composer/composer/issues/6661 ). -When `with-all-dependencies` is used, Composer\Installer::whitelistUpdateDependencies should update all whitelisted dependencies, even if the dependency is a root requirement. +When `--with-all-dependencies` is used, Composer\Installer::whitelistUpdateDependencies should update the dependencies of all whitelisted packages, even if the dependency is a root requirement. --COMPOSER-- { From 776977f597a848b2e89a8551da120f0b7fc86855 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Mon, 11 Sep 2017 13:53:56 -0400 Subject: [PATCH 10/10] Fixing method name. --- src/Composer/Command/RequireCommand.php | 2 +- src/Composer/Command/UpdateCommand.php | 2 +- src/Composer/Installer.php | 2 +- tests/Composer/Test/InstallerTest.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index 5946e4d98..4ec17bef5 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -171,7 +171,7 @@ EOT ->setUpdate(true) ->setUpdateWhitelist(array_keys($requirements)) ->setWhitelistNonRootDependencies($input->getOption('update-with-dependencies')) - ->setAllWhitelistDependencies($input->getOption('update-with-all-dependencies')) + ->setWhitelistAllDependencies($input->getOption('update-with-all-dependencies')) ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs')) ->setPreferStable($input->getOption('prefer-stable')) ->setPreferLowest($input->getOption('prefer-lowest')) diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index fb2e36834..5948ca5d7 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -147,7 +147,7 @@ EOT ->setUpdate(true) ->setUpdateWhitelist($input->getOption('lock') ? array('lock') : $packages) ->setWhitelistNonRootDependencies($input->getOption('with-dependencies')) - ->setAllWhitelistDependencies($input->getOption('with-all-dependencies')) + ->setWhitelistAllDependencies($input->getOption('with-all-dependencies')) ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs')) ->setPreferStable($input->getOption('prefer-stable')) ->setPreferLowest($input->getOption('prefer-lowest')) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 1f8b135cc..0bfe450f5 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -1680,7 +1680,7 @@ class Installer * @param bool $updateAllDependencies * @return Installer */ - public function setAllWhitelistDependencies($updateAllDependencies = true) + public function setWhitelistAllDependencies($updateAllDependencies = true) { $this->whitelistAllDependencies = (bool) $updateAllDependencies; diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php index 57d666189..9d900095a 100644 --- a/tests/Composer/Test/InstallerTest.php +++ b/tests/Composer/Test/InstallerTest.php @@ -225,7 +225,7 @@ class InstallerTest extends TestCase ->setDryRun($input->getOption('dry-run')) ->setUpdateWhitelist($input->getArgument('packages')) ->setWhitelistNonRootDependencies($input->getOption('with-dependencies')) - ->setAllWhitelistDependencies($input->getOption('with-all-dependencies')) + ->setWhitelistAllDependencies($input->getOption('with-all-dependencies')) ->setPreferStable($input->getOption('prefer-stable')) ->setPreferLowest($input->getOption('prefer-lowest')) ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'));