Skip to content

Commit

Permalink
Merge branch '5.4' into 6.0
Browse files Browse the repository at this point in the history
* 5.4:
  [Console] Fixes "Incorrectly nested style tag found" error when using multi-line header content
  Fix LDAP connection options
  fix probably undefined variable $expireAt
  Fix aliases handling in command name completion
  Fix division by zero
  Allow ErrorHandler ^5.0 to be used in HttpKernel
  [Security/Http] Ignore invalid URLs found in failure/success paths
  Fix typo
  • Loading branch information
nicolas-grekas committed May 14, 2022
2 parents 042e410 + 1894919 commit 47a6389
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 10 deletions.
15 changes: 12 additions & 3 deletions Application.php
Expand Up @@ -353,9 +353,18 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti
CompletionInput::TYPE_ARGUMENT_VALUE === $input->getCompletionType()
&& 'command' === $input->getCompletionName()
) {
$suggestions->suggestValues(array_filter(array_map(function (Command $command) {
return $command->isHidden() ? null : $command->getName();
}, $this->all())));
$commandNames = [];
foreach ($this->all() as $name => $command) {
// skip hidden commands and aliased commands as they already get added below
if ($command->isHidden() || $command->getName() !== $name) {
continue;
}
$commandNames[] = $command->getName();
foreach ($command->getAliases() as $name) {
$commandNames[] = $name;
}
}
$suggestions->suggestValues(array_filter($commandNames));

return;
}
Expand Down
3 changes: 2 additions & 1 deletion Command/CompleteCommand.php
Expand Up @@ -105,11 +105,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
} elseif (
$completionInput->mustSuggestArgumentValuesFor('command')
&& $command->getName() !== $completionInput->getCompletionValue()
&& !\in_array($completionInput->getCompletionValue(), $command->getAliases(), true)
) {
$this->log(' No command found, completing using the Application class.');

// expand shortcut names ("cache:cl<TAB>") into their full name ("cache:clear")
$suggestions->suggestValue($command->getName());
$suggestions->suggestValues(array_filter(array_merge([$command->getName()], $command->getAliases())));
} else {
$command->mergeApplicationDefinition();
$completionInput->bind($command->getDefinition());
Expand Down
2 changes: 1 addition & 1 deletion Helper/Table.php
Expand Up @@ -561,7 +561,7 @@ private function buildTableRows(array $rows): TableRows
}
$escaped = implode("\n", array_map([OutputFormatter::class, 'escapeTrailingBackslash'], explode("\n", $cell)));
$cell = $cell instanceof TableCell ? new TableCell($escaped, ['colspan' => $cell->getColspan()]) : $escaped;
$lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
$lines = explode("\n", str_replace("\n", "<fg=default;bg=default></>\n", $cell));
foreach ($lines as $lineKey => $line) {
if ($colspan > 1) {
$line = new TableCell($line, ['colspan' => $colspan]);
Expand Down
10 changes: 7 additions & 3 deletions Tests/Command/CompleteCommandTest.php
Expand Up @@ -102,9 +102,10 @@ public function testCompleteCommandName(array $input, array $suggestions)

public function provideCompleteCommandNameInputs()
{
yield 'empty' => [['bin/console'], ['help', 'list', 'completion', 'hello']];
yield 'partial' => [['bin/console', 'he'], ['help', 'list', 'completion', 'hello']];
yield 'complete-shortcut-name' => [['bin/console', 'hell'], ['hello']];
yield 'empty' => [['bin/console'], ['help', 'list', 'completion', 'hello', 'ahoy']];
yield 'partial' => [['bin/console', 'he'], ['help', 'list', 'completion', 'hello', 'ahoy']];
yield 'complete-shortcut-name' => [['bin/console', 'hell'], ['hello', 'ahoy']];
yield 'complete-aliases' => [['bin/console', 'ah'], ['hello', 'ahoy']];
}

/**
Expand All @@ -120,6 +121,8 @@ public function provideCompleteCommandInputDefinitionInputs()
{
yield 'definition' => [['bin/console', 'hello', '-'], ['--help', '--quiet', '--verbose', '--version', '--ansi', '--no-interaction']];
yield 'custom' => [['bin/console', 'hello'], ['Fabien', 'Robin', 'Wouter']];
yield 'definition-aliased' => [['bin/console', 'ahoy', '-'], ['--help', '--quiet', '--verbose', '--version', '--ansi', '--no-interaction']];
yield 'custom-aliased' => [['bin/console', 'ahoy'], ['Fabien', 'Robin', 'Wouter']];
}

private function execute(array $input)
Expand All @@ -134,6 +137,7 @@ class CompleteCommandTest_HelloCommand extends Command
public function configure(): void
{
$this->setName('hello')
->setAliases(['ahoy'])
->addArgument('name', InputArgument::REQUIRED)
;
}
Expand Down
24 changes: 22 additions & 2 deletions Tests/Helper/TableTest.php
Expand Up @@ -616,8 +616,8 @@ public function renderProvider()
'default',
<<<'TABLE'
+-------+------------+
[39;49m| [39;49m[37;41mDont break[39;49m[39;49m |[39;49m
[39;49m| [39;49m[37;41mhere[39;49m |
[37;41m| [39;49m[37;41mDont break[39;49m[37;41m |[39;49m
[37;41m| here[39;49m |
+-------+------------+
| foo | Dont break |
| bar | here |
Expand Down Expand Up @@ -1285,6 +1285,26 @@ public function renderSetTitle()
| 80-902734-1-6 | And Then There Were None | Agatha Christie |
+---------------+--------- Page 1/2 -------+------------------+
TABLE
,
true,
],
'header contains multiple lines' => [
'Multiline'."\n".'header'."\n".'here',
'footer',
'default',
<<<'TABLE'
+---------------+---- Multiline
header
here -+------------------+
| ISBN | Title | Author |
+---------------+--------------------------+------------------+
| 99921-58-10-7 | Divine Comedy | Dante Alighieri |
| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
| 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien |
| 80-902734-1-6 | And Then There Were None | Agatha Christie |
+---------------+---------- footer --------+------------------+
TABLE
],
[
Expand Down

0 comments on commit 47a6389

Please sign in to comment.