Skip to content

Commit c2111be

Browse files
feature #33775 [Console] Add deprecation message for non-int statusCode (jschaedl)
This PR was merged into the 4.4 branch. Discussion ---------- [Console] Add deprecation message for non-int statusCode | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | yes <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #33747 <!-- prefix each issue number with "Fix #", if any --> | License | MIT | Doc PR | - ### What was done: - [x] added deprecation message for non-int return value in Command::execute() - [x] fixed all core commands to return proper int values - [x] added proper return type-hint to Command::execute() method in all core Commands Commits ------- 98c4f6a [Console] Command::execute() should always return int - deprecate returning null
2 parents 3354bac + 98c4f6a commit c2111be

Some content is hidden

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

50 files changed

+128
-54
lines changed

UPGRADE-4.4.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Console
1010
-------
1111

1212
* Deprecated finding hidden commands using an abbreviation, use the full name instead
13+
* Deprecated returning `null` from `Command::execute()`, return `0` instead
1314

1415
Debug
1516
-----

UPGRADE-5.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Console
3737
* Removed the `getHorizontalBorderChar()` method in favor of the `getBorderChars()` method in `TableStyle`.
3838
* Removed the `setVerticalBorderChar()` method in favor of the `setVerticalBorderChars()` method in `TableStyle`.
3939
* Removed the `getVerticalBorderChar()` method in favor of the `getBorderChars()` method in `TableStyle`.
40+
* Removed support for returning `null` from `Command::execute()`, return `0` instead
4041
* The `ProcessHelper::run()` method takes the command as an array of arguments.
4142

4243
Before:

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
111111

112112
switch ($input->getOption('format')) {
113113
case 'text':
114-
return $name ? $this->displayPathsText($io, $name) : $this->displayGeneralText($io, $filter);
114+
$name ? $this->displayPathsText($io, $name) : $this->displayGeneralText($io, $filter);
115+
break;
115116
case 'json':
116-
return $name ? $this->displayPathsJson($io, $name) : $this->displayGeneralJson($io, $filter);
117+
$name ? $this->displayPathsJson($io, $name) : $this->displayGeneralJson($io, $filter);
118+
break;
117119
default:
118120
throw new InvalidArgumentException(sprintf('The format "%s" is not supported.', $input->getOption('format')));
119121
}
122+
123+
return 0;
120124
}
121125

122126
private function displayPathsText(SymfonyStyle $io, string $name)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected function configure()
5454
/**
5555
* {@inheritdoc}
5656
*/
57-
protected function execute(InputInterface $input, OutputInterface $output)
57+
protected function execute(InputInterface $input, OutputInterface $output): int
5858
{
5959
$io = new SymfonyStyle($input, $output);
6060

@@ -100,6 +100,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
100100
}
101101

102102
$io->table([], $rows);
103+
104+
return 0;
103105
}
104106

105107
private static function formatPath(string $path, string $baseDir): string

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function configure()
7272
/**
7373
* {@inheritdoc}
7474
*/
75-
protected function execute(InputInterface $input, OutputInterface $output)
75+
protected function execute(InputInterface $input, OutputInterface $output): int
7676
{
7777
$fs = $this->filesystem;
7878
$io = new SymfonyStyle($input, $output);
@@ -175,6 +175,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
175175
}
176176

177177
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
178+
179+
return 0;
178180
}
179181

180182
private function warmup(string $warmupDir, string $realCacheDir, bool $enableOptionalWarmers = true)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ protected function configure()
6060
/**
6161
* {@inheritdoc}
6262
*/
63-
protected function execute(InputInterface $input, OutputInterface $output)
63+
protected function execute(InputInterface $input, OutputInterface $output): int
6464
{
6565
$io = new SymfonyStyle($input, $output);
6666
$kernel = $this->getApplication()->getKernel();
@@ -99,5 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9999
}
100100

101101
$io->success('Cache was successfully cleared.');
102+
103+
return 0;
102104
}
103105
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function configure()
5959
/**
6060
* {@inheritdoc}
6161
*/
62-
protected function execute(InputInterface $input, OutputInterface $output)
62+
protected function execute(InputInterface $input, OutputInterface $output): int
6363
{
6464
$io = new SymfonyStyle($input, $output);
6565
$pool = $input->getArgument('pool');
@@ -69,13 +69,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
6969
if (!$cachePool->hasItem($key)) {
7070
$io->note(sprintf('Cache item "%s" does not exist in cache pool "%s".', $key, $pool));
7171

72-
return;
72+
return 0;
7373
}
7474

7575
if (!$cachePool->deleteItem($key)) {
7676
throw new \Exception(sprintf('Cache item "%s" could not be deleted.', $key));
7777
}
7878

7979
$io->success(sprintf('Cache item "%s" was successfully deleted.', $key));
80+
81+
return 0;
8082
}
8183
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@ protected function configure()
5151
/**
5252
* {@inheritdoc}
5353
*/
54-
protected function execute(InputInterface $input, OutputInterface $output)
54+
protected function execute(InputInterface $input, OutputInterface $output): int
5555
{
5656
$io = new SymfonyStyle($input, $output);
5757

5858
$io->table(['Pool name'], array_map(function ($pool) {
5959
return [$pool];
6060
}, $this->poolNames));
61+
62+
return 0;
6163
}
6264
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected function configure()
5757
/**
5858
* {@inheritdoc}
5959
*/
60-
protected function execute(InputInterface $input, OutputInterface $output)
60+
protected function execute(InputInterface $input, OutputInterface $output): int
6161
{
6262
$io = new SymfonyStyle($input, $output);
6363

@@ -67,5 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6767
}
6868

6969
$io->success('Successfully pruned cache pool(s).');
70+
71+
return 0;
7072
}
7173
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected function configure()
6666
/**
6767
* {@inheritdoc}
6868
*/
69-
protected function execute(InputInterface $input, OutputInterface $output)
69+
protected function execute(InputInterface $input, OutputInterface $output): int
7070
{
7171
$io = new SymfonyStyle($input, $output);
7272

@@ -80,5 +80,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8080
$this->cacheWarmer->warmUp($kernel->getContainer()->getParameter('kernel.cache_dir'));
8181

8282
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
83+
84+
return 0;
8385
}
8486
}

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