Skip to content

Commit 2125a21

Browse files
authored
Merge pull request #7718 from magento-atwix-pyrrans/AC-2751-upgrade-symfony-to-latest-lts
[Pyrrans] Upgrade Symfony to the latest LTS version
2 parents 80ebca4 + d3ca3fd commit 2125a21

31 files changed

+747
-519
lines changed

app/code/Magento/Backend/Console/Command/AbstractCacheSetCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
namespace Magento\Backend\Console\Command;
88

9+
use Magento\Framework\Console\Cli;
910
use Symfony\Component\Console\Input\InputInterface;
1011
use Symfony\Component\Console\Output\OutputInterface;
1112

1213
/**
14+
* phpcs:disable Magento2.Classes.AbstractApi
1315
* @api
1416
* @since 100.0.2
1517
*/
@@ -23,7 +25,7 @@ abstract class AbstractCacheSetCommand extends AbstractCacheManageCommand
2325
abstract protected function isEnable();
2426

2527
/**
26-
* {@inheritdoc}
28+
* @inheritdoc
2729
*/
2830
protected function execute(InputInterface $input, OutputInterface $output)
2931
{
@@ -43,5 +45,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
4345
$output->writeln('Cleaned cache types:');
4446
$output->writeln(join(PHP_EOL, $changedTypes));
4547
}
48+
49+
return Cli::RETURN_SUCCESS;
4650
}
4751
}

app/code/Magento/Backend/Console/Command/AbstractCacheTypeManageCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66

77
namespace Magento\Backend\Console\Command;
88

9+
use Magento\Framework\Console\Cli;
910
use Magento\Framework\Event\ManagerInterface as EventManagerInterface;
1011
use Symfony\Component\Console\Input\InputInterface;
1112
use Symfony\Component\Console\Output\OutputInterface;
1213
use Magento\Framework\App\Cache\Manager;
1314

1415
/**
16+
* phpcs:disable Magento2.Classes.AbstractApi
1517
* @api
1618
* @since 100.0.2
1719
*/
@@ -54,13 +56,15 @@ abstract protected function getDisplayMessage();
5456
*
5557
* @param InputInterface $input
5658
* @param OutputInterface $output
57-
* @return void
59+
* @return int
5860
*/
5961
protected function execute(InputInterface $input, OutputInterface $output)
6062
{
6163
$types = $this->getRequestedTypes($input);
6264
$this->performAction($types);
6365
$output->writeln($this->getDisplayMessage());
6466
$output->writeln(join(PHP_EOL, $types));
67+
68+
return Cli::RETURN_SUCCESS;
6569
}
6670
}

app/code/Magento/Backend/Console/Command/CacheStatusCommand.php

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

77
namespace Magento\Backend\Console\Command;
88

9+
use Magento\Framework\Console\Cli;
910
use Symfony\Component\Console\Input\InputInterface;
1011
use Symfony\Component\Console\Output\OutputInterface;
1112

@@ -18,7 +19,7 @@
1819
class CacheStatusCommand extends AbstractCacheCommand
1920
{
2021
/**
21-
* {@inheritdoc}
22+
* @inheritdoc
2223
*/
2324
protected function configure()
2425
{
@@ -28,13 +29,15 @@ protected function configure()
2829
}
2930

3031
/**
31-
* {@inheritdoc}
32+
* @inheritdoc
3233
*/
3334
protected function execute(InputInterface $input, OutputInterface $output)
3435
{
3536
$output->writeln('Current status:');
3637
foreach ($this->cacheManager->getStatus() as $cache => $status) {
3738
$output->writeln(sprintf('%30s: %d', $cache, $status));
3839
}
40+
41+
return Cli::RETURN_SUCCESS;
3942
}
4043
}

app/code/Magento/Cron/Console/Command/CronCommand.php

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,35 @@
66

77
namespace Magento\Cron\Console\Command;
88

9-
use Symfony\Component\Console\Command\Command;
10-
use Symfony\Component\Console\Input\InputInterface;
11-
use Symfony\Component\Console\Output\OutputInterface;
12-
use Symfony\Component\Console\Input\InputOption;
13-
use Magento\Framework\App\ObjectManager;
14-
use Magento\Framework\App\ObjectManagerFactory;
15-
use Magento\Store\Model\Store;
16-
use Magento\Store\Model\StoreManager;
179
use Magento\Cron\Observer\ProcessCronQueueObserver;
10+
use Magento\Framework\App\Cron;
1811
use Magento\Framework\App\DeploymentConfig;
12+
use Magento\Framework\App\ObjectManager;
13+
use Magento\Framework\App\ObjectManagerFactory;
1914
use Magento\Framework\Console\Cli;
15+
use Magento\Framework\Exception\FileSystemException;
16+
use Magento\Framework\Exception\RuntimeException;
2017
use Magento\Framework\Shell\ComplexParameter;
18+
use Magento\Store\Model\Store;
19+
use Magento\Store\Model\StoreManager;
20+
use Symfony\Component\Console\Command\Command;
21+
use Symfony\Component\Console\Input\InputInterface;
22+
use Symfony\Component\Console\Input\InputOption;
23+
use Symfony\Component\Console\Output\OutputInterface;
2124

