8000 [Console] Remove deprecations across the component · symfony/symfony@7e81c91 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7e81c91

Browse files
alexandre-dauboisnicolas-grekas
authored andcommitted
[Console] Remove deprecations across the component
1 parent 0132503 commit 7e81c91

19 files changed

+83
-244
lines changed

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

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,7 +2210,7 @@ index cc024da461..00b79e915f 100644
22102210
{
22112211
$errors = [];
22122212
diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php
2213-
index b7aaa6a29e..dd14cf2c5c 100644
2213+
index f8526ae5ce..72da224185 100644
22142214
--- a/src/Symfony/Component/Console/Application.php
22152215
+++ b/src/Symfony/Component/Console/Application.php
22162216
@@ -114,5 +114,5 @@ class Application implements ResetInterface
@@ -2340,66 +2340,66 @@ index b7aaa6a29e..dd14cf2c5c 100644
23402340
{
23412341
foreach ($command->getHelperSet() as $helper) {
23422342
diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php
2343-
index 704b112d1a..b296bffcbd 100644
2343+
index fae37b686a..5bc670292d 100644
23442344
--- a/src/Symfony/Component/Console/Command/Command.php
23452345
+++ b/src/Symfony/Component/Console/Command/Command.php
2346-
@@ -145,5 +145,5 @@ class Command
2346+
@@ -111,5 +111,5 @@ class Command
23472347
* @return void
23482348
*/
23492349
- public function ignoreValidationErrors()
23502350
+ public function ignoreValidationErrors(): void
23512351
{
23522352
$this->ignoreValidationErrors = true;
2353-
@@ -153,5 +153,5 @@ class Command
2353+
@@ -119,5 +119,5 @@ class Command
23542354
* @return void
23552355
*/
2356-
- public function setApplication(Application $application = null)
2357-
+ public function setApplication(Application $application = null): void
2356+
- public function setApplication(?Application $application)
2357+
+ public function setApplication(?Application $application): void
23582358
{
2359-
if (1 > \func_num_args()) {
2360-
@@ -171,5 +171,5 @@ class Command
2359+
$this->application = $application;
2360+
@@ -134,5 +134,5 @@ class Command
23612361
* @return void
23622362
*/
23632363
- public function setHelperSet(HelperSet $helperSet)
23642364
+ public function setHelperSet(HelperSet $helperSet): void
23652365
{
23662366
$this->helperSet = $helperSet;
2367-
@@ -200,5 +200,5 @@ class Command
2367+
@@ -163,5 +163,5 @@ class Command
23682368
* @return bool
23692369
*/
23702370
- public function isEnabled()
23712371
+ public function isEnabled(): bool
23722372
{
23732373
return true;
2374-
@@ -210,5 +210,5 @@ class Command
2374+
@@ -173,5 +173,5 @@ class Command
23752375
* @return void
23762376
*/
23772377
- protected function configure()
23782378
+ protected function configure(): void
23792379
{
23802380
}
2381-
@@ -228,5 +228,5 @@ class Command
2381+
@@ -191,5 +191,5 @@ class Command
23822382
* @see setCode()
23832383
*/
23842384
- protected function execute(InputInterface $input, OutputInterface $output)
23852385
+ protected function execute(InputInterface $input, OutputInterface $output): int
23862386
{
23872387
throw new LogicException('You must override the execute() method in the concrete command class.');
2388-
@@ -242,5 +242,5 @@ class Command
2388+
@@ -205,5 +205,5 @@ class Command
23892389
* @return void
23902390
*/
23912391
- protected function interact(InputInterface $input, OutputInterface $output)
23922392
+ protected function interact(InputInterface $input, OutputInterface $output): void
23932393
{
23942394
}
2395-
@@ -258,5 +258,5 @@ class Command
2395+
@@ -221,5 +221,5 @@ class Command
23962396
* @return void
23972397
*/
23982398
- protected function initialize(InputInterface $input, OutputInterface $output)
23992399
+ protected function initialize(InputInterface $input, OutputInterface $output): void
24002400
{
24012401
}
2402-
@@ -701,5 +701,5 @@ class Command
2402+
@@ -656,5 +656,5 @@ class Command
24032403
* @throws InvalidArgumentException if the helper is not defined
24042404
*/
24052405
- public function getHelper(string $name): mixed
@@ -2436,14 +2436,14 @@ index 5850c3d7b8..e2371f88fd 100644
24362436
{
24372437
$this
24382438
diff --git a/src/Symfony/Component/Console/Command/SignalableCommandInterface.php b/src/Symfony/Component/Console/Command/SignalableCommandInterface.php
2439-
index 4d0876003d..d33732acb6 100644
2439+
index 7ebffede11..40b301d18f 100644
24402440
--- a/src/Symfony/Component/Console/Command/SignalableCommandInterface.php
24412441
+++ b/src/Symfony/Component/Console/Command/SignalableCommandInterface.php
2442-
@@ -31,4 +31,4 @@ interface SignalableCommandInterface
2442+
@@ -29,4 +29,4 @@ interface SignalableCommandInterface
24432443
* @return int|false The exit code to return or false to continue the normal execution
24442444
*/
2445-
- public function handleSignal(int $signal, /* int|false $previousExitCode = 0 */);
2446-
+ public function handleSignal(int $signal, /* int|false $previousExitCode = 0 */): int|false;
2445+
- public function handleSignal(int $signal, int|false $previousExitCode = 0);
2446+
+ public function handleSignal(int $signal, int|false $previousExitCode = 0): int|false;
24472447
}
24482448
diff --git a/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php b/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php
24492449
index 27705ddb63..1b25473f75 100644
@@ -2528,38 +2528,38 @@ index 433cd41978..02187a7ffc 100644
25282528

25292529
/**
25302530
diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php b/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php
2531-
index 346a474c61..db3012ced8 100644
2531+
index f075e881d8..b93a539df1 100644
25322532
--- a/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php
25332533
+++ b/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php
25342534
@@ -42,5 +42,5 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
25352535
* @return void
25362536
*/
2537-
- public function setForeground(string $color = null)
2538-
+ public function setForeground(string $color = null): void
2537+
- public function setForeground(?string $color)
2538+
+ public function setForeground(?string $color): void
25392539
{
2540-
if (1 > \func_num_args()) {
2541-
@@ -53,5 +53,5 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
2540+
$this->color = new Color($this->foreground = $color ?: '', $this->background, $this->options);
2541+
@@ -50,5 +50,5 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
25422542
* @return void
25432543
*/
2544-
- public function setBackground(string $color = null)
2545-
+ public function setBackground(string $color = null): void
2544+
- public function setBackground(?string $color)
2545+
+ public function setBackground(?string $color): void
25462546
{
2547-
if (1 > \func_num_args()) {
2548-
@@ -69,5 +69,5 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
2547+
$this->color = new Color($this->foreground, $this->background = $color ?: '', $this->options);
2548+
@@ -63,5 +63,5 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
25492549
* @return void
25502550
*/
25512551
- public function setOption(string $option)
25522552
+ public function setOption(string $option): void
25532553
{
25542554
$this->options[] = $option;
2555-
@@ -78,5 +78,5 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
2555+
@@ -72,5 +72,5 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
25562556
* @return void
25572557
*/
25582558
- public function unsetOption(string $option)
25592559
+ public function unsetOption(string $option): void
25602560
{
25612561
$pos = array_search($option, $this->options);
2562-
@@ -91,5 +91,5 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
2562+
@@ -85,5 +85,5 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
25632563
* @return void
25642564
*/
25652565
- public function setOptions(array $options)
@@ -2645,31 +2645,31 @@ index eb32bce8fc..57edd56954 100644
26452645
{
26462646
$options = array_merge([
26472647
diff --git a/src/Symfony/Component/Console/Helper/Helper.php b/src/Symfony/Component/Console/Helper/Helper.php
2648-
index 3631b30f69..5e4407a591 100644
2648+
index c80c1f468f..9578a074bb 100644
26492649
--- a/src/Symfony/Component/Console/Helper/Helper.php
26502650
+++ b/src/Symfony/Component/Console/Helper/Helper.php
26512651
@@ -27,5 +27,5 @@ abstract class Helper implements HelperInterface
26522652
* @return void
26532653
*/
2654-
- public function setHelperSet(HelperSet $helperSet = null)
2655-
+ public function setHelperSet(HelperSet $helperSet = null): void
2654+
- public function setHelperSet(?HelperSet $helperSet)
2655+
+ public function setHelperSet(?HelperSet $helperSet): void
26562656
{
2657-
if (1 > \func_num_args()) {
2658-
@@ -95,5 +95,5 @@ abstract class Helper implements HelperInterface
2657+
$this->helperSet = $helperSet;
2658+
@@ -92,5 +92,5 @@ abstract class Helper implements HelperInterface
26592659
* @return string
26602660
*/
26612661
- public static function formatTime(int|float $secs)
26622662
+ public static function formatTime(int|float $secs): string
26632663
{
26642664
static $timeFormats = [
2665-
@@ -127,5 +127,5 @@ abstract class Helper implements HelperInterface
2665+
@@ -124,5 +124,5 @@ abstract class Helper implements HelperInterface
26662666
* @return string
26672667
*/
26682668
- public static function formatMemory(int $memory)
26692669
+ public static function formatMemory(int $memory): string
26702670
{
26712671
if ($memory >= 1024 * 1024 * 1024) {
2672-
@@ -147,5 +147,5 @@ abstract class Helper implements HelperInterface
2672+
@@ -144,5 +144,5 @@ abstract class Helper implements HelperInterface
26732673
* @return string
26742674
*/
26752675
- public static function removeDecoration(OutputFormatterInterface $formatter, ?string $string)
@@ -2904,16 +2904,16 @@ index 0f5617cd17..bdd5dd264f 100644
29042904
{
29052905
$this->stream = $stream;
29062906
diff --git a/src/Symfony/Component/Console/Input/InputArgument.php b/src/Symfony/Component/Console/Input/InputArgument.php
2907-
index 5cb151488d..2dc276a372 100644
2907+
index fa57f5d0d4..e657b56ad7 100644
29082908
--- a/src/Symfony/Component/Console/Input/InputArgument.php
29092909
+++ b/src/Symfony/Component/Console/Input/InputArgument.php
29102910
@@ -96,5 +96,5 @@ class InputArgument
29112911
* @throws LogicException When incorrect default value is given
29122912
*/
2913-
- public function setDefault(string|bool|int|float|array $default = null)
2914-
+ public function setDefault(string|bool|int|float|array $default = null): void
2913+
- public function setDefault(string|bool|int|float|array|null $default)
2914+
+ public function setDefault(string|bool|int|float|array|null $default): void
29152915
{
2916-
if (1 > \func_num_args()) {
2916+
if ($this->isRequired() && null !== $default) {
29172917
diff --git a/src/Symfony/Component/Console/Input/InputAwareInterface.php b/src/Symfony/Component/Console/Input/InputAwareInterface.php
29182918
index 0ad27b4558..f5e544930e 100644
29192919
--- a/src/Symfony/Component/Console/Input/InputAwareInterface.php
@@ -3037,16 +3037,16 @@ index aaed5fd01d..e7de9bcdec 100644
30373037
+ public function setInteractive(bool $interactive): void;
30383038
}
30393039
diff --git a/src/Symfony/Component/Console/Input/InputOption.php b/src/Symfony/Component/Console/Input/InputOption.php
3040-
index fdf88dcc27..cf7a71a3c4 100644
3040+
index c9e8aa82b6..ee7c119cd2 100644
30413041
--- a/src/Symfony/Component/Console/Input/InputOption.php
30423042
+++ b/src/Symfony/Component/Console/Input/InputOption.php
30433043
@@ -182,5 +182,5 @@ class InputOption
30443044
* @return void
30453045
*/
3046-
- public function setDefault(string|bool|int|float|array $default = null)
3047-
+ public function setDefault(string|bool|int|float|array $default = null): void
3046+
- public function setDefault(string|bool|int|float|array|null $default)
3047+
+ public function setDefault(string|bool|int|float|array|null $default): void
30483048
{
3049-
if (1 > \func_num_args()) {
3049+
if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
30503050
diff --git a/src/Symfony/Component/Console/Input/StreamableInputInterface.php b/src/Symfony/Component/Console/Input/StreamableInputInterface.php
30513051
index 4b95fcb11e..b95fab2601 100644
30523052
--- a/src/Symfony/Component/Console/Input/StreamableInputInterface.php
@@ -3283,10 +3283,10 @@ index b00445ece8..5e9b1086b0 100644
32833283
{
32843284
$this->buffer .= $message;
32853285
diff --git a/src/Symfony/Component/Console/Question/Question.php b/src/Symfony/Component/Console/Question/Question.php
3286-
index 26896bb531..af97d04ddc 100644
3286+
index dec0954e79..873b302873 100644
32873287
--- a/src/Symfony/Component/Console/Question/Question.php
32883288
+++ b/src/Symfony/Component/Console/Question/Question.php
3289-
@@ -270,5 +270,5 @@ class Question
3289+
@@ -264,5 +264,5 @@ class Question
32903290
* @return bool
32913291
*/
32923292
- protected function isAssoc(array $array)
@@ -4684,7 +4684,7 @@ index c1cd9087f0..a9efa77a6d 100644
46844684
{
46854685
return $this->resolved;
46864686
diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php
4687-
index 51a662afc2..19e1f18d29 100644
4687+
index 8c76fe7a8e..b255b0e8ef 100644
46884688
--- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php
46894689
+++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php
46904690
@@ -29,5 +29,5 @@ interface ParameterBagInterface

UPGRADE-7.0.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ Cache
1010

1111
* Add parameter `$isSameDatabase` to `DoctrineDbalAdapter::configureSchema()`
1212

13+
Console
14+
-------
15+
16+
* Remove `Command::$defaultName` and `Command::$defaultDescription`, use the `AsCommand` attribute instead
17+
* Passing null to `*Command::setApplication()`, `*FormatterStyle::setForeground/setBackground()`, `Helper::setHelpSet()`, `Input*::setDefault()` and `Question::setAutocompleterCallback/setValidator()` must be done explicitly
18+
* Remove `StringInput::REGEX_STRING`
19+
1320
DoctrineBridge
1421
--------------
1522

src/Symfony/Component/Console/Application.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,11 +1026,6 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
10261026
// If the command is signalable, we call the handleSignal() method
10271027
if (\in_array($signal, $commandSignals, true)) {
10281028
$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-
}
10341029
}
10351030

10361031
if (false !== $exitCode) {
@@ -1045,14 +1040,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
10451040

10461041
foreach ($commandSignals as $signal) {
10471042
$this->signalRegistry->register($signal, function (int $signal) use ($command): void {
1048-
$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-
}
1054-
1055-
if (false !== $exitCode) {
1043+
if (false !== $exitCode = $command->handleSignal($signal)) {
10561044
exit($exitCode);
10571045
}
10581046
});

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+
* Passing null to `*Command::setApplication()`, `*FormatterStyle::setForeground/setBackground()`, `Helper::setHelpSet()`, `Input*::setDefault()` and `Question::setAutocompleterCallback/setValidator()` must be done explicitly
9+
* Remove `StringInput::REGEX_STRING`
10+
411
6.4
512
---
613

0 commit comments

Comments
 (0)
0