SolverProblemsException.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\DependencyResolver;
  12. /**
  13. * @author Nils Adermann <naderman@naderman.de>
  14. */
  15. class SolverProblemsException extends \RuntimeException
  16. {
  17. protected $problems;
  18. protected $installedMap;
  19. public function __construct(array $problems, array $installedMap)
  20. {
  21. $this->problems = $problems;
  22. $this->installedMap = $installedMap;
  23. parent::__construct($this->createMessage(), 2);
  24. }
  25. protected function createMessage()
  26. {
  27. $text = "\n";
  28. foreach ($this->problems as $i => $problem) {
  29. $text .= " Problem ".($i + 1).$problem->getPrettyString($this->installedMap)."\n";
  30. }
  31. if (strpos($text, 'could not be found') || strpos($text, 'no matching package found')) {
  32. $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\nRead <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.";
  33. }
  34. return $text;
  35. }
  36. public function getProblems()
  37. {
  38. return $this->problems;
  39. }
  40. }