1
0
Fork 0

Merge pull request #5349 from ReenExeContributor/master

clear code
pull/5360/head
Jordi Boggiano 2016-05-17 11:43:51 +01:00
commit 6a225389c8
4 changed files with 52 additions and 33 deletions

View File

@ -97,7 +97,9 @@ class Problem
if (defined('HHVM_VERSION')) { if (defined('HHVM_VERSION')) {
return $msg . 'your HHVM version does not satisfy that requirement.'; return $msg . 'your HHVM version does not satisfy that requirement.';
} elseif ($job['packageName'] === 'hhvm') { }
if ($job['packageName'] === 'hhvm') {
return $msg . 'you are running this with PHP and not HHVM.'; return $msg . 'you are running this with PHP and not HHVM.';
} }

View File

@ -208,44 +208,50 @@ class Rule
// handle php/hhvm // handle php/hhvm
if (defined('HHVM_VERSION')) { if (defined('HHVM_VERSION')) {
return $text . ' -> your HHVM version does not satisfy that requirement.'; return $text . ' -> your HHVM version does not satisfy that requirement.';
} elseif ($targetName === 'hhvm') {
return $text . ' -> you are running this with PHP and not HHVM.';
} else {
$packages = $pool->whatProvides($targetName);
$package = count($packages) ? current($packages) : phpversion();
if (!($package instanceof CompletePackage)) {
return $text . ' -> your PHP version ('.phpversion().') does not satisfy that requirement.';
}
$extra = $package->getExtra();
if (!empty($extra['config.platform'])) {
$text .= ' -> your PHP version ('.phpversion().') overridden by "config.platform.php" version ('.$package->getPrettyVersion().') does not satisfy that requirement.';
} else {
$text .= ' -> your PHP version ('.$package->getPrettyVersion().') does not satisfy that requirement.';
}
return $text;
} }
} elseif (0 === strpos($targetName, 'ext-')) {
if ($targetName === 'hhvm') {
return $text . ' -> you are running this with PHP and not HHVM.';
}
$packages = $pool->whatProvides($targetName);
$package = count($packages) ? current($packages) : phpversion();
if (!($package instanceof CompletePackage)) {
return $text . ' -> your PHP version ('.phpversion().') does not satisfy that requirement.';
}
$extra = $package->getExtra();
if (!empty($extra['config.platform'])) {
$text .= ' -> your PHP version ('.phpversion().') overridden by "config.platform.php" version ('.$package->getPrettyVersion().') does not satisfy that requirement.';
} else {
$text .= ' -> your PHP version ('.$package->getPrettyVersion().') does not satisfy that requirement.';
}
return $text;
}
if (0 === strpos($targetName, 'ext-')) {
// handle php extensions // handle php extensions
$ext = substr($targetName, 4); $ext = substr($targetName, 4);
$error = extension_loaded($ext) ? 'has the wrong version ('.(phpversion($ext) ?: '0').') installed' : 'is missing from your system'; $error = extension_loaded($ext) ? 'has the wrong version ('.(phpversion($ext) ?: '0').') installed' : 'is missing from your system';
return $text . ' -> the requested PHP extension '.$ext.' '.$error.'.'; return $text . ' -> the requested PHP extension '.$ext.' '.$error.'.';
} elseif (0 === strpos($targetName, 'lib-')) { }
if (0 === strpos($targetName, 'lib-')) {
// handle linked libs // handle linked libs
$lib = substr($targetName, 4); $lib = substr($targetName, 4);
return $text . ' -> the requested linked library '.$lib.' has the wrong version installed or is missing from your system, make sure to have the extension providing it.'; return $text . ' -> the requested linked library '.$lib.' has the wrong version installed or is missing from your system, make sure to have the extension providing it.';
} else {
if ($providers = $pool->whatProvides($targetName, $this->reasonData->getConstraint(), true, true)) {
return $text . ' -> satisfiable by ' . $this->formatPackagesUnique($pool, $providers) .' but these conflict with your requirements or minimum-stability.';
}
return $text . ' -> no matching package found.';
} }
if ($providers = $pool->whatProvides($targetName, $this->reasonData->getConstraint(), true, true)) {
return $text . ' -> satisfiable by ' . $this->formatPackagesUnique($pool, $providers) .' but these conflict with your requirements or minimum-stability.';
}
return $text . ' -> no matching package found.';
} }
return $text; return $text;

View File

@ -47,12 +47,17 @@ class Platform
{ {
if (false !== ($home = getenv('HOME'))) { if (false !== ($home = getenv('HOME'))) {
return $home; return $home;
} elseif (self::isWindows() && false !== ($home = getenv('USERPROFILE'))) { }
if (self::isWindows() && false !== ($home = getenv('USERPROFILE'))) {
return $home; return $home;
} elseif (function_exists('posix_getuid') && function_exists('posix_getpwuid')) { }
if (function_exists('posix_getuid') && function_exists('posix_getpwuid')) {
$info = posix_getpwuid(posix_getuid()); $info = posix_getpwuid(posix_getuid());
return $info['dir']; return $info['dir'];
} }
throw new \RuntimeException('Could not determine user directory'); throw new \RuntimeException('Could not determine user directory');
} }

View File

@ -161,9 +161,13 @@ class EventDispatcherTest extends TestCase
->will($this->returnCallback(function (Event $event) { ->will($this->returnCallback(function (Event $event) {
if ($event->getName() === 'root') { if ($event->getName() === 'root') {
return array('@group'); return array('@group');
} elseif ($event->getName() === 'group') { }
if ($event->getName() === 'group') {
return array('echo -n foo', '@subgroup', 'echo -n bar'); return array('echo -n foo', '@subgroup', 'echo -n bar');
} elseif ($event->getName() === 'subgroup') { }
if ($event->getName() === 'subgroup') {
return array('echo -n baz'); return array('echo -n baz');
} }
@ -201,7 +205,9 @@ class EventDispatcherTest extends TestCase
->will($this->returnCallback(function (Event $event) { ->will($this->returnCallback(function (Event $event) {
if ($event->getName() === 'root') { if ($event->getName() === 'root') {
return array('@recurse'); return array('@recurse');
} elseif ($event->getName() === 'recurse') { }
if ($event->getName() === 'recurse') {
return array('@root'); return array('@root');
} }