Always return an int for Symfony Command execute method#40793
Conversation
| $groupPrincipalBackend = new GroupPrincipalBackend( | ||
| $this->groupManager | ||
| ); | ||
| $config = \OC::$server->getConfig(); |
There was a problem hiding this comment.
$config was unused.
| } | ||
| } | ||
| $cursor->closeCursor(); | ||
| return 0; |
There was a problem hiding this comment.
The execute method did not have an explicit return 0 (but in Symfony 4 that works - it breaks in Symfony 5)
| ]); | ||
| }); | ||
| $t->render(); | ||
| return 0; |
There was a problem hiding this comment.
Another place to explicitly return 0 at the end of the method.
| $continue = $dialog->ask($input, $output, new Question('<question>Continue with the conversion (y/n)? [n] </question>', false)); | ||
| if ($continue !== 'y') { | ||
| return; | ||
| return 0; |
There was a problem hiding this comment.
The user has interactively answered "no". We are doing what the user said, so return 0 (which is success - we successfully did what the user said)
| } | ||
| $intersectingTables = \array_intersect($toTables, $fromTables); | ||
| $this->convertDB($fromDB, $toDB, $intersectingTables, $input, $output); | ||
| return 0; |
There was a problem hiding this comment.
Return 0 (success) at the end of execute
| $output->writeln('Example: ./occ integrity:sign-app --path="/Users/lukasreschke/Programming/myapp/" --privateKey="/Users/lukasreschke/private/myapp.key" --certificate="/Users/lukasreschke/public/mycert.crt"'); | ||
| $output->writeln('For more information please consult the documentation: '. $documentationUrl); | ||
| return null; | ||
| return 1; |
There was a problem hiding this comment.
null is not a proper return value. There is a problem, so return 1
| if ($privateKeyPath === null || $keyBundlePath === null || $path === null) { | ||
| $output->writeln('--privateKey, --certificate and --path are required.'); | ||
| return null; | ||
| return 1; |
There was a problem hiding this comment.
null is not a proper return value. There is a problem, so return 1
6b52904 to
9c6c466
Compare
|
Kudos, SonarCloud Quality Gate passed! |








Description
Symfony 5 requires that the Symfony Command
executemethod always returns anintIt is "sort of" optional for Symfony 4, but actually we should always return an
intThis PR:
intintis now returned. That will fix potential problems with some commands.How Has This Been Tested?
CI
Types of changes
Checklist: