From dac4f0e7133eab7da116d68931933cdbf442a394 Mon Sep 17 00:00:00 2001 From: Tareq Ahamed Date: Fri, 15 Sep 2023 16:55:17 +0600 Subject: [PATCH] Add some return types --- Cli/Application.php | 4 ++-- Cli/Command/AnalysisCommand.php | 4 ++-- Cli/Command/AnalyzeCommand.php | 4 ++-- Cli/Command/ConfigureCommand.php | 6 ++++-- Cli/Command/ProjectsCommand.php | 6 ++++-- Cli/Command/SelfUpdateCommand.php | 10 +++++++--- Cli/Helper/ConfigurationHelper.php | 2 +- Cli/Helper/DescriptorHelper.php | 2 +- Cli/Helper/FailConditionHelper.php | 2 +- 9 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Cli/Application.php b/Cli/Application.php index 2a6d650..089e2f4 100644 --- a/Cli/Application.php +++ b/Cli/Application.php @@ -69,7 +69,7 @@ public function getApi() return $this->api; } - public function getLongVersion() + public function getLongVersion(): string { $version = parent::getLongVersion().' by Symfony'; $commit = '@git-commit@'; @@ -116,7 +116,7 @@ protected function getDefaultCommands(): array return $defaultCommands; } - protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) + protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output): int { if (!$command instanceof LocalCommand\NeedConfigurationInterface) { return parent::doRunCommand($command, $input, $output); diff --git a/Cli/Command/AnalysisCommand.php b/Cli/Command/AnalysisCommand.php index 00ccebf..63a478a 100644 --- a/Cli/Command/AnalysisCommand.php +++ b/Cli/Command/AnalysisCommand.php @@ -20,7 +20,7 @@ class AnalysisCommand extends Command implements NeedConfigurationInterface { - protected function configure() + protected function configure(): void { $this ->setName('analysis') @@ -32,7 +32,7 @@ protected function configure() ; } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $api = $this->getApplication()->getApi(); $analysis = $api->getProject($input->getArgument('project-uuid'))->getLastAnalysis(); diff --git a/Cli/Command/AnalyzeCommand.php b/Cli/Command/AnalyzeCommand.php index 39f6ee6..068c9a4 100644 --- a/Cli/Command/AnalyzeCommand.php +++ b/Cli/Command/AnalyzeCommand.php @@ -22,7 +22,7 @@ class AnalyzeCommand extends Command implements NeedConfigurationInterface { - protected function configure() + protected function configure(): void { $this ->setName('analyze') @@ -38,7 +38,7 @@ protected function configure() ; } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $projectUuid = $input->getArgument('project-uuid'); diff --git a/Cli/Command/ConfigureCommand.php b/Cli/Command/ConfigureCommand.php index 073d146..358f8db 100644 --- a/Cli/Command/ConfigureCommand.php +++ b/Cli/Command/ConfigureCommand.php @@ -17,7 +17,7 @@ class ConfigureCommand extends Command { - protected function configure() + protected function configure(): void { $this ->setName('configure') @@ -25,8 +25,10 @@ protected function configure() ; } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->getHelperSet()->get('configuration')->updateConfigurationManually($input, $output); + + return 0; } } diff --git a/Cli/Command/ProjectsCommand.php b/Cli/Command/ProjectsCommand.php index d0e88cf..c47c87c 100644 --- a/Cli/Command/ProjectsCommand.php +++ b/Cli/Command/ProjectsCommand.php @@ -18,7 +18,7 @@ class ProjectsCommand extends Command implements NeedConfigurationInterface { - protected function configure() + protected function configure(): void { $this ->setName('projects') @@ -26,7 +26,7 @@ protected function configure() ; } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $api = $this->getApplication()->getApi(); @@ -58,5 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output) ->setRows($rows) ->render() ; + + return 0; } } diff --git a/Cli/Command/SelfUpdateCommand.php b/Cli/Command/SelfUpdateCommand.php index 05c9523..feeb08d 100644 --- a/Cli/Command/SelfUpdateCommand.php +++ b/Cli/Command/SelfUpdateCommand.php @@ -25,7 +25,7 @@ class SelfUpdateCommand extends Command /** * {@inheritdoc} */ - protected function configure() + protected function configure(): void { $this ->setName('self-update') @@ -44,7 +44,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $remoteFilename = 'http://get.insight.sensiolabs.com/insight.phar'; $localFilename = $_SERVER['argv'][0]; @@ -57,7 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln('insight is already up to date.'); unlink($tempFilename); - return; + return 0; } chmod($tempFilename, 0777 & ~umask()); @@ -69,6 +69,8 @@ protected function execute(InputInterface $input, OutputInterface $output) rename($tempFilename, $localFilename); $output->writeln('insight updated.'); + + return 0; } catch (\Exception $e) { if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) { throw $e; @@ -76,6 +78,8 @@ protected function execute(InputInterface $input, OutputInterface $output) unlink($tempFilename); $output->writeln('The download is corrupt ('.$e->getMessage().').'); $output->writeln('Please re-run the self-update command to try again.'); + + return 1; } } } diff --git a/Cli/Helper/ConfigurationHelper.php b/Cli/Helper/ConfigurationHelper.php index 0994c09..f65f2dd 100644 --- a/Cli/Helper/ConfigurationHelper.php +++ b/Cli/Helper/ConfigurationHelper.php @@ -62,7 +62,7 @@ public function getConfiguration(InputInterface $input, OutputInterface $output) return $configuration; } - public function getName() + public function getName(): string { return 'configuration'; } diff --git a/Cli/Helper/DescriptorHelper.php b/Cli/Helper/DescriptorHelper.php index 83c082a..cf5772b 100644 --- a/Cli/Helper/DescriptorHelper.php +++ b/Cli/Helper/DescriptorHelper.php @@ -61,7 +61,7 @@ public function register($format, AbstractDescriptor $descriptor) /** * {@inheritdoc} */ - public function getName() + public function getName(): string { return 'descriptor'; } diff --git a/Cli/Helper/FailConditionHelper.php b/Cli/Helper/FailConditionHelper.php index 64a93a3..34943af 100644 --- a/Cli/Helper/FailConditionHelper.php +++ b/Cli/Helper/FailConditionHelper.php @@ -69,7 +69,7 @@ public function evaluate(Analysis $analysis, $expr) return 0; } - public function getName() + public function getName(): string { return 'fail_condition'; }