From 17788c76f635f0f4ff43e19e672e651fc144faf4 Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Wed, 6 Feb 2019 12:51:30 -0800 Subject: [PATCH] Better error message for present but incompatible versions hhvm-nightly (and next week's release) now report 4.x, so all the 3.x constraints are now giving misleading error messages with this patch. Before: ``` - facebook/fbexpect v2.3.0 requires hhvm ^3.28 -> you are running this with PHP and not HHVM. ``` After: ``` - facebook/fbexpect v2.3.0 requires hhvm ^3.28 -> your HHVM version (4.0.0-dev) does not satisfy that requirement. ``` --- src/Composer/DependencyResolver/Rule.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Composer/DependencyResolver/Rule.php b/src/Composer/DependencyResolver/Rule.php index 4760b8964..82c9c499c 100644 --- a/src/Composer/DependencyResolver/Rule.php +++ b/src/Composer/DependencyResolver/Rule.php @@ -175,13 +175,18 @@ abstract class Rule return $text . ' -> your HHVM version does not satisfy that requirement.'; } - 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 ($targetName === 'hhvm') { + if ($package instanceof CompletePackage) { + return $text . ' -> your HHVM version ('.$package->getPrettyVersion().') does not satisfy that requirement.'; + } else { + return $text . ' -> you are running this with PHP and not HHVM.'; + } + } + + if (!($package instanceof CompletePackage)) { return $text . ' -> your PHP version ('.phpversion().') does not satisfy that requirement.'; }