2225
/**
2326
* Command for executing cron jobs
27+
*
28+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2429
*/
2530
class CronCommand extends Command
2631
{
2732
/**
2833
* Name of input option
2934
*/
30-
const INPUT_KEY_GROUP = 'group';
35+
public const INPUT_KEY_GROUP = 'group';
3136

3237
/**
33-
* Object manager factory
34-
*
3538
* @var ObjectManagerFactory
3639
*/
3740
private $objectManagerFactory;
@@ -45,7 +48,7 @@ class CronCommand extends Command
4548

4649
/**
4750
* @param ObjectManagerFactory $objectManagerFactory
48-
* @param DeploymentConfig $deploymentConfig Application deployment configuration
51+
* @param DeploymentConfig|null $deploymentConfig Application deployment configuration
4952
*/
5053
public function __construct(
5154
ObjectManagerFactory $objectManagerFactory,
@@ -59,7 +62,7 @@ public function __construct(
5962
}
6063

6164
/**
62-
* {@inheritdoc}
65+
* @inheritdoc
6366
*/
6467
protected function configure()
6568
{
@@ -86,14 +89,20 @@ protected function configure()
8689
/**
8790
* Runs cron jobs if cron is not disabled in Magento configurations
8891
*
89-
* {@inheritdoc}
92+
* @param InputInterface $input
93+
* @param OutputInterface $output
94+
*
95+
* @return int
96+
* @throws FileSystemException
97+
* @throws RuntimeException
9098
*/
9199
protected function execute(InputInterface $input, OutputInterface $output)
92100
{
93101
if (!$this->deploymentConfig->get('cron/enabled', 1)) {
94102
$output->writeln('<info>' . 'Cron is disabled. Jobs were not run.' . '</info>');
95-
return;
103+
return Cli::RETURN_SUCCESS;
96104
}
105+
// phpcs:ignore Magento2.Security.Superglobal
97106
$omParams = $_SERVER;
98107
$omParams[StoreManager::PARAM_RUN_CODE] = 'admin';
99108
$omParams[Store::CUSTOM_ENTRY_POINT_PARAM] = true;
@@ -112,9 +121,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
112121
$params[ProcessCronQueueObserver::STANDALONE_PROCESS_STARTED] = $bootstrapOptionValue;
113122
}
114123
}
115-
/** @var \Magento\Framework\App\Cron $cronObserver */
116-
$cronObserver = $objectManager->create(\Magento\Framework\App\Cron::class, ['parameters' => $params]);
124+
/** @var Cron $cronObserver */
125+
$cronObserver = $objectManager->create(Cron::class, ['parameters' => $params]);
117126
$cronObserver->launch();
118127
$output->writeln('<info>' . 'Ran jobs by schedule.' . '</info>');
128+
129+
return Cli::RETURN_SUCCESS;
119130
}
120131
}

app/code/Magento/Deploy/Console/Command/ShowModeCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Deploy\Console\Command;
88

9+
use Magento\Framework\Console\Cli;
910
use Magento\Framework\ObjectManagerInterface;
1011
use Magento\Framework\App\State;
1112
use Symfony\Component\Console\Command\Command;
@@ -69,7 +70,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
6970
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
7071
$output->writeln($e->getTraceAsString());
7172
}
72-
return;
73+
return Cli::RETURN_FAILURE;
7374
}
75+
76+
return Cli::RETURN_SUCCESS;
7477
}
7578
}

app/code/Magento/Developer/Console/Command/ProfilerDisableCommand.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\Developer\Console\Command;
88

