diff --git a/setup/src/Magento/Setup/Console/Command/ModuleStatusCommand.php b/setup/src/Magento/Setup/Console/Command/ModuleStatusCommand.php
index b4504efdc3423..65a26df11b2cd 100644
--- a/setup/src/Magento/Setup/Console/Command/ModuleStatusCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/ModuleStatusCommand.php
@@ -8,13 +8,13 @@
namespace Magento\Setup\Console\Command;
+use Magento\Framework\Console\Cli;
use Magento\Framework\Module\FullModuleList;
use Magento\Framework\Module\ModuleList;
use Magento\Setup\Model\ObjectManagerProvider;
-use Magento\Framework\Console\Cli;
+use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Input\InputArgument;
/**
* Command for displaying status of modules
@@ -22,15 +22,11 @@
class ModuleStatusCommand extends AbstractSetupCommand
{
/**
- * Object manager provider
- *
* @var ObjectManagerProvider
*/
private $objectManagerProvider;
/**
- * Inject dependencies
- *
* @param ObjectManagerProvider $objectManagerProvider
*/
public function __construct(ObjectManagerProvider $objectManagerProvider)
@@ -40,28 +36,33 @@ public function __construct(ObjectManagerProvider $objectManagerProvider)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
protected function configure()
{
$this->setName('module:status')
->setDescription('Displays status of modules')
- ->addArgument('module-names', InputArgument::OPTIONAL | InputArgument::IS_ARRAY , 'Optional module name')
+ ->addArgument(
+ 'module-names',
+ InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
+ 'Optional module name'
+ )
->addOption('enabled', null, null, 'Print only enabled modules')
->addOption('disabled', null, null, 'Print only disabled modules');
parent::configure();
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$moduleNames = $input->getArgument('module-names');
if (!empty($moduleNames)) {
- foreach($moduleNames as $moduleName)
+ foreach ($moduleNames as $moduleName) {
$this->showSpecificModule($moduleName, $output);
- return;
+ }
+ return 0;
}
$onlyEnabled = $input->getOption('enabled');
@@ -81,34 +82,42 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln("List of disabled modules:");
$this->showDisabledModules($output);
$output->writeln('');
+
+ return 0;
}
/**
+ * Specific module show
+ *
* @param string $moduleName
* @param OutputInterface $output
+ * @return int
*/
- private function showSpecificModule(string $moduleName, OutputInterface $output)
+ private function showSpecificModule(string $moduleName, OutputInterface $output): int
{
$allModules = $this->getAllModules();
- if (!in_array($moduleName, $allModules->getNames())) {
- $output->writeln($moduleName.' : Module does not exist');
+ if (!in_array($moduleName, $allModules->getNames(), true)) {
+ $output->writeln($moduleName . ' : Module does not exist');
return Cli::RETURN_FAILURE;
}
$enabledModules = $this->getEnabledModules();
- if (in_array($moduleName, $enabledModules->getNames())) {
- $output->writeln($moduleName.' : Module is enabled');
+ if (in_array($moduleName, $enabledModules->getNames(), true)) {
+ $output->writeln($moduleName . ' : Module is enabled');
return Cli::RETURN_FAILURE;
}
- $output->writeln($moduleName.' : Module is disabled');
- return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
+ $output->writeln($moduleName . ' : Module is disabled');
+ return Cli::RETURN_SUCCESS;
}
/**
+ * Enable modules show
+ *
* @param OutputInterface $output
+ * @return int
*/
- private function showEnabledModules(OutputInterface $output)
+ private function showEnabledModules(OutputInterface $output): int
{
$enabledModules = $this->getEnabledModules();
$enabledModuleNames = $enabledModules->getNames();
@@ -118,13 +127,17 @@ private function showEnabledModules(OutputInterface $output)
}
$output->writeln(join("\n", $enabledModuleNames));
- return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
+
+ return Cli::RETURN_SUCCESS;
}
/**
+ * Disabled modules show
+ *
* @param OutputInterface $output
+ * @return int
*/
- private function showDisabledModules(OutputInterface $output)
+ private function showDisabledModules(OutputInterface $output): int
{
$disabledModuleNames = $this->getDisabledModuleNames();
if (count($disabledModuleNames) === 0) {
@@ -133,32 +146,42 @@ private function showDisabledModules(OutputInterface $output)
}
$output->writeln(join("\n", $disabledModuleNames));
- return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
+
+ return Cli::RETURN_SUCCESS;
}
/**
+ * Returns all modules
+ *
* @return FullModuleList
*/
private function getAllModules(): FullModuleList
{
- return $this->objectManagerProvider->get()->create(FullModuleList::class);
+ return $this->objectManagerProvider->get()
+ ->create(FullModuleList::class);
}
/**
+ * Returns enabled modules
+ *
* @return ModuleList
*/
private function getEnabledModules(): ModuleList
{
- return $this->objectManagerProvider->get()->create(ModuleList::class);
+ return $this->objectManagerProvider->get()
+ ->create(ModuleList::class);
}
/**
+ * Returns disabled module names
+ *
* @return array
*/
private function getDisabledModuleNames(): array
{
$fullModuleList = $this->getAllModules();
$enabledModules = $this->getEnabledModules();
+
return array_diff($fullModuleList->getNames(), $enabledModules->getNames());
}
}