X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=vendor%2Fstecman%2Fsymfony-console-completion%2Fsrc%2FCompletionHandler.php;h=905ea5a0816d141d88578dd59e7cba8c4f56e28d;hb=5b8bb166bfa98770daef9de5c127fc2e6ef02340;hp=531fae339e6f81664e8cbe344ca71e3294706ad9;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/stecman/symfony-console-completion/src/CompletionHandler.php b/vendor/stecman/symfony-console-completion/src/CompletionHandler.php index 531fae339..905ea5a08 100644 --- a/vendor/stecman/symfony-console-completion/src/CompletionHandler.php +++ b/vendor/stecman/symfony-console-completion/src/CompletionHandler.php @@ -39,12 +39,13 @@ class CompletionHandler $this->application = $application; $this->context = $context; + // Set up completions for commands that are built-into Application $this->addHandler( new Completion( 'help', 'command_name', Completion::TYPE_ARGUMENT, - array_keys($application->all()) + $this->getCommandNames() ) ); @@ -256,14 +257,7 @@ class CompletionHandler protected function completeForCommandName() { if (!$this->command || (count($this->context->getWords()) == 2 && $this->context->getWordIndex() == 1)) { - $commands = $this->application->all(); - $names = array_keys($commands); - - if ($key = array_search('_completion', $names)) { - unset($names[$key]); - } - - return $names; + return $this->getCommandNames(); } return false; @@ -442,4 +436,37 @@ class CompletionHandler $this->application->getDefinition()->getOptions() ); } + + /** + * Get command names available for completion + * + * Filters out hidden commands where supported. + * + * @return string[] + */ + protected function getCommandNames() + { + // Command::Hidden isn't supported before Symfony Console 3.2.0 + // We don't complete hidden command names as these are intended to be private + if (method_exists('\Symfony\Component\Console\Command\Command', 'isHidden')) { + $commands = array(); + + foreach ($this->application->all() as $name => $command) { + if (!$command->isHidden()) { + $commands[] = $name; + } + } + + return $commands; + + } else { + + // Fallback for compatibility with Symfony Console < 3.2.0 + // This was the behaviour prior to pull #75 + $commands = $this->application->all(); + unset($commands['_completion']); + + return array_keys($commands); + } + } }