Fix platform package description for replacer/provider and packages which are not really loaded in general
parent
e30a6b0b9b
commit
ca5d5b40ee
|
@ -79,7 +79,7 @@
|
|||
],
|
||||
"scripts": {
|
||||
"compile": "@php -dphar.readonly=0 bin/compile",
|
||||
"test": "simple-phpunit",
|
||||
"test": "@php simple-phpunit",
|
||||
"phpstan-setup": [
|
||||
"@composer config platform --unset",
|
||||
"@composer update",
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Composer\DependencyResolver;
|
|||
use Composer\Package\CompletePackageInterface;
|
||||
use Composer\Package\AliasPackage;
|
||||
use Composer\Package\BasePackage;
|
||||
use Composer\Package\Link;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Package\RootPackageInterface;
|
||||
use Composer\Pcre\Preg;
|
||||
|
@ -242,19 +243,19 @@ class Problem
|
|||
$ext = substr($packageName, 4);
|
||||
$msg = "- Root composer.json requires PHP extension ".$packageName.self::constraintToText($constraint).' but ';
|
||||
|
||||
if (extension_loaded($ext)) {
|
||||
$version = self::getPlatformPackageVersion($pool, $packageName, phpversion($ext) ?: '0');
|
||||
|
||||
if (null === $version) {
|
||||
return array($msg, 'the '.$packageName.' package is disabled by your platform config. Enable it again with "composer config platform.'.$packageName.' --unset".');
|
||||
$version = self::getPlatformPackageVersion($pool, $packageName, phpversion($ext) ?: '0');
|
||||
if (null === $version) {
|
||||
if (extension_loaded($ext)) {
|
||||
return array(
|
||||
$msg,
|
||||
'the '.$packageName.' package is disabled by your platform config. Enable it again with "composer config platform.'.$packageName.' --unset".',
|
||||
);
|
||||
}
|
||||
|
||||
$error = 'it has the wrong version ('.$version.') installed';
|
||||
} else {
|
||||
$error = 'it is missing from your system';
|
||||
return array($msg, 'it is missing from your system. Install or enable PHP\'s '.$ext.' extension.');
|
||||
}
|
||||
|
||||
return array($msg, $error.'. Install or enable PHP\'s '.$ext.' extension.');
|
||||
return array($msg, 'it has the wrong version installed ('.$version.').');
|
||||
}
|
||||
|
||||
// handle linked libs
|
||||
|
@ -431,11 +432,31 @@ class Problem
|
|||
$available = $pool->whatProvides($packageName);
|
||||
|
||||
if (count($available)) {
|
||||
$firstAvailable = reset($available);
|
||||
$version = $firstAvailable->getPrettyVersion();
|
||||
$extra = $firstAvailable->getExtra();
|
||||
if ($firstAvailable instanceof CompletePackageInterface && isset($extra['config.platform']) && $extra['config.platform'] === true) {
|
||||
$version .= '; ' . str_replace('Package ', '', $firstAvailable->getDescription());
|
||||
$selected = null;
|
||||
foreach ($available as $pkg) {
|
||||
if ($pkg->getRepository() instanceof PlatformRepository) {
|
||||
$selected = $pkg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($selected === null) {
|
||||
$selected = reset($available);
|
||||
}
|
||||
|
||||
// must be a package providing/replacing and not a real platform package
|
||||
if ($selected->getName() !== $packageName) {
|
||||
/** @var Link $link */
|
||||
foreach (array_merge(array_values($selected->getProvides()), array_values($selected->getReplaces())) as $link) {
|
||||
if ($link->getTarget() === $packageName) {
|
||||
return $link->getPrettyConstraint().' '.substr($link->getDescription(), 0, -1).'d by '.$selected->getPrettyString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$version = $selected->getPrettyVersion();
|
||||
$extra = $selected->getExtra();
|
||||
if ($selected instanceof CompletePackageInterface && isset($extra['config.platform']) && $extra['config.platform'] === true) {
|
||||
$version .= '; ' . str_replace('Package ', '', $selected->getDescription());
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
|
|
|
@ -47,7 +47,7 @@ Your requirements could not be resolved to an installable set of packages.
|
|||
|
||||
Problem 1
|
||||
- Root composer.json requires a/a * -> satisfiable by a/a[1.0.0].
|
||||
- a/a 1.0.0 requires ext-filter 2.0.0 -> it has the wrong version (7.4.0; overridden via config.platform, actual: %s) installed. Install or enable PHP's filter extension.
|
||||
- a/a 1.0.0 requires ext-filter 2.0.0 -> it has the wrong version installed (7.4.0; overridden via config.platform, actual: %s).
|
||||
|
||||
To enable extensions, verify that they are enabled in your .ini files:
|
||||
__inilist__
|
||||
|
|
|
@ -119,7 +119,7 @@ Your requirements could not be resolved to an installable set of packages.
|
|||
Problem 6
|
||||
- Root composer.json requires linked library lib-icu 1001.* but it has the wrong version installed, try upgrading the intl extension.
|
||||
Problem 7
|
||||
- Root composer.json requires PHP extension ext-xml 1002.* but it has the wrong version (%s) installed. Install or enable PHP's xml extension.
|
||||
- Root composer.json requires PHP extension ext-xml 1002.* but it has the wrong version installed (%s).
|
||||
Problem 8
|
||||
- Root composer.json requires php 1 but your php version (%s) does not satisfy that requirement.
|
||||
Problem 9
|
||||
|
@ -161,4 +161,3 @@ Alternatively, you can run Composer with `--ignore-platform-req=ext-xml` to temp
|
|||
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
|
||||
|
||||
--EXPECT--
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ Your requirements could not be resolved to an installable set of packages.
|
|||
- Root composer.json requires PHP extension ext-foo-baz [== 9.0.0.0 || >= 9.0.0.0] but it is missing from your system. Install or enable PHP's foo-baz extension.
|
||||
Problem 2
|
||||
- Root composer.json requires b/b 1.0.* -> satisfiable by b/b[1.0.1].
|
||||
- b/b 1.0.1 requires ext-foo-bar 10.* -> it has the wrong version (5.0.3 provided by __root__ 1.0.0+no-version-set) installed. Install or enable PHP's foo-bar extension.
|
||||
- b/b 1.0.1 requires ext-foo-bar 10.* -> it has the wrong version installed (5.0.3 provided by __root__ 1.0.0+no-version-set).
|
||||
|
||||
To enable extensions, verify that they are enabled in your .ini files:
|
||||
__inilist__
|
||||
|
|
Loading…
Reference in New Issue