From 83a106bd79994e0962b6f7a7b0b89c25c42581d2 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 8 Jan 2012 22:39:42 +0100 Subject: [PATCH] Add recommends and package versions to the depends command --- src/Composer/Command/DependsCommand.php | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/Composer/Command/DependsCommand.php b/src/Composer/Command/DependsCommand.php index 1b8afdffa..9079e46af 100644 --- a/src/Composer/Command/DependsCommand.php +++ b/src/Composer/Command/DependsCommand.php @@ -46,7 +46,7 @@ EOT $composer = $this->getComposer(); $references = $this->getReferences($input, $output, $composer); - $this->printLinks($input, $output, $references); + $this->printReferences($input, $output, $references); } /** @@ -58,7 +58,7 @@ EOT * @return array * @throws \InvalidArgumentException */ - protected function getReferences(InputInterface $input, OutputInterface $output, Composer $composer) + private function getReferences(InputInterface $input, OutputInterface $output, Composer $composer) { $needle = $input->getArgument('package'); @@ -72,15 +72,11 @@ EOT ); foreach ($repos as $repository) { foreach ($repository->getPackages() as $package) { - foreach ($package->getRequires() as $link) { - if ($link->getTarget() === $needle) { - $references[] = $link; - } - } - - foreach ($package->getSuggests() as $link) { - if ($link->getTarget() === $needle) { - $references[] = $link; + foreach (array('requires', 'recommends', 'suggests') as $type) { + foreach ($package->{'get'.$type}() as $link) { + if ($link->getTarget() === $needle) { + $references[] = array($type, $package, $link); + } } } } @@ -89,10 +85,10 @@ EOT return $references; } - protected function printLinks(InputInterface $input, OutputInterface $output, array $links) + private function printReferences(InputInterface $input, OutputInterface $output, array $references) { - foreach ($links as $link) { - $output->writeln($link->getSource() . ' ' . $link->getPrettyConstraint() . ''); + foreach ($references as $ref) { + $output->writeln($ref[1]->getPrettyName() . ' ' . $ref[1]->getPrettyVersion() . ' ' . $ref[0] . ' ' . $ref[2]->getPrettyConstraint()); } } } \ No newline at end of file