Skip to content
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 from Symfony Command execute method #395

Merged
merged 1 commit into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Command/FixEncryptedVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected function configure() {
* @param OutputInterface $output
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output) {
protected function execute(InputInterface $input, OutputInterface $output): int {
$user = $input->getArgument('user');
$pathToWalk = "/$user/files";

Expand Down
6 changes: 4 additions & 2 deletions lib/Command/HSMDaemon.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ protected function configure() {
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int|void
* @return int
* @throws \Exception
*/
protected function execute(InputInterface $input, OutputInterface $output) {
protected function execute(InputInterface $input, OutputInterface $output): int {
/** @var string|null $hsmUrl */
$hsmUrl = $this->config->getAppValue('encryption', 'hsm.url');
if (\is_string($hsmUrl) && $hsmUrl !== '') {
Expand All @@ -79,6 +79,8 @@ protected function execute(InputInterface $input, OutputInterface $output) {
}
} else {
$output->writeln("<error>hsm.url not set</error>");
return 1;
}
return 0;
}
}
5 changes: 3 additions & 2 deletions lib/Command/HSMDaemonDecrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ protected function configure() {
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int|void
* @return int
* @throws \Exception
*/
protected function execute(InputInterface $input, OutputInterface $output) {
protected function execute(InputInterface $input, OutputInterface $output): int {
$hsmUrl = $this->config->getAppValue('encryption', 'hsm.url');
if (!$hsmUrl || !\is_string($hsmUrl)) {
$output->writeln("<error>hsm.url not set</error>");
Expand Down Expand Up @@ -142,6 +142,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {

$decryptedStr = $response->getBody();
$output->writeln("decrypted string (base64 encoded): '".\base64_encode($decryptedStr)."'");
return 0;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions lib/Command/MigrateKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ protected function configure() {
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int|void
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output) {
protected function execute(InputInterface $input, OutputInterface $output): int {

// perform system reorganization
$migration = new Migration($this->config, $this->view, $this->connection, $this->logger);
Expand Down Expand Up @@ -127,5 +127,6 @@ protected function execute(InputInterface $input, OutputInterface $output) {
}

$migration->finalCleanUp();
return 0;
}
}
4 changes: 2 additions & 2 deletions lib/Command/RecreateMasterKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected function configure() {
* @return int
* @throws \Exception
*/
protected function execute(InputInterface $input, OutputInterface $output) {
protected function execute(InputInterface $input, OutputInterface $output): int {
$yes = $input->getOption('yes');
if ($this->util->isMasterKeyEnabled()) {
$question = new ConfirmationQuestion(
Expand Down Expand Up @@ -164,7 +164,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
* We are reusing the encryptAll code but not the decryptAll. The reason being
* decryptAll finishes by encrypting. Which is not what we want. This will make
* things out of scope for this command. We want first the entire oC FS to be
* decrypt. Then re-encrypt the entire oC FS with the new master key generated.
* decrypted. Then re-encrypt the entire oC FS with the new master key generated.
*/
$encryptAll->encryptAll($input, $output);

Expand Down