1
0
Fork 0

Show reasons why an operation is executed in -vv mode, fixes #1063

pull/1828/merge
Jordi Boggiano 2013-04-27 00:11:06 +02:00
parent 3b97e2e260
commit 201cde05be
2 changed files with 31 additions and 2 deletions

View File

@ -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();

View File

@ -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);