From 37dcf77f2aa988f54f54a4df6a2bbb78d94eb113 Mon Sep 17 00:00:00 2001 From: Andrii Vasyliev Date: Fri, 19 May 2017 13:39:21 +0000 Subject: [PATCH] improved tree colors --- src/Plugin.php | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/Plugin.php b/src/Plugin.php index fe98e5a..739aa5b 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -408,31 +408,18 @@ protected function showDepsTree() return; } - $this->initStyles(); foreach (array_reverse($this->orderedList) as $name => $depth) { $deps = $this->originalFiles[$name]; - $color = $this->colors[$depth]; + $color = $this->colors[$depth % count($this->colors)]; $indent = str_repeat(' ', $depth - 1); $package = $this->plainList[$name]; - $showdeps = $deps ? '[' . implode(',', array_keys($deps)) . ']' : ''; - $this->io->write(sprintf('%s - <%s>%s %s %s', $indent, $color, $name, $color, $package->getFullPrettyVersion(), $showdeps)); + $showdeps = $deps ? '[' . implode(',', array_keys($deps)) . ']' : ''; + $this->io->write(sprintf('%s - %s %s %s', $indent, $color, $name, $package->getFullPrettyVersion(), $showdeps)); } } protected $colors = ['red', 'green', 'yellow', 'cyan', 'magenta', 'blue']; - protected function initStyles() - { - $ref = new \ReflectionProperty(get_class($this->io), 'output'); - $ref->setAccessible(true); - $output = $ref->getValue($this->io); - - foreach ($this->colors as $color) { - $style = new OutputFormatterStyle($color); - $output->getFormatter()->setStyle($color, $style); - } - } - /** * Get absolute path to package base dir. * @return string