9+
use InvalidArgumentException;
10+
use Magento\Framework\Console\Cli;
911
use Magento\Framework\Filesystem\Io\File;
1012
use Symfony\Component\Console\Command\Command;
1113
use Symfony\Component\Console\Input\InputInterface;
@@ -14,19 +16,13 @@
1416
class ProfilerDisableCommand extends Command
1517
{
1618
/**
17-
* Profiler flag file
19+
* Profiler flag file path
1820
*/
19-
const PROFILER_FLAG_FILE = 'var/profiler.flag';
21+
public const PROFILER_FLAG_FILE = 'var/profiler.flag';
2022

21-
/**
22-
* Command name
23-
*/
24-
const COMMAND_NAME = 'dev:profiler:disable';
23+
public const COMMAND_NAME = 'dev:profiler:disable';
2524

26-
/**
27-
* Success message
28-
*/
29-
const SUCCESS_MESSAGE = 'Profiler disabled.';
25+
public const SUCCESS_MESSAGE = 'Profiler disabled.';
3026

3127
/**
3228
* @var File
@@ -46,7 +42,7 @@ public function __construct(File $filesystem)
4642
}
4743

4844
/**
49-
* {@inheritdoc}
45+
* @inheritdoc
5046
*/
5147
protected function configure()
5248
{
@@ -57,16 +53,19 @@ protected function configure()
5753
}
5854

5955
/**
60-
* {@inheritdoc}
61-
* @throws \InvalidArgumentException
56+
* @inheritdoc
57+
*
58+
* @throws InvalidArgumentException
6259
*/
6360
protected function execute(InputInterface $input, OutputInterface $output)
6461
{
6562
$this->filesystem->rm(BP . '/' . self::PROFILER_FLAG_FILE);
6663
if (!$this->filesystem->fileExists(BP . '/' . self::PROFILER_FLAG_FILE)) {
6764
$output->writeln('<info>'. self::SUCCESS_MESSAGE . '</info>');
68-
return;
65+
return Cli::RETURN_SUCCESS;
6966
}
7067
$output->writeln('<error>Something went wrong while disabling the profiler.</error>');
68+
69+
return Cli::RETURN_FAILURE;
7170
}
7271
}

app/code/Magento/Developer/Console/Command/ProfilerEnableCommand.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,35 @@
66

77
namespace Magento\Developer\Console\Command;
88

9+
use InvalidArgumentException;
10+
use Magento\Framework\Console\Cli;
911
use Magento\Framework\Filesystem\Io\File;
12+
use Magento\Framework\Profiler\Driver\Standard\Output\Csvfile;
1013
use Symfony\Component\Console\Command\Command;
14+
use Symfony\Component\Console\Input\InputArgument;
1115
use Symfony\Component\Console\Input\InputInterface;
1216
use Symfony\Component\Console\Output\OutputInterface;
13-
use Symfony\Component\Console\Input\InputArgument;
1417

1518
class ProfilerEnableCommand extends Command
1619
{
1720
/**
18-
* Profiler flag file
21+
* Profiler flag file path
1922
*/
20-
const PROFILER_FLAG_FILE = 'var/profiler.flag';
23+
public const PROFILER_FLAG_FILE = 'var/profiler.flag';
2124

2225
/**
2326
* Profiler type default setting
2427
*/
25-
const TYPE_DEFAULT = 'html';
28+
public const TYPE_DEFAULT = 'html';
2629

2730
/**
2831
* Built in profiler types
2932
*/
30-
const BUILT_IN_TYPES = ['html', 'csvfile'];
33+
public const BUILT_IN_TYPES = ['html', 'csvfile'];
3134

32-
/**
33-
* Command name
34-
*/
35-
const COMMAND_NAME = 'dev:profiler:enable';
35+
public const COMMAND_NAME = 'dev:profiler:enable';
3636

37-
/**
38-
* Success message
39-
*/
40-
const SUCCESS_MESSAGE = 'Profiler enabled with %s output.';
37+
public const SUCCESS_MESSAGE = 'Profiler enabled with %s output.';
4138

4239
/**
4340
* @var File
@@ -57,7 +54,7 @@ public function __construct(File $filesystem)
5754
}
5855

5956
/**
60-
* {@inheritdoc}
57+
* @inheritdoc
6158
*/
6259
protected function configure()
6360
{
@@ -69,8 +66,9 @@ protected function configure()
6966
}
7067

7168
/**
72-
* {@inheritdoc}
73-
* @throws \InvalidArgumentException
69+
* @inheritdoc
70+
*
71+
* @throws InvalidArgumentException
7472
*/
7573
protected function execute(InputInterface $input, OutputInterface $output)
7674
{
@@ -95,15 +93,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
9593
$output->write(
9694
'<info> ' . sprintf(
9795
'Output will be saved in %s',
98-
\Magento\Framework\Profiler\Driver\Standard\Output\Csvfile::DEFAULT_FILEPATH
96+
Csvfile::DEFAULT_FILEPATH
9997
)
10098
. '</info>'
10199
);
102100
}
103101
$output->write(PHP_EOL);
104102

105-
return;
103+
return Cli::RETURN_SUCCESS;
106104
}
107105
$output->writeln('<error>Something went wrong while enabling the profiler.</error>');
106+
107+
return Cli::RETURN_FAILURE;
108108
}
109109
}

0 commit comments

Comments
 (0)