Skip to content

Commit 47a6389

Browse files
Merge branch '5.4' into 6.0
* 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
2 parents 042e410 + 1894919 commit 47a6389

File tree

5 files changed

+44
-10
lines changed

5 files changed

+44
-10
lines changed

Application.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,18 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti
353353
CompletionInput::TYPE_ARGUMENT_VALUE === $input->getCompletionType()
354354
&& 'command' === $input->getCompletionName()
355355
) {
356-
$suggestions->suggestValues(array_filter(array_map(function (Command $command) {
357-
return $command->isHidden() ? null : $command->getName();
358-
}, $this->all())));
356+
$commandNames = [];
357+
foreach ($this->all() as $name => $command) {
358+
// skip hidden commands and aliased commands as they already get added below
359+
if ($command->isHidden() || $command->getName() !== $name) {
360+
continue;
361+
}
362+
$commandNames[] = $command->getName();
363+
foreach ($command->getAliases() as $name) {
364+
$commandNames[] = $name;
365+
}
366+
}
367+
$suggestions->suggestValues(array_filter($commandNames));
359368

360369
return;
361370
}

Command/CompleteCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
105105
} elseif (
106106
$completionInput->mustSuggestArgumentValuesFor('command')
107107
&& $command->getName() !== $completionInput->getCompletionValue()
108+
&& !\in_array($completionInput->getCompletionValue(), $command->getAliases(), true)
108109
) {
109110
$this->log(' No command found, completing using the Application class.');
110111

111112
// expand shortcut names ("cache:cl<TAB>") into their full name ("cache:clear")
112-
$suggestions->suggestValue($command->getName());
113+
$suggestions->suggestValues(array_filter(array_merge([$command->getName()], $command->getAliases())));
113114
} else {
114115
$command->mergeApplicationDefinition();
115116
$completionInput->bind($command->getDefinition());

Helper/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ private function buildTableRows(array $rows): TableRows
561561
}
562562
$escaped = implode("\n", array_map([OutputFormatter::class, 'escapeTrailingBackslash'], explode("\n", $cell)));
563563
$cell = $cell instanceof TableCell ? new TableCell($escaped, ['colspan' => $cell->getColspan()]) : $escaped;
564-
$lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
564+
$lines = explode("\n", str_replace("\n", "<fg=default;bg=default></>\n", $cell));
565565
foreach ($lines as $lineKey => $line) {
566566
if ($colspan > 1) {
567567
$line = new TableCell($line, ['colspan' => $colspan]);

Tests/Command/CompleteCommandTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ public function testCompleteCommandName(array $input, array $suggestions)
102102

103103
public function provideCompleteCommandNameInputs()
104104
{
105-
yield 'empty' => [['bin/console'], ['help', 'list', 'completion', 'hello']];
106-
yield 'partial' => [['bin/console', 'he'], ['help', 'list', 'completion', 'hello']];
107-
yield 'complete-shortcut-name' => [['bin/console', 'hell'], ['hello']];
105+
yield 'empty' => [['bin/console'], ['help', 'list', 'completion', 'hello', 'ahoy']];
106+
yield 'partial' => [['bin/console', 'he'], ['help', 'list', 'completion', 'hello', 'ahoy']];
107+
yield 'complete-shortcut-name' => [['bin/console', 'hell'], ['hello', 'ahoy']];
108+
yield 'complete-aliases' => [['bin/console', 'ah'], ['hello', 'ahoy']];
108109
}
109110

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

125128
private function execute(array $input)
@@ -134,6 +137,7 @@ class CompleteCommandTest_HelloCommand extends Command
134137
public function configure(): void
135138
{
136139
$this->setName('hello')
140+
->setAliases(['ahoy'])
137141
->addArgument('name', InputArgument::REQUIRED)
138142
;
139143
}

Tests/Helper/TableTest.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,8 @@ public function renderProvider()
616616
'default',
617617
<<<'TABLE'
618618
+-------+------------+
619-
[39;49m| [39;49m[37;41mDont break[39;49m[39;49m |[39;49m
620-
[39;49m| [39;49m[37;41mhere[39;49m |
619+
[37;41m| [39;49m[37;41mDont break[39;49m[37;41m |[39;49m
620+
[37;41m| here[39;49m |
621621
+-------+------------+
622622
| foo | Dont break |
623623
| bar | here |
@@ -1285,6 +1285,26 @@ public function renderSetTitle()
12851285
| 80-902734-1-6 | And Then There Were None | Agatha Christie |
12861286
+---------------+--------- Page 1/2 -------+------------------+
12871287

1288+
TABLE
1289+
,
1290+
true,
1291+
],
1292+
'header contains multiple lines' => [
1293+
'Multiline'."\n".'header'."\n".'here',
1294+
'footer',
1295+
'default',
1296+
<<<'TABLE'
1297+
+---------------+---- Multiline
1298+
header
1299+
here -+------------------+
1300+
| ISBN | Title | Author |
1301+
+---------------+--------------------------+------------------+
1302+
| 99921-58-10-7 | Divine Comedy | Dante Alighieri |
1303+
| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
1304+
| 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien |
1305+
| 80-902734-1-6 | And Then There Were None | Agatha Christie |
1306+
+---------------+---------- footer --------+------------------+
1307+
12881308
TABLE
12891309
],
12901310
[

0 commit comments

Comments
 (0)