Skip to content

Commit 1f04b60

Browse files
Merge branch '6.4' into 7.3
* 6.4: [Routing] Fix case sensitivity for static host matching in compiled routes [Routing] Fix localized prefix updates breaking aliases [Routing] Fix addNamePrefix breaking aliases to external routes [Workflow] Fix MethodMarkingStore crash with inherited uninitialized properties [AssetMapper] Fix entrypoint status lost during update [Console] Fix completion for global options values
2 parents ddb064e + 7f0dd9a commit 1f04b60

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

Application.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,15 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti
424424
if (CompletionInput::TYPE_OPTION_NAME === $input->getCompletionType()) {
425425
$suggestions->suggestOptions($this->getDefinition()->getOptions());
426426
}
427+
428+
if (
429+
CompletionInput::TYPE_OPTION_VALUE === $input->getCompletionType()
430+
&& ($definition = $this->getDefinition())->hasOption($input->getCompletionName())
431+
) {
432+
$definition->getOption($input->getCompletionName())->complete($input, $suggestions);
433+
434+
return;
435+
}
427436
}
428437

429438
/**

Tests/Command/CompleteCommandTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Console\Completion\CompletionSuggestions;
2020
use Symfony\Component\Console\Completion\Output\BashCompletionOutput;
2121
use Symfony\Component\Console\Input\InputArgument;
22+
use Symfony\Component\Console\Input\InputOption;
2223
use Symfony\Component\Console\Output\OutputInterface;
2324
use Symfony\Component\Console\Tester\CommandTester;
2425

@@ -34,6 +35,8 @@ protected function setUp(): void
3435

3536
$this->application = new Application();
3637
$this->application->add(new CompleteCommandTest_HelloCommand());
38+
$this->application->getDefinition()
39+
->addOption(new InputOption('global-option', null, InputOption::VALUE_REQUIRED, suggestedValues: ['foo', 'bar', 'baz']));
3740

3841
$this->command->setApplication($this->application);
3942
$this->tester = new CommandTester($this->command);
@@ -119,10 +122,12 @@ public function testCompleteCommandInputDefinition(array $input, array $suggesti
119122

120123
public static function provideCompleteCommandInputDefinitionInputs()
121124
{
122-
yield 'definition' => [['bin/console', 'hello', '-'], ['--help', '--silent', '--quiet', '--verbose', '--version', '--ansi', '--no-ansi', '--no-interaction']];
125+
yield 'definition' => [['bin/console', 'hello', '-'], ['--help', '--silent', '--quiet', '--verbose', '--version', '--ansi', '--no-ansi', '--no-interaction', '--global-option']];
123126
yield 'custom' => [['bin/console', 'hello'], ['Fabien', 'Robin', 'Wouter']];
124-
yield 'definition-aliased' => [['bin/console', 'ahoy', '-'], ['--help', '--silent', '--quiet', '--verbose', '--version', '--ansi', '--no-ansi', '--no-interaction']];
127+
yield 'definition-aliased' => [['bin/console', 'ahoy', '-'], ['--help', '--silent', '--quiet', '--verbose', '--version', '--ansi', '--no-ansi', '--no-interaction', '--global-option']];
125128
yield 'custom-aliased' => [['bin/console', 'ahoy'], ['Fabien', 'Robin', 'Wouter']];
129+
yield 'global-option-values' => [['bin/console', '--global-option'], ['foo', 'bar', 'baz']];
130+
yield 'global-option-with-command-values' => [['bin/console', 'ahoy', '--global-option'], ['foo', 'bar', 'baz']];
126131
}
127132

128133
private function execute(array $input)
@@ -147,6 +152,10 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti
147152
{
148153
if ($input->mustSuggestArgumentValuesFor('name')) {
149154
$suggestions->suggestValues(['Fabien', 'Robin', 'Wouter']);
155+
156+
return;
150157
}
158+
159+
parent::complete($input, $suggestions);
151160
}
152161
}

0 commit comments

Comments
 (0)