Skip to content

Commit 171965f

Browse files
[Console] Remove deprecations across the component
1 parent 4065c08 commit 171965f

File tree

68 files changed

+453
-2614
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+453
-2614
lines changed

.github/expected-missing-return-types.diff

Lines changed: 225 additions & 1775 deletions
Large diffs are not rendered by default.

UPGRADE-7.0.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ Symfony 6.4 and Symfony 7.0 will be released simultaneously at the end of Novemb
55
release process, both versions will have the same features, but Symfony 7.0 won't include any deprecated features.
66
To upgrade, make sure to resolve all deprecation notices.
77

8+
Console
9+
-------
10+
11+
* Remove `Command::$defaultName` and `Command::$defaultDescription`, use the `#[AsCommand]` attribute instead
12+
* Remove `StringInput::REGEX_STRING`
13+
* Passing null to `*Command::setApplication()`, `*FormatterStyle::setForeground/setBackground()`, `Helper::setHelpSet()`, `Input*::setDefault()` and `Question::setAutocompleterCallback/setValidator()` must be done explicitly
14+
815
DoctrineBridge
916
--------------
1017

src/Symfony/Bridge/Monolog/Command/ServerLogCommand.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ public function isEnabled(): bool
5050
return parent::isEnabled();
5151
}
5252

53-
/**
54-
* @return void
55-
*/
56-
protected function configure()
53+
protected function configure(): void
5754
{
5855
if (!class_exists(ConsoleFormatter::class)) {
5956
return;

src/Symfony/Bridge/Twig/Command/DebugCommand.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ public function __construct(Environment $twig, string $projectDir = null, array
5959
$this->fileLinkFormatter = $fileLinkFormatter;
6060
}
6161

62-
/**
63-
* @return void
64-
*/
65-
protected function configure()
62+
protected function configure(): void
6663
{
6764
$this
6865
->setDefinition([

src/Symfony/Bridge/Twig/Command/LintCommand.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ public function __construct(
4848
parent::__construct();
4949
}
5050

51-
/**
52-
* @return void
53-
*/
54-
protected function configure()
51+
protected function configure(): void
5552
{
5653
$this
5754
->addOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())))

src/Symfony/Bundle/FrameworkBundle/Console/Application.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ public function getKernel(): KernelInterface
5252
return $this->kernel;
5353
}
5454

55-
/**
56-
* @return void
57-
*/
58-
public function reset()
55+
public function reset(): void
5956
{
6057
if ($this->kernel->getContainer()->has('services_resetter')) {
6158
$this->kernel->getContainer()->get('services_resetter')->reset();
@@ -140,10 +137,7 @@ public function add(Command $command): ?Command
140137
return parent::add($command);
141138
}
142139

143-
/**
144-
* @return void
145-
*/
146-
protected function registerCommands()
140+
protected function registerCommands(): void
147141
{
148142
if ($this->commandsRegistered) {
149143
return;

src/Symfony/Component/Console/Application.php

Lines changed: 18 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,7 @@ public function setDispatcher(EventDispatcherInterface $dispatcher): void
110110
$this->dispatcher = $dispatcher;
111111
}
112112

113-
/**
114-
* @return void
115-
*/
116-
public function setCommandLoader(CommandLoaderInterface $commandLoader)
113+
public function setCommandLoader(CommandLoaderInterface $commandLoader): void
117114
{
118115
$this->commandLoader = $commandLoader;
119116
}
@@ -127,10 +124,7 @@ public function getSignalRegistry(): SignalRegistry
127124
return $this->signalRegistry;
128125
}
129126

130-
/**
131-
* @return void
132-
*/
133-
public function setSignalsToDispatchEvent(int ...$signalsToDispatchEvent)
127+
public function setSignalsToDispatchEvent(int ...$signalsToDispatchEvent): void
134128
{
135129
$this->signalsToDispatchEvent = $signalsToDispatchEvent;
136130
}
@@ -220,7 +214,7 @@ public function run(InputInterface $input = null, OutputInterface $output = null
220214
*
221215
* @return int 0 if everything went fine, or an error code
222216
*/
223-
public function doRun(InputInterface $input, OutputInterface $output)
217+
public function doRun(InputInterface $input, OutputInterface $output): int
224218
{
225219
if (true === $input->hasParameterOption(['--version', '-V'], true)) {
226220
$output->writeln($this->getLongVersion());
@@ -323,17 +317,11 @@ public function doRun(InputInterface $input, OutputInterface $output)
323317
return $exitCode;
324318
}
325319

326-
/**
327-
* @return void
328-
*/
329-
public function reset()
320+
public function reset(): void
330321
{
331322
}
332323

333-
/**
334-
* @return void
335-
*/
336-
public function setHelperSet(HelperSet $helperSet)
324+
public function setHelperSet(HelperSet $helperSet): void
337325
{
338326
$this->helperSet = $helperSet;
339327
}
@@ -346,10 +334,7 @@ public function getHelperSet(): HelperSet
346334
return $this->helperSet ??= $this->getDefaultHelperSet();
347335
}
348336

349-
/**
350-
* @return void
351-
*/
352-
public function setDefinition(InputDefinition $definition)
337+
public function setDefinition(InputDefinition $definition): void
353338
{
354339
$this->definition = $definition;
355340
}
@@ -419,10 +404,8 @@ public function areExceptionsCaught(): bool
419404

420405
/**
421406
* Sets whether to catch exceptions or not during commands execution.
422-
*
423-
* @return void
424407
*/
425-
public function setCatchExceptions(bool $boolean)
408+
public function setCatchExceptions(bool $boolean): void
426409
{
427410
$this->catchExceptions = $boolean;
428411
}
@@ -437,10 +420,8 @@ public function isAutoExitEnabled(): bool
437420

438421
/**
439422
* Sets whether to automatically exit after a command execution or not.
440-
*
441-
* @return void
442423
*/
443-
public function setAutoExit(bool $boolean)
424+
public function setAutoExit(bool $boolean): void
444425
{
445426
$this->autoExit = $boolean;
446427
}
@@ -455,10 +436,8 @@ public function getName(): string
455436

456437
/**
457438
* Sets the application name.
458-
*
459-
* @return void
460439
*/
461-
public function setName(string $name)
440+
public function setName(string $name): void
462441
{
463442
$this->name = $name;
464443
}
@@ -473,20 +452,16 @@ public function getVersion(): string
473452

474453
/**
475454
* Sets the application version.
476-
*
477-
* @return void
478455
*/
479-
public function setVersion(string $version)
456+
public function setVersion(string $version): void
480457
{
481458
$this->version = $version;
482459
}
483460

484461
/**
485462
* Returns the long version of the application.
486-
*
487-
* @return string
488463
*/
489-
public function getLongVersion()
464+
public function getLongVersion(): string
490465
{
491466
if ('UNKNOWN' !== $this->getName()) {
492467
if ('UNKNOWN' !== $this->getVersion()) {
@@ -513,10 +488,8 @@ public function register(string $name): Command
513488
* If a Command is not enabled it will not be added.
514489
*
515490
* @param Command[] $commands An array of commands
516-
*
517-
* @return void
518491
*/
519-
public function addCommands(array $commands)
492+
public function addCommands(array $commands): void
520493
{
521494
foreach ($commands as $command) {
522495
$this->add($command);
@@ -528,10 +501,8 @@ public function addCommands(array $commands)
528501
*
529502
* If a command with the same name already exists, it will be overridden.
530503
* If the command is not enabled it will not be added.
531-
*
532-
* @return Command|null
533504
*/
534-
public function add(Command $command)
505+
public function add(Command $command): ?Command
535506
{
536507
$this->init();
537508

@@ -564,11 +535,9 @@ public function add(Command $command)
564535
/**
565536
* Returns a registered command by name or alias.
566537
*
567-
* @return Command
568-
*
569538
* @throws CommandNotFoundException When given command name does not exist
570539
*/
571-
public function get(string $name)
540+
public function get(string $name): Command
572541
{
573542
$this->init();
574543

@@ -671,11 +640,9 @@ public function findNamespace(string $namespace): string
671640
* Contrary to get, this command tries to find the best
672641
* match if you give it an abbreviation of a name or alias.
673642
*
674-
* @return Command
675-
*
676643
* @throws CommandNotFoundException When command name is incorrect or ambiguous
677644
*/
678-
public function find(string $name)
645+
public function find(string $name): Command
679646
{
680647
$this->init();
681648

@@ -783,7 +750,7 @@ public function find(string $name)
783750
*
784751
* @return Command[]
785752
*/
786-
public function all(string $namespace = null)
753+
public function all(string $namespace = null): array
787754
{
788755
$this->init();
789756

@@ -924,10 +891,8 @@ protected function doRenderThrowable(\Throwable $e, OutputInterface $output): vo
924891

925892
/**
926893
* Configures the input and output instances based on the user arguments and options.
927-
*
928-
* @return void
929894
*/
930-
protected function configureIO(InputInterface $input, OutputInterface $output)
895+
protected function configureIO(InputInterface $input, OutputInterface $output): void
931896
{
932897
if (true === $input->hasParameterOption(['--ansi'], true)) {
933898
$output->setDecorated(true);
@@ -992,7 +957,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
992957
*
993958
* @return int 0 if everything went fine, or an error code
994959
*/
995-
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
960+
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output): int
996961
{
997962
foreach ($command->getHelperSet() as $helper) {
998963
if ($helper instanceof InputAwareInterface) {
@@ -1026,11 +991,6 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
1026991
// If the command is signalable, we call the handleSignal() method
1027992
if (\in_array($signal, $commandSignals, true)) {
1028993
$exitCode = $command->handleSignal($signal, $exitCode);
1029-
// BC layer for Symfony <= 5
1030-
if (null === $exitCode) {
1031-
trigger_deprecation('symfony/console', '6.3', 'Not returning an exit code from "%s::handleSignal()" is deprecated, return "false" to keep the command running or "0" to exit successfully.', get_debug_type($command));
1032-
$exitCode = 0;
1033-
}
1034994
}
1035995

1036996
if (false !== $exitCode) {
@@ -1046,11 +1006,6 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
10461006
foreach ($commandSignals as $signal) {
10471007
$this->signalRegistry->register($signal, function (int $signal) use ($command): void {
10481008
$exitCode = $command->handleSignal($signal);
1049-
// BC layer for Symfony <= 5
1050-
if (null === $exitCode) {
1051-
trigger_deprecation('symfony/console', '6.3', 'Not returning an exit code from "%s::handleSignal()" is deprecated, return "false" to keep the command running or "0" to exit successfully.', get_debug_type($command));
1052-
$exitCode = 0;
1053-
}
10541009

10551010
if (false !== $exitCode) {
10561011
exit($exitCode);

src/Symfony/Component/Console/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
CHANGELOG
22
=========
33

4+
7.0
5+
---
6+
7+
* Remove `Command::$defaultName` and `Command::$defaultDescription`, use the `AsCommand` attribute instead
8+
* Remove `StringInput::REGEX_STRING`
9+
* Passing null to `*Command::setApplication()`, `*FormatterStyle::setForeground/setBackground()`, `Helper::setHelpSet()`, `Input*::setDefault()` and `Question::setAutocompleterCallback/setValidator()` must be done explicitly
10+
411
6.3
512
---
613

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy