diff --git a/src/Composer/DependencyResolver/Problem.php b/src/Composer/DependencyResolver/Problem.php index 51af36e80..4aa0532b0 100644 --- a/src/Composer/DependencyResolver/Problem.php +++ b/src/Composer/DependencyResolver/Problem.php @@ -33,6 +33,13 @@ class Problem protected $section = 0; + protected $pool; + + public function __construct(Pool $pool) + { + $this->pool = $pool; + } + /** * Add a rule as a reason * @@ -88,6 +95,10 @@ class Problem return "\n - The requested linked library ".$job['packageName'].$this->constraintToText($job['constraint']).' has the wrong version installed or is missing from your system, make sure to have the extension providing it.'; } + if (!$this->pool->whatProvides($job['packageName'])) { + return "\n - The requested package ".$job['packageName'].' could not be found in any version, you most likely did a typo in the package name.'; + } + return "\n - The requested package ".$job['packageName'].$this->constraintToText($job['constraint']).' could not be found.'; } } diff --git a/src/Composer/DependencyResolver/Solver.php b/src/Composer/DependencyResolver/Solver.php index 5a12b73e5..1d736d009 100644 --- a/src/Composer/DependencyResolver/Solver.php +++ b/src/Composer/DependencyResolver/Solver.php @@ -83,7 +83,7 @@ class Solver if ($conflict && RuleSet::TYPE_PACKAGE === $conflict->getType()) { - $problem = new Problem; + $problem = new Problem($this->pool); $problem->addRule($rule); $problem->addRule($conflict); @@ -93,7 +93,7 @@ class Solver } // conflict with another job - $problem = new Problem; + $problem = new Problem($this->pool); $problem->addRule($rule); $problem->addRule($conflict); @@ -146,7 +146,7 @@ class Solver case 'install': if (!$job['packages']) { - $problem = new Problem(); + $problem = new Problem($this->pool); $problem->addRule(new Rule($this->pool, array(), null, null, $job)); $this->problems[] = $problem; } @@ -465,7 +465,7 @@ class Solver private function analyzeUnsolvable($conflictRule, $disableRules) { - $problem = new Problem; + $problem = new Problem($this->pool); $problem->addRule($conflictRule); $this->analyzeUnsolvableRule($problem, $conflictRule); diff --git a/tests/Composer/Test/DependencyResolver/SolverTest.php b/tests/Composer/Test/DependencyResolver/SolverTest.php index 9ca29bcd2..c674fa559 100644 --- a/tests/Composer/Test/DependencyResolver/SolverTest.php +++ b/tests/Composer/Test/DependencyResolver/SolverTest.php @@ -75,7 +75,7 @@ class SolverTest extends TestCase } catch (SolverProblemsException $e) { $problems = $e->getProblems(); $this->assertEquals(1, count($problems)); - $this->assertEquals("\n - The requested package b == 1 could not be found.", $problems[0]->getPrettyString()); + $this->assertEquals("\n - The requested package b could not be found in any version, you most likely did a typo in the package name.", $problems[0]->getPrettyString()); } }