From d79315036f8e0ebb6441270bddf574d58d85a637 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Thu, 18 May 2023 15:14:46 +0545 Subject: [PATCH] Always return an int from Symfony Command execute method --- lib/Commands/AddClient.php | 5 +++-- lib/Commands/ListClients.php | 4 ++-- lib/Commands/ModifyClient.php | 5 +++-- lib/Commands/RemoveClient.php | 7 ++++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/Commands/AddClient.php b/lib/Commands/AddClient.php index 3cb85fd..6d507a1 100644 --- a/lib/Commands/AddClient.php +++ b/lib/Commands/AddClient.php @@ -90,10 +90,10 @@ protected function configure() { /** * @param InputInterface $input * @param OutputInterface $output - * @return int|void + * @return int * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $name = $input->getArgument('name'); $id = $input->getArgument('client-id'); $secret = $input->getArgument('client-secret'); @@ -149,5 +149,6 @@ protected function execute(InputInterface $input, OutputInterface $output) { $this->clientMapper->insert($client); } + return 0; } } diff --git a/lib/Commands/ListClients.php b/lib/Commands/ListClients.php index 407d76b..9f3e68e 100644 --- a/lib/Commands/ListClients.php +++ b/lib/Commands/ListClients.php @@ -48,10 +48,10 @@ protected function configure() { /** * @param InputInterface $input * @param OutputInterface $output - * @return int|void + * @return int * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $clients = $this->clientMapper->findAll(); $clientsOutput = []; diff --git a/lib/Commands/ModifyClient.php b/lib/Commands/ModifyClient.php index 4db84d6..6a9383a 100644 --- a/lib/Commands/ModifyClient.php +++ b/lib/Commands/ModifyClient.php @@ -66,10 +66,10 @@ protected function configure() { /** * @param InputInterface $input * @param OutputInterface $output - * @return int|void + * @return int * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $name = $input->getArgument('name'); $key = $input->getArgument('key'); $value = $input->getArgument('value'); @@ -138,5 +138,6 @@ protected function execute(InputInterface $input, OutputInterface $output) { \call_user_func([$client, $funcMapper[$key]], $value); $this->clientMapper->update($client); + return 0; } } diff --git a/lib/Commands/RemoveClient.php b/lib/Commands/RemoveClient.php index 60c4e6a..4441bf5 100644 --- a/lib/Commands/RemoveClient.php +++ b/lib/Commands/RemoveClient.php @@ -54,18 +54,19 @@ protected function configure() { * @param InputInterface $input * @param OutputInterface $output * - * @return int|void|null + * @return int * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $id = $input->getArgument('client-id'); try { $client = $this->clientMapper->findByIdentifier($id); $this->clientMapper->delete($client); $output->writeln("Client <$id> has been deleted"); - return; } catch (DoesNotExistException $ex) { $output->writeln("Client <$id> is unknown"); + return 1; } + return 0; } }