PluginProbe
Independent Analytics – WordPress Analytics Plugin / 1.25.1
Independent Analytics – WordPress Analytics Plugin v1.25.1
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 All 120 releases
independent-analytics / vendor / symfony / console / Tester / CommandCompletionTester.php
CommandCompletionTester.php
49 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 namespace IAWP_SCOPED\Symfony\Component\Console\Tester;
12
13 use IAWP_SCOPED\Symfony\Component\Console\Command\Command;
14 use IAWP_SCOPED\Symfony\Component\Console\Completion\CompletionInput;
15 use IAWP_SCOPED\Symfony\Component\Console\Completion\CompletionSuggestions;
16 /**
17 * Eases the testing of command completion.
18 *
19 * @author Jérôme Tamarelle <jerome@tamarelle.net>
20 */
21 class CommandCompletionTester
22 {
23 private $command;
24 public function __construct(Command $command)
25 {
26 $this->command = $command;
27 }
28 /**
29 * Create completion suggestions from input tokens.
30 */
31 public function complete(array $input) : array
32 {
33 $currentIndex = \count($input);
34 if ('' === \end($input)) {
35 \array_pop($input);
36 }
37 \array_unshift($input, $this->command->getName());
38 $completionInput = CompletionInput::fromTokens($input, $currentIndex);
39 $completionInput->bind($this->command->getDefinition());
40 $suggestions = new CompletionSuggestions();
41 $this->command->complete($completionInput, $suggestions);
42 $options = [];
43 foreach ($suggestions->getOptionSuggestions() as $option) {
44 $options[] = '--' . $option->getName();
45 }
46 return \array_map('strval', \array_merge($options, $suggestions->getValueSuggestions()));
47 }
48 }
49