Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Problem.php

function Problem::getPrettyString

A human readable textual representation of the problem's reasons

Parameters

array<int|string, BasePackage> $installedMap A map of all present packages:

array<Rule[]> $learnedPool:

File

vendor/composer/composer/src/Composer/DependencyResolver/Problem.php, line 78

Class

Problem
Represents a problem detected while solving dependencies

Namespace

Composer\DependencyResolver

Code

public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, array $installedMap = [], array $learnedPool = []) : string {
    // TODO doesn't this entirely defeat the purpose of the problem sections? what's the point of sections?
    $reasons = array_merge(...array_reverse($this->reasons));
    if (\count($reasons) === 1) {
        reset($reasons);
        $rule = current($reasons);
        if ($rule->getReason() !== Rule::RULE_ROOT_REQUIRE) {
            throw new \LogicException("Single reason problems must contain a root require rule.");
        }
        $reasonData = $rule->getReasonData();
        $packageName = $reasonData['packageName'];
        $constraint = $reasonData['constraint'];
        $packages = $pool->whatProvides($packageName, $constraint);
        if (\count($packages) === 0) {
            return "\n    " . implode(self::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $packageName, $constraint));
        }
    }
    usort($reasons, function (Rule $rule1, Rule $rule2) use ($pool) {
        $rule1Prio = $this->getRulePriority($rule1);
        $rule2Prio = $this->getRulePriority($rule2);
        if ($rule1Prio !== $rule2Prio) {
            return $rule2Prio - $rule1Prio;
        }
        return $this->getSortableString($pool, $rule1) <=> $this->getSortableString($pool, $rule2);
    });
    return self::formatDeduplicatedRules($reasons, '    ', $repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal