8000 minor #43628 [Console] Remove `CompletionInterface` (derrabus) · symfony/symfony@540ee0a · GitHub
[go: up one dir, main page]

Skip to content

Commit 540ee0a

Browse files
committed
minor #43628 [Console] Remove CompletionInterface (derrabus)
This PR was merged into the 5.4 branch. Discussion ---------- [Console] Remove `CompletionInterface` | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | #43620 (comment) | License | MIT | Doc PR | N/A Commits ------- cd49146 [Console] Remove CompletionInterface
2 parents ec34dd5 + cd49146 commit 540ee0a

File tree

11 files changed

+19
-52
lines changed

11 files changed

+19
-52
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/SecretsRemoveCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Bundle\FrameworkBundle\Secrets\AbstractVault;
1515
use Symfony\Component\Console\Command\Command;
1616
use Symfony\Component\Console\Completion\CompletionInput;
17-
use Symfony\Component\Console\Completion\CompletionInterface;
1817
use Symfony\Component\Console\Completion\CompletionSuggestions;
1918
use Symfony\Component\Console\Input\InputArgument;
2019
use Symfony\Component\Console\Input\InputInterface;
@@ -29,7 +28,7 @@
2928
*
3029
* @internal
3130
*/
32-
final class SecretsRemoveCommand extends Command implements CompletionInterface
31+
final class SecretsRemoveCommand extends Command
3332
{
3433
protected static $defaultName = 'secrets:remove';
3534
protected static $defaultDescription = 'Remove a secret from the vault';

src/Symfony/Component/Console/Application.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use Symfony\Component\Console\Command\SignalableCommandInterface;
2121
use Symfony\Component\Console\CommandLoader\CommandLoaderInterface;
2222
use Symfony\Component\Console\Completion\CompletionInput;
23-
use Symfony\Component\Console\Completion\CompletionInterface;
2423
use Symfony\Component\Console\Completion\CompletionSuggestions;
2524
use Symfony\Component\Console\Event\ConsoleCommandEvent;
2625
use Symfony\Component\Console\Event\ConsoleErrorEvent;
@@ -69,7 +68,7 @@
6968
*
7069
* @author Fabien Potencier <fabien@symfony.com>
7170
*/
72-
class Application implements ResetInterface, CompletionInterface
71+
class Application implements ResetInterface
7372
{
7473
private $commands = [];
7574
private $wantHelps = false;
@@ -356,7 +355,7 @@ public function getDefinition()
356355
}
357356

358357
/**
359-
* {@inheritdoc}
358+
* Adds suggestions to $suggestions for the current completion input (e.g. option or argument).
360359
*/
361360
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
362361
{

src/Symfony/Component/Console/Command/Command.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use Symfony\Component\Console\Application;
1515
use Symfony\Component\Console\Attribute\AsCommand;
16+
use Symfony\Component\Console\Completion\CompletionInput;
17+
use Symfony\Component\Console\Completion\CompletionSuggestions;
1618
use Symfony\Component\Console\Exception\ExceptionInterface;
1719
use Symfony\Component\Console\Exception\InvalidArgumentException;
1820
use Symfony\Component\Console\Exception\LogicException;
@@ -303,6 +305,13 @@ public function run(InputInterface $input, OutputInterface $output)
303305
return is_numeric($statusCode) ? (int) $statusCode : 0;
304306
}
305307

308+
/**
309+
* Adds suggestions to $suggestions for the current completion input (e.g. option or argument).
310+
*/
311+
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
312+
{
313+
}
314+
306315
/**
307316
* Sets the code to execute when running this command.
308317
*

src/Symfony/Component/Console/Command/CompleteCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Console\Command;
1313

1414
use Symfony\Component\Console\Completion\CompletionInput;
15-
use Symfony\Component\Console\Completion\CompletionInterface;
1615
use Symfony\Component\Console\Completion\CompletionSuggestions;
1716
use Symfony\Component\Console\Completion\Output\BashCompletionOutput;
1817
use Symfony\Component\Console\Exception\CommandNotFoundException;
@@ -107,7 +106,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
107106
$this->log(' Completing option names for the <comment>'.\get_class($command instanceof LazyCommand ? $command->getCommand() : $command).'</> command.');
108107

109108
$suggestions->suggestOptions($command->getDefinition()->getOptions());
110-
} elseif ($command instanceof CompletionInterface) {
109+
} else {
111110
$this->log([
112111
' Completing using the <comment>'.\get_class($command).'</> class.',
113112
' Completing <comment>'.$completionInput->getCompletionType().'</> for <comment>'.$completionInput->getCompletionName().'</>',

src/Symfony/Component/Console/Command/DumpCompletionCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Console\Command;
1313

1414
use Symfony\Component\Console\Completion\CompletionInput;
15-
use Symfony\Component\Console\Completion\CompletionInterface;
1615
use Symfony\Component\Console\Completion\CompletionSuggestions;
1716
use Symfony\Component\Console\Input\InputArgument;
1817
use Symfony\Component\Console\Input\InputInterface;
@@ -26,7 +25,7 @@
2625
*
2726
* @author Wouter de Jong <wouter@wouterj.nl>
2827
*/
29-
final class DumpCompletionCommand extends Command implements CompletionInterface
28+
final class DumpCompletionCommand extends Command
3029
{
3130
protected static $defaultName = 'completion';
3231
protected static $defaultDescription = 'Dump the shell completion script';

src/Symfony/Component/Console/Command/HelpCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Console\Command;
1313

1414
use Symfony\Component\Console\Completion\CompletionInput;
15-
use Symfony\Component\Console\Completion\CompletionInterface;
1615
use Symfony\Component\Console\Completion\CompletionSuggestions;
1716
use Symfony\Component\Console\Descriptor\ApplicationDescription;
1817
use Symfony\Component\Console\Helper\DescriptorHelper;
@@ -26,7 +25,7 @@
2625
*
2726
* @author Fabien Potencier <fabien@symfony.com>
2827
*/
29-
class HelpCommand extends Command implements CompletionInterface
28+
class HelpCommand extends Command
3029
{
3130
private $command;
3231

src/Symfony/Component/Console/Command/LazyCommand.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\Component\Console\Application;
1515
use Symfony\Component\Console\Completion\CompletionInput;
16-
use Symfony\Component\Console\Completion\CompletionInterface;
1716
use Symfony\Component\Console\Completion\CompletionSuggestions;
1817
use Symfony\Component\Console\Helper\HelperSet;
1918
use Symfony\Component\Console\Input\InputDefinition;
@@ -23,7 +22,7 @@
2322
/**
2423
* @author Nicolas Grekas <p@tchwork.com>
2524
*/
26-
final class LazyCommand extends Command implements CompletionInterface
25+
final class LazyCommand extends Command
2726
{
2827
private $command;
2928
private $isEnabled;
@@ -74,9 +73,7 @@ public function run(InputInterface $input, OutputInterface $output): int
7473

7574
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
7675
{
77-
if ($this->getCommand() instanceof CompletionInterface) {
78-
$this->getCommand()->complete($input, $suggestions);
79-
}
76+
$this->getCommand()->complete($input, $suggestions);
8077
}
8178

8279
/**

src/Symfony/Component/Console/Command/ListCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Console\Command;
1313

1414
use Symfony\Component\Console\Completion\CompletionInput;
15-
use Symfony\Component\Console\Completion\CompletionInterface;
1615
use Symfony\Component\Console\Completion\CompletionSuggestions;
1716
use Symfony\Component\Console\Descriptor\ApplicationDescription;
1817
use Symfony\Component\Console\Helper\DescriptorHelper;
@@ -26,7 +25,7 @@
2625
*
2726
* @author Fabien Potencier <fabien@symfony.com>
2827
*/
29-
class ListCommand extends Command implements CompletionInterface
28+
class ListCommand extends Command
3029
{
3130
/**
3231
* {@inheritdoc}

src/Symfony/Component/Console/Completion/CompletionInterface.php

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/Symfony/Component/Console/Tester/CommandCompletionTester.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\Component\Console\Command\Command;
1515
use Symfony\Component\Console\Completion\CompletionInput;
16-
use Symfony\Component\Console\Completion\CompletionInterface;
1716
use Symfony\Component\Console\Completion\CompletionSuggestions;
1817

1918
/**
@@ -35,10 +34,6 @@ public function __construct(Command $command)
3534
*/
3635
public function complete(array $input): array
3736
{
38-
if (!$this->command instanceof CompletionInterface) {
39-
throw new \LogicException(sprintf('Command "%s" must implement "%s" to support completion.', \get_class($this->command), CompletionInput::class));
40-
}
41-
4237
$currentIndex = \count($input);
4338
if ('' === end($input)) {
4439
array_pop($input);

src/Symfony/Component/Console/Tests/Command/CompleteCommandTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Symfony\Component\Console\Command\Command;
1717
use Symfony\Component\Console\Command\CompleteCommand;
1818
use Symfony\Component\Console\Completion\CompletionInput;
19-
use Symfony\Component\Console\Completion\CompletionInterface;
2019
use Symfony\Component\Console\Completion\CompletionSuggestions;
2120
use Symfony\Component\Console\Input\InputArgument;
2221
use Symfony\Component\Console\Output\OutputInterface;
@@ -115,7 +114,7 @@ private function execute(array $input)
115114
}
116115
}
117116

118-
class CompleteCommandTest_HelloCommand extends Command implements CompletionInterface
117+
class CompleteCommandTest_HelloCommand extends Command
119118
{
120119
public function configure(): void
121120
{

0 commit comments

Comments
 (0)
0