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

Breadcrumb

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

function PackageDiscoveryTrait::getPlatformExceptionDetails

1 call to PackageDiscoveryTrait::getPlatformExceptionDetails()
PackageDiscoveryTrait::findBestVersionAndNameForPackage in vendor/composer/composer/src/Composer/Command/PackageDiscoveryTrait.php
Given a package name, this determines the best version to use in the require key.

File

vendor/composer/composer/src/Composer/Command/PackageDiscoveryTrait.php, line 430

Class

PackageDiscoveryTrait
@internal

Namespace

Composer\Command

Code

private function getPlatformExceptionDetails(PackageInterface $candidate, ?PlatformRepository $platformRepo = null) : string {
    $details = [];
    if (null === $platformRepo) {
        return '';
    }
    foreach ($candidate->getRequires() as $link) {
        if (!PlatformRepository::isPlatformPackage($link->getTarget())) {
            continue;
        }
        $platformPkg = $platformRepo->findPackage($link->getTarget(), '*');
        if (null === $platformPkg) {
            if ($platformRepo->isPlatformPackageDisabled($link->getTarget())) {
                $details[] = $candidate->getPrettyName() . ' ' . $candidate->getPrettyVersion() . ' requires ' . $link->getTarget() . ' ' . $link->getPrettyConstraint() . ' but it is disabled by your platform config. Enable it again with "composer config platform.' . $link->getTarget() . ' --unset".';
            }
            else {
                $details[] = $candidate->getPrettyName() . ' ' . $candidate->getPrettyVersion() . ' requires ' . $link->getTarget() . ' ' . $link->getPrettyConstraint() . ' but it is not present.';
            }
            continue;
        }
        if (!$link->getConstraint()
            ->matches(new Constraint('==', $platformPkg->getVersion()))) {
            $platformPkgVersion = $platformPkg->getPrettyVersion();
            $platformExtra = $platformPkg->getExtra();
            if (isset($platformExtra['config.platform']) && $platformPkg instanceof CompletePackageInterface) {
                $platformPkgVersion .= ' (' . $platformPkg->getDescription() . ')';
            }
            $details[] = $candidate->getPrettyName() . ' ' . $candidate->getPrettyVersion() . ' requires ' . $link->getTarget() . ' ' . $link->getPrettyConstraint() . ' which does not match your installed version ' . $platformPkgVersion . '.';
        }
    }
    if (count($details) === 0) {
        return '';
    }
    return ':' . PHP_EOL . '  - ' . implode(PHP_EOL . '  - ', $details);
}

API Navigation

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