From b68ab50d2f17c9895370dbda385cdb72c1348cf9 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Thu, 18 May 2023 15:18:44 +0545 Subject: [PATCH] Always return an int from Symfony Command execute method --- lib/Command/Create.php | 7 ++++--- lib/Command/Rebuild.php | 4 ++-- lib/Command/Reset.php | 2 +- lib/Command/Update.php | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/Command/Create.php b/lib/Command/Create.php index a3632cc1..7745b460 100644 --- a/lib/Command/Create.php +++ b/lib/Command/Create.php @@ -111,9 +111,9 @@ protected function indexFiles($user, $quiet, OutputInterface $output) { * @param InputInterface $input * @param OutputInterface $output * - * @return int|null|void + * @return int */ - public function execute(InputInterface $input, OutputInterface $output) { + public function execute(InputInterface $input, OutputInterface $output): int { if ($input->getOption('all')) { $users = $this->userManager->search(''); } else { @@ -123,7 +123,7 @@ public function execute(InputInterface $input, OutputInterface $output) { if (\count($users) === 0) { $output->writeln('Please specify the user id to index, "--all" to index for all users'); - return; + return 1; } foreach ($users as $user) { @@ -136,5 +136,6 @@ public function execute(InputInterface $input, OutputInterface $output) { $output->writeln("Unknown user $user"); } } + return 0; } } diff --git a/lib/Command/Rebuild.php b/lib/Command/Rebuild.php index d9a4f2d7..aa9eb80b 100644 --- a/lib/Command/Rebuild.php +++ b/lib/Command/Rebuild.php @@ -124,7 +124,7 @@ protected function configure() { * * @return int */ - public function execute(InputInterface $input, OutputInterface $output) { + public function execute(InputInterface $input, OutputInterface $output): int { $users = $input->getArgument('user_id'); $quiet = $input->getOption('quiet'); @@ -133,7 +133,7 @@ public function execute(InputInterface $input, OutputInterface $output) { if ($userObject !== null) { if ($this->shouldAbort($input, $output)) { $output->writeln('Aborting.'); - return -1; + return 1; } $this->rebuildIndex($userObject, $quiet, $output); } else { diff --git a/lib/Command/Reset.php b/lib/Command/Reset.php index 5dee0cf0..124c059e 100644 --- a/lib/Command/Reset.php +++ b/lib/Command/Reset.php @@ -78,7 +78,7 @@ protected function configure() { * * @return int */ - public function execute(InputInterface $input, OutputInterface $output) { + public function execute(InputInterface $input, OutputInterface $output): int { if ($input->getOption('force')) { $continue = true; } else { diff --git a/lib/Command/Update.php b/lib/Command/Update.php index 3ba5ce0d..73ee218b 100644 --- a/lib/Command/Update.php +++ b/lib/Command/Update.php @@ -85,7 +85,7 @@ protected function configure() { * * @return int */ - public function execute(InputInterface $input, OutputInterface $output) { + public function execute(InputInterface $input, OutputInterface $output): int { $output->writeln("Start Updating the Elastic Search index:"); $updateJobs = [];