From 286593cf999ecbc2e27ff2517f0fe65a1ca86436 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 15 May 2012 21:37:57 +0200 Subject: [PATCH] Move solver debugging code into solver subclass --- .../DependencyResolver/DebugSolver.php | 83 +++++++++++++++++++ src/Composer/DependencyResolver/Solver.php | 64 -------------- 2 files changed, 83 insertions(+), 64 deletions(-) create mode 100644 src/Composer/DependencyResolver/DebugSolver.php diff --git a/src/Composer/DependencyResolver/DebugSolver.php b/src/Composer/DependencyResolver/DebugSolver.php new file mode 100644 index 000000000..b3ff0ca63 --- /dev/null +++ b/src/Composer/DependencyResolver/DebugSolver.php @@ -0,0 +1,83 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\DependencyResolver; + +/** + * @author Nils Adermann + */ +class DebugSolver extends Solver +{ + private function printDecisionMap() + { + echo "\nDecisionMap: \n"; + foreach ($this->decisionMap as $packageId => $level) { + if ($packageId === 0) { + continue; + } + if ($level > 0) { + echo ' +' . $this->pool->packageById($packageId)."\n"; + } elseif ($level < 0) { + echo ' -' . $this->pool->packageById($packageId)."\n"; + } else { + echo ' ?' . $this->pool->packageById($packageId)."\n"; + } + } + echo "\n"; + } + + private function printDecisionQueue() + { + echo "DecisionQueue: \n"; + foreach ($this->decisionQueue as $i => $literal) { + echo ' ' . $literal . ' ' . $this->decisionQueueWhy[$i]." level ".$this->decisionMap[$literal->getPackageId()]."\n"; + } + echo "\n"; + } + + private function printWatches() + { + echo "\nWatches:\n"; + foreach ($this->watches as $literalId => $watch) { + echo ' '.$this->literalFromId($literalId)."\n"; + $queue = array(array(' ', $watch)); + + while (!empty($queue)) { + list($indent, $watch) = array_pop($queue); + + echo $indent.$watch; + + if ($watch) { + echo ' [id='.$watch->getId().',watch1='.$this->literalFromId($watch->watch1).',watch2='.$this->literalFromId($watch->watch2)."]"; + } + + echo "\n"; + + if ($watch && ($watch->next1 == $watch || $watch->next2 == $watch)) { + if ($watch->next1 == $watch) { + echo $indent." 1 *RECURSION*"; + } + if ($watch->next2 == $watch) { + echo $indent." 2 *RECURSION*"; + } + } elseif ($watch && ($watch->next1 || $watch->next2)) { + $indent = str_replace(array('1', '2'), ' ', $indent); + + array_push($queue, array($indent.' 2 ', $watch->next2)); + array_push($queue, array($indent.' 1 ', $watch->next1)); + } + } + + echo "\n"; + } + } +} diff --git a/src/Composer/DependencyResolver/Solver.php b/src/Composer/DependencyResolver/Solver.php index faa97bd14..8e77264db 100644 --- a/src/Composer/DependencyResolver/Solver.php +++ b/src/Composer/DependencyResolver/Solver.php @@ -1050,68 +1050,4 @@ class Solver break; } } - - private function printDecisionMap() - { - echo "\nDecisionMap: \n"; - foreach ($this->decisionMap as $packageId => $level) { - if ($packageId === 0) { - continue; - } - if ($level > 0) { - echo ' +' . $this->pool->packageById($packageId)."\n"; - } elseif ($level < 0) { - echo ' -' . $this->pool->packageById($packageId)."\n"; - } else { - echo ' ?' . $this->pool->packageById($packageId)."\n"; - } - } - echo "\n"; - } - - private function printDecisionQueue() - { - echo "DecisionQueue: \n"; - foreach ($this->decisionQueue as $i => $literal) { - echo ' ' . $literal . ' ' . $this->decisionQueueWhy[$i]." level ".$this->decisionMap[$literal->getPackageId()]."\n"; - } - echo "\n"; - } - - private function printWatches() - { - echo "\nWatches:\n"; - foreach ($this->watches as $literalId => $watch) { - echo ' '.$this->literalFromId($literalId)."\n"; - $queue = array(array(' ', $watch)); - - while (!empty($queue)) { - list($indent, $watch) = array_pop($queue); - - echo $indent.$watch; - - if ($watch) { - echo ' [id='.$watch->getId().',watch1='.$this->literalFromId($watch->watch1).',watch2='.$this->literalFromId($watch->watch2)."]"; - } - - echo "\n"; - - if ($watch && ($watch->next1 == $watch || $watch->next2 == $watch)) { - if ($watch->next1 == $watch) { - echo $indent." 1 *RECURSION*"; - } - if ($watch->next2 == $watch) { - echo $indent." 2 *RECURSION*"; - } - } elseif ($watch && ($watch->next1 || $watch->next2)) { - $indent = str_replace(array('1', '2'), ' ', $indent); - - array_push($queue, array($indent.' 2 ', $watch->next2)); - array_push($queue, array($indent.' 1 ', $watch->next1)); - } - } - - echo "\n"; - } - } }