-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always return an int for Symfony Command execute method #40793
Conversation
@@ -82,7 +82,6 @@ protected function execute(InputInterface $input, OutputInterface $output) { | |||
$groupPrincipalBackend = new GroupPrincipalBackend( | |||
$this->groupManager | |||
); | |||
$config = \OC::$server->getConfig(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$config
was unused.
@@ -134,6 +134,7 @@ public function execute(InputInterface $input, OutputInterface $output) { | |||
} | |||
} | |||
$cursor->closeCursor(); | |||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The execute method did not have an explicit return 0
(but in Symfony 4 that works - it breaks in Symfony 5)
@@ -70,5 +70,6 @@ protected function execute(InputInterface $input, OutputInterface $output) { | |||
]); | |||
}); | |||
$t->render(); | |||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another place to explicitly return 0 at the end of the method.
@@ -252,11 +252,12 @@ protected function execute(InputInterface $input, OutputInterface $output) { | |||
'@phan-var \Symfony\Component\Console\Helper\QuestionHelper $dialog'; | |||
$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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return 0
(success) at the end of execute
@@ -82,20 +82,20 @@ protected function execute(InputInterface $input, OutputInterface $output) { | |||
$output->writeln('This command requires the --path, --privateKey and --certificate.'); | |||
$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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null
is not a proper return value. There is a problem, so return 1
$privateKeyPath = $input->getOption('privateKey'); | ||
$keyBundlePath = $input->getOption('certificate'); | ||
$path = $input->getOption('path'); | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
execute
method always returns anint
It is "sort of" optional for Symfony 4, but actually we should always return an
int
This PR:
int
int
is now returned. That will fix potential problems with some commands.How Has This Been Tested?
CI
Types of changes
Checklist: