Improve error reporting for exts overridden by platform config, fixes #9876
parent
da3d5e3143
commit
44e6591573
|
@ -181,26 +181,16 @@ class Problem
|
|||
{
|
||||
// handle php/hhvm
|
||||
if ($packageName === 'php' || $packageName === 'php-64bit' || $packageName === 'hhvm') {
|
||||
$version = phpversion();
|
||||
$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());
|
||||
}
|
||||
}
|
||||
$version = self::getPlatformPackageVersion($pool, $packageName, phpversion());
|
||||
|
||||
$msg = "- Root composer.json requires ".$packageName.self::constraintToText($constraint).' but ';
|
||||
|
||||
if (defined('HHVM_VERSION') || (count($available) && $packageName === 'hhvm')) {
|
||||
if (defined('HHVM_VERSION') || ($packageName === 'hhvm' && count($pool->whatProvides($packageName)) > 0)) {
|
||||
return array($msg, 'your HHVM version does not satisfy that requirement.');
|
||||
}
|
||||
|
||||
if ($packageName === 'hhvm') {
|
||||
return array($msg, 'you are running this with PHP and not HHVM.');
|
||||
return array($msg, 'HHVM was not detected on this machine, make sure it is in your PATH.');
|
||||
}
|
||||
|
||||
return array($msg, 'your '.$packageName.' version ('. $version .') does not satisfy that requirement.');
|
||||
|
@ -213,7 +203,9 @@ class Problem
|
|||
}
|
||||
|
||||
$ext = substr($packageName, 4);
|
||||
$error = extension_loaded($ext) ? 'it has the wrong version ('.(phpversion($ext) ?: '0').') installed' : 'it is missing from your system';
|
||||
$version = self::getPlatformPackageVersion($pool, $packageName, phpversion($ext) ?: '0');
|
||||
|
||||
$error = extension_loaded($ext) ? 'it has the wrong version ('.$version.') installed' : 'it is missing from your system';
|
||||
|
||||
return array("- Root composer.json requires PHP extension ".$packageName.self::constraintToText($constraint).' but ', $error.'. Install or enable PHP\'s '.$ext.' extension.');
|
||||
}
|
||||
|
@ -358,6 +350,22 @@ class Problem
|
|||
return implode(', ', $prepared);
|
||||
}
|
||||
|
||||
private static function getPlatformPackageVersion(Pool $pool, $packageName, $version)
|
||||
{
|
||||
$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());
|
||||
}
|
||||
}
|
||||
|
||||
return $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $versions an array of pretty versions, with normalized versions as keys
|
||||
* @return list<string> a list of pretty versions and '...' where versions were removed
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
--TEST--
|
||||
Test the error output of solver problems with ext/platform packages which have platform config
|
||||
--COMPOSER--
|
||||
{
|
||||
"repositories": [
|
||||
{
|
||||
"type": "package",
|
||||
"package": [
|
||||
{"name": "a/a", "version": "1.0.0", "require": {"ext-filter": "2.0.0"}}
|
||||
]
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"a/a": "*"
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"ext-filter": "7.4.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
--LOCK--
|
||||
{
|
||||
"packages": [
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "dev",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": []
|
||||
}
|
||||
|
||||
--RUN--
|
||||
update
|
||||
|
||||
--EXPECT-EXIT-CODE--
|
||||
2
|
||||
|
||||
--EXPECT-OUTPUT--
|
||||
Loading composer repositories with package information
|
||||
Updating dependencies
|
||||
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.
|
||||
|
||||
To enable extensions, verify that they are enabled in your .ini files:
|
||||
__inilist__
|
||||
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
|
||||
|
||||
--EXPECT--
|
Loading…
Reference in New Issue