Эх сурвалжийг харах

Add hint in solver exceptions as to what may be wrong

Jordi Boggiano 12 жил өмнө
parent
commit
6573fd3f77

+ 4 - 0
src/Composer/DependencyResolver/SolverProblemsException.php

@@ -35,6 +35,10 @@ class SolverProblemsException extends \RuntimeException
             $text .= "  Problem ".($i+1).$problem->getPrettyString($this->installedMap)."\n";
         }
 
+        if (strpos($text, 'could not be found') || strpos($text, 'no matching package found')) {
+            $text .= "\nPotential causes:\n - A typo in the package name\n - The package is not available in a stable-enough version according to your minimum-stability setting\n   see https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion for more details.\n";
+        }
+
         return $text;
     }
 

+ 5 - 1
tests/Composer/Test/DependencyResolver/SolverTest.php

@@ -699,7 +699,11 @@ class SolverTest extends TestCase
             $msg = "\n";
             $msg .= "  Problem 1\n";
             $msg .= "    - Installation request for a -> satisfiable by A 1.0.\n";
-            $msg .= "    - A 1.0 requires b >= 2.0 -> no matching package found.\n";
+            $msg .= "    - A 1.0 requires b >= 2.0 -> no matching package found.\n\n";
+            $msg .= "Potential causes:\n";
+            $msg .= " - A typo in the package name\n";
+            $msg .= " - The package is not available in a stable-enough version according to your minimum-stability setting\n";
+            $msg .= "   see https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion for more details.\n";
             $this->assertEquals($msg, $e->getMessage());
         }
     }