Pārlūkot izejas kodu

Refactor to use ArrayInput instead of StringInput

Jordi Boggiano 9 gadi atpakaļ
vecāks
revīzija
7def8cf6e5
1 mainītis faili ar 16 papildinājumiem un 6 dzēšanām
  1. 16 6
      src/Composer/Command/OutdatedCommand.php

+ 16 - 6
src/Composer/Command/OutdatedCommand.php

@@ -12,10 +12,9 @@
 
 namespace Composer\Command;
 
-use Composer\Util\ProcessExecutor;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\StringInput;
+use Symfony\Component\Console\Input\ArrayInput;
 use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Output\OutputInterface;
 
@@ -53,10 +52,21 @@ EOT
 
     protected function execute(InputInterface $input, OutputInterface $output)
     {
-        $args = array($input->getArgument('package') ? ProcessExecutor::escape($input->getArgument('package')) : '');
-        $args[] = $input->getOption('outdated') ? ProcessExecutor::escape('--outdated') : '';
-        $args[] = $input->getOption('direct') ? ProcessExecutor::escape('--direct') : '';
-        $input = new StringInput('show --latest '.implode(' ', $args));
+        $args = array(
+            'show',
+            '--latest' => true,
+        );
+        if ($input->getOption('outdated')) {
+            $args['--outdated'] = true;
+        }
+        if ($input->getOption('direct')) {
+            $args['--direct'] = true;
+        }
+        if ($input->getArgument('package')) {
+            $args['package'] = $input->getArgument('package');
+        }
+
+        $input = new ArrayInput($args);
 
         return $this->getApplication()->run($input, $output);
     }