diff --git a/src/Composer/DependencyResolver/Operation/InstallOperation.php b/src/Composer/DependencyResolver/Operation/InstallOperation.php index 08c659c49..569ae67a4 100644 --- a/src/Composer/DependencyResolver/Operation/InstallOperation.php +++ b/src/Composer/DependencyResolver/Operation/InstallOperation.php @@ -56,11 +56,19 @@ class InstallOperation extends SolverOperation return 'install'; } + /** + * {@inheritDoc} + */ + public function show($lock) + { + return ($lock ? 'Locking ' : 'Installing ').$this->package->getPrettyName().' ('.$this->formatVersion($this->package).')'; + } + /** * {@inheritDoc} */ public function __toString() { - return 'Installing '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).')'; + return $this->show(false); } } diff --git a/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php b/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php index 920e54e67..800cf43c2 100644 --- a/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php +++ b/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php @@ -60,8 +60,16 @@ class MarkAliasInstalledOperation extends SolverOperation /** * {@inheritDoc} */ - public function __toString() + public function show($lock) { return 'Marking '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).') as installed, alias of '.$this->package->getAliasOf()->getPrettyName().' ('.$this->formatVersion($this->package->getAliasOf()).')'; } + + /** + * {@inheritDoc} + */ + public function __toString() + { + return $this->show(false); + } } diff --git a/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php b/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php index 77f3aef8c..3c996f343 100644 --- a/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php +++ b/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php @@ -60,8 +60,16 @@ class MarkAliasUninstalledOperation extends SolverOperation /** * {@inheritDoc} */ - public function __toString() + public function show($lock) { return 'Marking '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).') as uninstalled, alias of '.$this->package->getAliasOf()->getPrettyName().' ('.$this->formatVersion($this->package->getAliasOf()).')'; } + + /** + * {@inheritDoc} + */ + public function __toString() + { + return $this->show(false); + } } diff --git a/src/Composer/DependencyResolver/Operation/OperationInterface.php b/src/Composer/DependencyResolver/Operation/OperationInterface.php index 330cbceb1..261a746af 100644 --- a/src/Composer/DependencyResolver/Operation/OperationInterface.php +++ b/src/Composer/DependencyResolver/Operation/OperationInterface.php @@ -33,6 +33,14 @@ interface OperationInterface */ public function getReason(); + /** + * Serializes the operation in a human readable format + * + * @param $lock bool Whether this is an operation on the lock file + * @return string + */ + public function show($lock); + /** * Serializes the operation in a human readable format * diff --git a/src/Composer/DependencyResolver/Operation/SolverOperation.php b/src/Composer/DependencyResolver/Operation/SolverOperation.php index e1a68585e..bb733b70f 100644 --- a/src/Composer/DependencyResolver/Operation/SolverOperation.php +++ b/src/Composer/DependencyResolver/Operation/SolverOperation.php @@ -43,6 +43,12 @@ abstract class SolverOperation implements OperationInterface return $this->reason; } + /** + * @param $lock bool Whether this is an operation on the lock file + * @return string + */ + abstract public function show($lock); + protected function formatVersion(PackageInterface $package) { return $package->getFullPrettyVersion(); diff --git a/src/Composer/DependencyResolver/Operation/UninstallOperation.php b/src/Composer/DependencyResolver/Operation/UninstallOperation.php index b4a73811e..73321f96f 100644 --- a/src/Composer/DependencyResolver/Operation/UninstallOperation.php +++ b/src/Composer/DependencyResolver/Operation/UninstallOperation.php @@ -59,8 +59,16 @@ class UninstallOperation extends SolverOperation /** * {@inheritDoc} */ - public function __toString() + public function show($lock) { return 'Uninstalling '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).')'; } + + /** + * {@inheritDoc} + */ + public function __toString() + { + return $this->show(false); + } } diff --git a/src/Composer/DependencyResolver/Operation/UpdateOperation.php b/src/Composer/DependencyResolver/Operation/UpdateOperation.php index 836725ef5..aecde33c2 100644 --- a/src/Composer/DependencyResolver/Operation/UpdateOperation.php +++ b/src/Composer/DependencyResolver/Operation/UpdateOperation.php @@ -72,9 +72,17 @@ class UpdateOperation extends SolverOperation /** * {@inheritDoc} */ - public function __toString() + public function show($lock) { return 'Updating '.$this->initialPackage->getPrettyName().' ('.$this->formatVersion($this->initialPackage).') to '. $this->targetPackage->getPrettyName(). ' ('.$this->formatVersion($this->targetPackage).')'; } + + /** + * {@inheritDoc} + */ + public function __toString() + { + return $this->show(false); + } } diff --git a/src/Composer/DependencyResolver/Transaction.php b/src/Composer/DependencyResolver/Transaction.php index f12aeccc5..6496327ff 100644 --- a/src/Composer/DependencyResolver/Transaction.php +++ b/src/Composer/DependencyResolver/Transaction.php @@ -24,7 +24,7 @@ use Composer\Semver\Constraint\Constraint; /** * @author Nils Adermann */ -abstract class Transaction +class Transaction { /** * @var array @@ -53,7 +53,6 @@ abstract class Transaction $this->presentPackages = $presentPackages; $this->setResultPackageMaps($resultPackages); $this->operations = $this->calculateOperations(); - } public function getOperations() diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 941717912..9f014be1e 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -484,7 +484,7 @@ class Installer // output op, but alias op only in debug verbosity if (false === strpos($operation->getJobType(), 'Alias') || $this->io->isDebug()) { - $this->io->writeError(' - ' . $operation); + $this->io->writeError(' - ' . $operation->show(true)); } } @@ -673,7 +673,7 @@ class Installer // output op, but alias op only in debug verbosity if ((!$this->executeOperations && false === strpos($operation->getJobType(), 'Alias')) || $this->io->isDebug()) { - $this->io->writeError(' - ' . $operation); + $this->io->writeError(' - ' . $operation->show(false)); } $this->installationManager->execute($localRepo, $operation); diff --git a/tests/Composer/Test/Fixtures/installer/abandoned-listed.test b/tests/Composer/Test/Fixtures/installer/abandoned-listed.test index 7c671565d..3ad5b0428 100644 --- a/tests/Composer/Test/Fixtures/installer/abandoned-listed.test +++ b/tests/Composer/Test/Fixtures/installer/abandoned-listed.test @@ -27,8 +27,8 @@ update Loading composer repositories with package information Updating dependencies Lock file operations: 2 installs, 0 updates, 0 removals - - Installing a/a (1.0.0) - - Installing c/c (1.0.0) + - Locking a/a (1.0.0) + - Locking c/c (1.0.0) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 2 installs, 0 updates, 0 removals diff --git a/tests/Composer/Test/Fixtures/installer/suggest-installed.test b/tests/Composer/Test/Fixtures/installer/suggest-installed.test index e53ab0065..413ac8665 100644 --- a/tests/Composer/Test/Fixtures/installer/suggest-installed.test +++ b/tests/Composer/Test/Fixtures/installer/suggest-installed.test @@ -22,8 +22,8 @@ update Loading composer repositories with package information Updating dependencies Lock file operations: 2 installs, 0 updates, 0 removals - - Installing a/a (1.0.0) - - Installing b/b (1.0.0) + - Locking a/a (1.0.0) + - Locking b/b (1.0.0) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 2 installs, 0 updates, 0 removals diff --git a/tests/Composer/Test/Fixtures/installer/suggest-prod.test b/tests/Composer/Test/Fixtures/installer/suggest-prod.test index 89d6ab8de..6a00b5607 100644 --- a/tests/Composer/Test/Fixtures/installer/suggest-prod.test +++ b/tests/Composer/Test/Fixtures/installer/suggest-prod.test @@ -21,7 +21,7 @@ install --no-dev Loading composer repositories with package information Updating dependencies Lock file operations: 1 install, 0 updates, 0 removals - - Installing a/a (1.0.0) + - Locking a/a (1.0.0) Writing lock file Installing dependencies from lock file Package operations: 1 install, 0 updates, 0 removals diff --git a/tests/Composer/Test/Fixtures/installer/suggest-replaced.test b/tests/Composer/Test/Fixtures/installer/suggest-replaced.test index 62c13e560..e56af5093 100644 --- a/tests/Composer/Test/Fixtures/installer/suggest-replaced.test +++ b/tests/Composer/Test/Fixtures/installer/suggest-replaced.test @@ -22,8 +22,8 @@ update Loading composer repositories with package information Updating dependencies Lock file operations: 2 installs, 0 updates, 0 removals - - Installing c/c (1.0.0) - - Installing a/a (1.0.0) + - Locking c/c (1.0.0) + - Locking a/a (1.0.0) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 2 installs, 0 updates, 0 removals diff --git a/tests/Composer/Test/Fixtures/installer/suggest-uninstalled.test b/tests/Composer/Test/Fixtures/installer/suggest-uninstalled.test index f45b710f0..1b88b2d8b 100644 --- a/tests/Composer/Test/Fixtures/installer/suggest-uninstalled.test +++ b/tests/Composer/Test/Fixtures/installer/suggest-uninstalled.test @@ -21,7 +21,7 @@ install Loading composer repositories with package information Updating dependencies Lock file operations: 1 install, 0 updates, 0 removals - - Installing a/a (1.0.0) + - Locking a/a (1.0.0) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 1 install, 0 updates, 0 removals