diff --git a/src/Composer/DependencyResolver/Rule.php b/src/Composer/DependencyResolver/Rule.php index a69d3bc10..4e3dfc14d 100644 --- a/src/Composer/DependencyResolver/Rule.php +++ b/src/Composer/DependencyResolver/Rule.php @@ -82,6 +82,16 @@ class Rule return $this->job; } + public function getReason() + { + return $this->reason; + } + + public function getReasonData() + { + return $this->reasonData; + } + public function getRequiredPackage() { if ($this->reason === self::RULE_JOB_INSTALL) { @@ -200,9 +210,12 @@ class Rule if ($requires) { $requireText = array(); foreach ($requires as $require) { - $requireText[] = $require->getPrettyString(); + $requireText[$require->getName()][] = $require->getPrettyVersion(); } - $text .= ' -> satisfiable by '.implode(', ', $requireText).'.'; + foreach ($requireText as $name => $versions) { + $requireText[$name] = $name.'['.implode(', ', $versions).']'; + } + $text .= ' -> satisfiable by '.implode(', ', $requireText); } else { $targetName = $this->reasonData->getTarget(); diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 2970a9cb3..fc5a7c044 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -18,6 +18,7 @@ use Composer\DependencyResolver\Operation\UpdateOperation; use Composer\DependencyResolver\Operation\UninstallOperation; use Composer\DependencyResolver\Pool; use Composer\DependencyResolver\Request; +use Composer\DependencyResolver\Rule; use Composer\DependencyResolver\Solver; use Composer\DependencyResolver\SolverProblemsException; use Composer\Downloader\DownloadManager; @@ -496,6 +497,21 @@ class Installer $this->installationManager->execute($localRepo, $operation); + // output reasons why the operation was ran + if ($this->verbose && $this->io->isVeryVerbose()) { + $reason = $operation->getReason(); + if ($reason instanceof Rule) { + switch ($reason->getReason()) { + case Rule::RULE_JOB_INSTALL: + $this->io->write(' REASON: Required to be installed: '.$reason->getRequiredPackage()); + break; + case Rule::RULE_PACKAGE_REQUIRES: + $this->io->write(' REASON: '.$reason->getPrettyString()); + break; + } + } + } + $event = 'Composer\Script\ScriptEvents::POST_PACKAGE_'.strtoupper($operation->getJobType()); if (defined($event) && $this->runScripts) { $this->eventDispatcher->dispatchPackageEvent(constant($event), $this->devMode, $operation);