Skip to content

Commit 1d81ca2

Browse files
fix static
1 parent 46f74af commit 1d81ca2

File tree

1 file changed

+47
-24
lines changed

1 file changed

+47
-24
lines changed

setup/src/Magento/Setup/Console/Command/ModuleStatusCommand.php

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,25 @@
88

99
namespace Magento\Setup\Console\Command;
1010

11+
use Magento\Framework\Console\Cli;
1112
use Magento\Framework\Module\FullModuleList;
1213
use Magento\Framework\Module\ModuleList;
1314
use Magento\Setup\Model\ObjectManagerProvider;
14-
use Magento\Framework\Console\Cli;
15+
use Symfony\Component\Console\Input\InputArgument;
1516
use Symfony\Component\Console\Input\InputInterface;
1617
use Symfony\Component\Console\Output\OutputInterface;
17-
use Symfony\Component\Console\Input\InputArgument;
1818

1919
/**
2020
* Command for displaying status of modules
2121
*/
2222
class ModuleStatusCommand extends AbstractSetupCommand
2323
{
2424
/**
25-
* Object manager provider
26-
*
2725
* @var ObjectManagerProvider
2826
*/
2927
private $objectManagerProvider;
3028

3129
/**
32-
* Inject dependencies
33-
*
3430
* @param ObjectManagerProvider $objectManagerProvider
3531
*/
3632
public function __construct(ObjectManagerProvider $objectManagerProvider)
@@ -40,28 +36,33 @@ public function __construct(ObjectManagerProvider $objectManagerProvider)
4036
}
4137

4238
/**
43-
* {@inheritdoc}
39+
* @inheritdoc
4440
*/
4541
protected function configure()
4642
{
4743
$this->setName('module:status')
4844
->setDescription('Displays status of modules')
49-
->addArgument('module-names', InputArgument::OPTIONAL | InputArgument::IS_ARRAY , 'Optional module name')
45+
->addArgument(
46+
'module-names',
47+
InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
48+
'Optional module name'
49+
)
5050
->addOption('enabled', null, null, 'Print only enabled modules')
5151
->addOption('disabled', null, null, 'Print only disabled modules');
5252
parent::configure();
5353
}
5454

5555
/**
56-
* {@inheritdoc}
56+
* @inheritdoc
5757
*/
5858
protected function execute(InputInterface $input, OutputInterface $output)
5959
{
6060
$moduleNames = $input->getArgument('module-names');
6161
if (!empty($moduleNames)) {
62-
foreach($moduleNames as $moduleName)
62+
foreach ($moduleNames as $moduleName) {
6363
$this->showSpecificModule($moduleName, $output);
64-
return;
64+
}
65+
return 0;
6566
}
6667

6768
$onlyEnabled = $input->getOption('enabled');
@@ -81,34 +82,42 @@ protected function execute(InputInterface $input, OutputInterface $output)
8182
$output->writeln("<info>List of disabled modules:</info>");
8283
$this->showDisabledModules($output);
8384
$output->writeln('');
85+
86+
return 0;
8487
}
8588

8689
/**
90+
* Specific module show
91+
*
8792
* @param string $moduleName
8893
* @param OutputInterface $output
94+
* @return int
8995
*/
90-
private function showSpecificModule(string $moduleName, OutputInterface $output)
96+
private function showSpecificModule(string $moduleName, OutputInterface $output): int
9197
{
9298
$allModules = $this->getAllModules();
93-
if (!in_array($moduleName, $allModules->getNames())) {
94-
$output->writeln($moduleName.' : <error>Module does not exist</error>');
99+
if (!in_array($moduleName, $allModules->getNames(), true)) {
100+
$output->writeln($moduleName . ' : <error>Module does not exist</error>');
95101
return Cli::RETURN_FAILURE;
96102
}
97103

98104
$enabledModules = $this->getEnabledModules();
99-
if (in_array($moduleName, $enabledModules->getNames())) {
100-
$output->writeln($moduleName.' : <info>Module is enabled</info>');
105+
if (in_array($moduleName, $enabledModules->getNames(), true)) {
106+
$output->writeln($moduleName . ' : <info>Module is enabled</info>');
101107
return Cli::RETURN_FAILURE;
102108
}
103109

104-
$output->writeln($moduleName.' : <info> Module is disabled</info>');
105-
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
110+
$output->writeln($moduleName . ' : <info> Module is disabled</info>');
111+
return Cli::RETURN_SUCCESS;
106112
}
107113

108114
/**
115+
* Enable modules show
116+
*
109117
* @param OutputInterface $output
118+
* @return int
110119
*/
111-
private function showEnabledModules(OutputInterface $output)
120+
private function showEnabledModules(OutputInterface $output): int
112121
{
113122
$enabledModules = $this->getEnabledModules();
114123
$enabledModuleNames = $enabledModules->getNames();
@@ -118,13 +127,17 @@ private function showEnabledModules(OutputInterface $output)
118127
}
119128

120129
$output->writeln(join("\n", $enabledModuleNames));
121-
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
130+
131+
return Cli::RETURN_SUCCESS;
122132
}
123133

124134
/**
135+
* Disabled modules show
136+
*
125137
* @param OutputInterface $output
138+
* @return int
126139
*/
127-
private function showDisabledModules(OutputInterface $output)
140+
private function showDisabledModules(OutputInterface $output): int
128141
{
129142
$disabledModuleNames = $this->getDisabledModuleNames();
130143
if (count($disabledModuleNames) === 0) {
@@ -133,32 +146,42 @@ private function showDisabledModules(OutputInterface $output)
133146
}
134147

135148
$output->writeln(join("\n", $disabledModuleNames));
136-
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
149+
150+
return Cli::RETURN_SUCCESS;
137151
}
138152

139153
/**
154+
* Returns all modules
155+
*
140156
* @return FullModuleList
141157
*/
142158
private function getAllModules(): FullModuleList
143159
{
144-
return $this->objectManagerProvider->get()->create(FullModuleList::class);
160+
return $this->objectManagerProvider->get()
161+
->create(FullModuleList::class);
145162
}
146163

147164
/**
165+
* Returns enabled modules
166+
*
148167
* @return ModuleList
149168
*/
150169
private function getEnabledModules(): ModuleList
151170
{
152-
return $this->objectManagerProvider->get()->create(ModuleList::class);
171+
return $this->objectManagerProvider->get()
172+
->create(ModuleList::class);
153173
}
154174

155175
/**
176+
* Returns disabled module names
177+
*
156178
* @return array
157179
*/
158180
private function getDisabledModuleNames(): array
159181
{
160182
$fullModuleList = $this->getAllModules();
161183
$enabledModules = $this->getEnabledModules();
184+
162185
return array_diff($fullModuleList->getNames(), $enabledModules->getNames());
163186
}
164187
}

0 commit comments

Comments
 (0)