From 8a7f3a9a094b895f1477448a3ff4e2eb7ae7de70 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 2 Jun 2020 13:13:11 +0200 Subject: [PATCH] Avoid rendering problem output for dev-master aliases which is useless --- src/Composer/DependencyResolver/Problem.php | 2 +- src/Composer/DependencyResolver/Rule.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Composer/DependencyResolver/Problem.php b/src/Composer/DependencyResolver/Problem.php index 16da238b6..a7efca100 100644 --- a/src/Composer/DependencyResolver/Problem.php +++ b/src/Composer/DependencyResolver/Problem.php @@ -104,7 +104,7 @@ class Problem $template = preg_replace('{^\S+ \S+ }', '%s%s ', $message); $messages[] = $template; $templates[$template][$m[1]][$parser->normalize($m[2])] = $m[2]; - } else { + } elseif ($message !== '') { $messages[] = $message; } } diff --git a/src/Composer/DependencyResolver/Rule.php b/src/Composer/DependencyResolver/Rule.php index d2bd582a5..5cee6c2e3 100644 --- a/src/Composer/DependencyResolver/Rule.php +++ b/src/Composer/DependencyResolver/Rule.php @@ -275,7 +275,10 @@ abstract class Rule $learnedString = ', learned rules:'."\n - "; $reasons = array(); foreach ($learnedPool[$this->reasonData] as $learnedRule) { - $reasons[] = $learnedRule->getPrettyString($repositorySet, $request, $pool, $installedMap, $learnedPool); + $reason = $learnedRule->getPrettyString($repositorySet, $request, $pool, $installedMap, $learnedPool); + if ($reason !== '') { + $reasons[] = $reason; + } } $learnedString .= implode("\n - ", array_unique($reasons)); } else { @@ -284,7 +287,11 @@ abstract class Rule return 'Conclusion: '.$ruleText.$learnedString; case self::RULE_PACKAGE_ALIAS: - $aliasPackage = $this->deduplicateMasterAlias($pool->literalToPackage($literals[0])); + $aliasPackage = $pool->literalToPackage($literals[0]); + // avoid returning content like "9999999-dev is an alias of dev-master" as it is useless + if ($aliasPackage->getVersion() === VersionParser::DEV_MASTER_ALIAS) { + return ''; + } $package = $this->deduplicateMasterAlias($pool->literalToPackage($literals[1])); return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and thus requires it to be installed too.';