DebugSolver.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 DebugSolver extends Solver
  16. {
  17. protected function printDecisionMap()
  18. {
  19. echo "\nDecisionMap: \n";
  20. foreach ($this->decisionMap as $packageId => $level) {
  21. if ($packageId === 0) {
  22. continue;
  23. }
  24. if ($level > 0) {
  25. echo ' +' . $this->pool->packageById($packageId)."\n";
  26. } elseif ($level < 0) {
  27. echo ' -' . $this->pool->packageById($packageId)."\n";
  28. } else {
  29. echo ' ?' . $this->pool->packageById($packageId)."\n";
  30. }
  31. }
  32. echo "\n";
  33. }
  34. protected function printDecisionQueue()
  35. {
  36. echo "DecisionQueue: \n";
  37. foreach ($this->decisionQueue as $i => $literal) {
  38. echo ' ' . $this->pool->literalToString($literal) . ' ' . $this->decisionQueueWhy[$i]." level ".$this->decisionMap[abs($literal)]."\n";
  39. }
  40. echo "\n";
  41. }
  42. protected function printWatches()
  43. {
  44. echo "\nWatches:\n";
  45. foreach ($this->watches as $literalId => $watch) {
  46. echo ' '.$this->literalFromId($literalId)."\n";
  47. $queue = array(array(' ', $watch));
  48. while (!empty($queue)) {
  49. list($indent, $watch) = array_pop($queue);
  50. echo $indent.$watch;
  51. if ($watch) {
  52. echo ' [id='.$watch->getId().',watch1='.$this->literalFromId($watch->watch1).',watch2='.$this->literalFromId($watch->watch2)."]";
  53. }
  54. echo "\n";
  55. if ($watch && ($watch->next1 == $watch || $watch->next2 == $watch)) {
  56. if ($watch->next1 == $watch) {
  57. echo $indent." 1 *RECURSION*";
  58. }
  59. if ($watch->next2 == $watch) {
  60. echo $indent." 2 *RECURSION*";
  61. }
  62. } elseif ($watch && ($watch->next1 || $watch->next2)) {
  63. $indent = str_replace(array('1', '2'), ' ', $indent);
  64. array_push($queue, array($indent.' 2 ', $watch->next2));
  65. array_push($queue, array($indent.' 1 ', $watch->next1));
  66. }
  67. }
  68. echo "\n";
  69. }
  70. }
  71. }