Skip to content

Commit c27250e

Browse files
Merge branch '5.4' into 6.0
* 5.4: [Cache] fix connecting to local Redis sockets Fix appveyor config for deprecations Skip deprecation coming from DBAL 3.2 Add Suggestion class for more advanced completion suggestion [HttpClient] Add Klaxoon as a backer to the README [Translation] Add Lokalise as a backer to the READMEs [Translation] Add Crowdin as a backer to the READMEs [Security] Add SymfonyCasts as a backer to the READMEs [Notifier] Add Mercure.rocks as a backer to the README [Messenger][Process] Add SensioLabs as a backer to the README [HttpKernel][Console] Add Les-Tilleuls.coop as a backer to the README [HttpFoundation] Add Laravel as a backer to the README Allow v3 contracts where possible
2 parents 0c15d5f + f797eed commit c27250e

File tree

6 files changed

+66
-11
lines changed

6 files changed

+66
-11
lines changed

Completion/CompletionSuggestions.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* @author Wouter de Jong <[email protected]>
2020
*/
21-
class CompletionSuggestions
21+
final class CompletionSuggestions
2222
{
2323
private $valueSuggestions = [];
2424
private $optionSuggestions = [];
@@ -28,23 +28,25 @@ class CompletionSuggestions
2828
*
2929
* @return $this
3030
*/
31-
public function suggestValue(string $value): static
31+
public function suggestValue(string|Suggestion $value): static
3232
{
33-
$this->valueSuggestions[] = $value;
33+
$this->valueSuggestions[] = !$value instanceof Suggestion ? new Suggestion($value) : $value;
3434

3535
return $this;
3636
}
3737

3838
/**
3939
* Add multiple suggested values at once for an input option or argument.
4040
*
41-
* @param string[] $values
41+
* @param list<string|Suggestion> $values
4242
*
4343
* @return $this
4444
*/
4545
public function suggestValues(array $values): static
4646
{
47-
$this->valueSuggestions = array_merge($this->valueSuggestions, $values);
47+
foreach ($values as $value) {
48+
$this->suggestValue($value);
49+
}
4850

4951
return $this;
5052
}
@@ -86,7 +88,7 @@ public function getOptionSuggestions(): array
8688
}
8789

8890
/**
89-
* @return string[]
91+
* @return Suggestion[]
9092
*/
9193
public function getValueSuggestions(): array
9294
{

Completion/Output/BashCompletionOutput.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ class BashCompletionOutput implements CompletionOutputInterface
2121
{
2222
public function write(CompletionSuggestions $suggestions, OutputInterface $output): void
2323
{
24-
$options = $suggestions->getValueSuggestions();
24+
$values = $suggestions->getValueSuggestions();
2525
foreach ($suggestions->getOptionSuggestions() as $option) {
26-
$options[] = '--'.$option->getName();
26+
$values[] = '--'.$option->getName();
2727
}
28-
$output->writeln(implode("\n", $options));
28+
$output->writeln(implode("\n", $values));
2929
}
3030
}

Completion/Suggestion.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Console\Completion;
13+
14+
/**
15+
* Represents a single suggested value.
16+
*
17+
* @author Wouter de Jong <[email protected]>
18+
*/
19+
class Suggestion
20+
{
21+
private string $value;
22+
23+
public function __construct(string $value)
24+
{
25+
$this->value = $value;
26+
}
27+
28+
public function getValue(): string
29+
{
30+
return $this->value;
31+
}
32+
33+
public function __toString(): string
34+
{
35+
return $this->getValue();
36+
}
37+
}

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ Console Component
44
The Console component eases the creation of beautiful and testable command line
55
interfaces.
66

7+
Sponsor
8+
-------
9+
10+
The Console component for Symfony 5.4/6.0 is [backed][1] by [Les-Tilleuls.coop][2].
11+
12+
Les-Tilleuls.coop is a team of 50+ Symfony experts who can help you design, develop and
13+
fix your projects. We provide a wide range of professional services including development,
14+
consulting, coaching, training and audits. We also are highly skilled in JS, Go and DevOps.
15+
We are a worker cooperative!
16+
17+
Help Symfony by [sponsoring][3] its development!
18+
719
Resources
820
---------
921

@@ -18,3 +30,7 @@ Credits
1830

1931
`Resources/bin/hiddeninput.exe` is a third party binary provided within this
2032
component. Find sources and license at https://github.com/Seldaek/hidden-input.
33+
34+
[1]: https://symfony.com/backers
35+
[2]: https://les-tilleuls.coop
36+
[3]: https://symfony.com/sponsor

Tester/CommandCompletionTester.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ public function complete(array $input): array
5151
$options[] = '--'.$option->getName();
5252
}
5353

54-
return array_merge($options, $suggestions->getValueSuggestions());
54+
return array_map('strval', array_merge($options, $suggestions->getValueSuggestions()));
5555
}
5656
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=8.0.2",
2020
"symfony/polyfill-mbstring": "~1.0",
21-
"symfony/service-contracts": "^1.1|^2.0|^3.0",
21+
"symfony/service-contracts": "^1.1|^2|^3",
2222
"symfony/string": "^5.4|^6.0"
2323
},
2424
"require-dev": {

0 commit comments

Comments
 (0)