Skip to content

Commit 4155b9f

Browse files
Merge branch '7.3' into 7.4
* 7.3: [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 87ad3ca + 1f04b60 commit 4155b9f

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
@@ -421,6 +421,15 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti
421421
if (CompletionInput::TYPE_OPTION_NAME === $input->getCompletionType()) {
422422
$suggestions->suggestOptions($this->getDefinition()->getOptions());
423423
}
424+
425+
if (
426+
CompletionInput::TYPE_OPTION_VALUE === $input->getCompletionType()
427+
&& ($definition = $this->getDefinition())->hasOption($input->getCompletionName())
428+
) {
429+
$definition->getOption($input->getCompletionName())->complete($input, $suggestions);
430+
431+
return;
432+
}
424433
}
425434

426435
/**

Tests/Command/CompleteCommandTest.php

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

@@ -35,6 +36,8 @@ protected function setUp(): void
3536

3637
$this->application = new Application();
3738
$this->application->addCommand(new CompleteCommandTest_HelloCommand());
39+
$this->application->getDefinition()
40+
->addOption(new InputOption('global-option', null, InputOption::VALUE_REQUIRED, suggestedValues: ['foo', 'bar', 'baz']));
3841

3942
$this->command->setApplication($this->application);
4043
$this->tester = new CommandTester($this->command);
@@ -114,10 +117,12 @@ public function testCompleteCommandInputDefinition(array $input, array $suggesti
114117

115118
public static function provideCompleteCommandInputDefinitionInputs()
116119
{
117-
yield 'definition' => [['bin/console', 'hello', '-'], ['--help', '--silent', '--quiet', '--verbose', '--version', '--ansi', '--no-ansi', '--no-interaction']];
120+
yield 'definition' => [['bin/console', 'hello', '-'], ['--help', '--silent', '--quiet', '--verbose', '--version', '--ansi', '--no-ansi', '--no-interaction', '--global-option']];
118121
yield 'custom' => [['bin/console', 'hello'], ['Fabien', 'Robin', 'Wouter']];
119-
yield 'definition-aliased' => [['bin/console', 'ahoy', '-'], ['--help', '--silent', '--quiet', '--verbose', '--version', '--ansi', '--no-ansi', '--no-interaction']];
122+
yield 'definition-aliased' => [['bin/console', 'ahoy', '-'], ['--help', '--silent', '--quiet', '--verbose', '--version', '--ansi', '--no-ansi', '--no-interaction', '--global-option']];
120123
yield 'custom-aliased' => [['bin/console', 'ahoy'], ['Fabien', 'Robin', 'Wouter']];
124+
yield 'global-option-values' => [['bin/console', '--global-option'], ['foo', 'bar', 'baz']];
125+
yield 'global-option-with-command-values' => [['bin/console', 'ahoy', '--global-option'], ['foo', 'bar', 'baz']];
121126
}
122127

123128
private function execute(array $input)
@@ -142,6 +147,10 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti
142147
{
143148
if ($input->mustSuggestArgumentValuesFor('name')) {
144149
$suggestions->suggestValues(['Fabien', 'Robin', 'Wouter']);
150+
151+
return;
145152
}
153+
154+
parent::complete($input, $suggestions);
146155
}
147156
}

0 commit comments

Comments
 (0)