function SolverProblemsException::getPrettyString
File
-
vendor/
composer/ composer/ src/ Composer/ DependencyResolver/ SolverProblemsException.php, line 44
Class
- SolverProblemsException
- @author Nils Adermann <naderman@naderman.de>
Namespace
Composer\DependencyResolverCode
public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, bool $isDevExtraction = false) : string {
$installedMap = $request->getPresentMap(true);
$missingExtensions = [];
$isCausedByLock = false;
$problems = [];
foreach ($this->problems as $problem) {
$problems[] = $problem->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $this->learnedPool) . "\n";
$missingExtensions = array_merge($missingExtensions, $this->getExtensionProblems($problem->getReasons()));
$isCausedByLock = $isCausedByLock || $problem->isCausedByLock($repositorySet, $request, $pool);
}
$i = 1;
$text = "\n";
foreach (array_unique($problems) as $problem) {
$text .= " Problem " . $i++ . $problem;
}
$hints = [];
if (!$isDevExtraction && (str_contains($text, 'could not be found') || str_contains($text, 'no matching package found'))) {
$hints[] = "Potential causes:\n - A typo in the package name\n - The package is not available in a stable-enough version according to your minimum-stability setting\n see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.\n - It's a private package and you forgot to add a custom repository to find it\n\nRead <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.";
}
if (\count($missingExtensions) > 0) {
$hints[] = $this->createExtensionHint($missingExtensions);
}
if ($isCausedByLock && !$isDevExtraction && !$request->getUpdateAllowTransitiveRootDependencies()) {
$hints[] = "Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.";
}
if (str_contains($text, 'found composer-plugin-api[2.0.0] but it does not match') && str_contains($text, '- ocramius/package-versions')) {
$hints[] = "<warning>ocramius/package-versions only provides support for Composer 2 in 1.8+, which requires PHP 7.4.</warning>\nIf you can not upgrade PHP you can require <info>composer/package-versions-deprecated</info> to resolve this with PHP 7.0+.";
}
if (!class_exists('PHPUnit\\Framework\\TestCase', false)) {
if (str_contains($text, 'found composer-plugin-api[2.0.0] but it does not match')) {
$hints[] = "You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.";
}
}
if (\count($hints) > 0) {
$text .= "\n" . implode("\n\n", $hints);
}
return $text;
}