Skip to content

Commit

Permalink
Merge pull request #322 from owncloud/symfony-command-execute-int
Browse files Browse the repository at this point in the history
Always return an int from Symfony Command execute method
  • Loading branch information
phil-davis authored May 18, 2023
2 parents 7654d29 + b68ab50 commit 1573d33
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions lib/Command/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -123,7 +123,7 @@ public function execute(InputInterface $input, OutputInterface $output) {

if (\count($users) === 0) {
$output->writeln('<error>Please specify the user id to index, "--all" to index for all users</error>');
return;
return 1;
}

foreach ($users as $user) {
Expand All @@ -136,5 +136,6 @@ public function execute(InputInterface $input, OutputInterface $output) {
$output->writeln("<error>Unknown user $user</error>");
}
}
return 0;
}
}
4 changes: 2 additions & 2 deletions lib/Command/Rebuild.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lib/Command/Reset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lib/Command/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down

0 comments on commit 1573d33

Please sign in to comment.