Browse Source

Display prettier messages for second-degree required exts to avoid confusion

Jordi Boggiano 12 years ago
parent
commit
a8171f5be0

+ 7 - 1
src/Composer/DependencyResolver/Problem.php

@@ -81,6 +81,13 @@ class Problem
                     return "\n    - The requested PHP extension ".$job['packageName'].$this->constraintToText($job['constraint']).' '.$error.'.';
                 }
 
+                // handle linked libs
+                if (0 === stripos($job['packageName'], 'lib-')) {
+                    $lib = substr($job['packageName'], 4);
+
+                    return "\n    - The requested linked library ".$job['packageName'].$this->constraintToText($job['constraint']).' has the wrong version instaled or is missing from your system, make sure to have the extension providing it.';
+                }
+
                 return "\n    - The requested package ".$job['packageName'].$this->constraintToText($job['constraint']).' could not be found.';
             }
         }
@@ -88,7 +95,6 @@ class Problem
         $messages = array();
 
         foreach ($reasons as $reason) {
-
             $rule = $reason['rule'];
             $job = $reason['job'];
 

+ 16 - 1
src/Composer/DependencyResolver/Rule.php

@@ -191,7 +191,22 @@ class Rule
                     }
                     $text .= ' -> satisfiable by '.implode(', ', $requireText).'.';
                 } else {
-                    $text .= ' -> no matching package found.';
+                    $targetName = $this->reasonData->getTarget();
+
+                    // handle php extensions
+                    if (0 === strpos($targetName, 'ext-')) {
+                        $ext = substr($targetName, 4);
+                        $error = extension_loaded($ext) ? 'has the wrong version ('.phpversion($ext).') installed' : 'is missing from your system';
+
+                        $text .= ' -> the requested PHP extension '.$ext.' '.$error.'.';
+                    } elseif (0 === strpos($targetName, 'lib-')) {
+                        // handle linked libs
+                        $lib = substr($targetName, 4);
+
+                        $text .= ' -> the requested linked library '.$lib.' has the wrong version instaled or is missing from your system, make sure to have the extension providing it.';
+                    } else {
+                        $text .= ' -> no matching package found.';
+                    }
                 }
 
                 return $text;