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\CommandCode
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);
}