Fixed some issues detected by PHPstan.

This commit is contained in:
Jan Böhmer 2020-02-01 17:00:03 +01:00
parent f2ff77a8b3
commit dd1f806c4e
30 changed files with 310 additions and 45 deletions

View file

@ -65,7 +65,7 @@ class CleanAttachmentsCommand extends Command
' These files are not needed and can eventually deleted.');
}
protected function execute(InputInterface $input, OutputInterface $output): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
@ -107,7 +107,7 @@ class CleanAttachmentsCommand extends Command
if (! $continue) {
//We are finished here, when no files should be deleted
return;
return 0;
}
//Delete the files
@ -119,6 +119,8 @@ class CleanAttachmentsCommand extends Command
} else {
$io->success('No abandoned files found.');
}
return 0;
}
/**

View file

@ -105,7 +105,7 @@ class ConvertBBCodeCommand extends Command
];
}
protected function execute(InputInterface $input, OutputInterface $output): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$targets = $this->getTargetsLists();
@ -168,5 +168,7 @@ class ConvertBBCodeCommand extends Command
$this->em->flush();
$io->success('Changes saved to DB successfully!');
}
return 0;
}
}

View file

@ -57,19 +57,19 @@ class SetPasswordCommand extends Command
;
}
protected function execute(InputInterface $input, OutputInterface $output): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$user_name = $input->getArgument('user');
/** @var User */
/** @var User[] $users */
$users = $this->entityManager->getRepository(User::class)->findBy(['name' => $user_name]);
$user = $users[0];
if (null === $user) {
$io->error(sprintf('No user with the given username %s found in the database!', $user_name));
return;
return 1;
}
$io->note('User found!');
@ -79,7 +79,7 @@ class SetPasswordCommand extends Command
$user->getFullName(true), $user->getID()));
if (! $proceed) {
return;
return 1;
}
$success = false;
@ -106,5 +106,6 @@ class SetPasswordCommand extends Command
$this->entityManager->flush();
$io->success('Password was set successful! You can now log in using the new password.');
return 0;
}
}

View file

@ -64,13 +64,13 @@ class ShowEventLogCommand extends Command
$onePage = $input->getOption('onePage');
$desc = $input->getOption('oldest_first');
$limit = $input->getOption('count');
$page = $input->getOption('page');
$desc = (bool) $input->getOption('oldest_first');
$limit = (int) $input->getOption('count');
$page = (int) $input->getOption('page');
$showExtra = $input->getOption('showExtra');
$total_count = $this->repo->count([]);
$max_page = ceil($total_count / $limit);
$max_page = (int) ceil($total_count / $limit);
if ($page > $max_page) {
$io->error("There is no page ${page}! The maximum page is ${max_page}.");

View file

@ -68,7 +68,7 @@ class UpdateExchangeRatesCommand extends Command
null);
}
protected function execute(InputInterface $input, OutputInterface $output): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
@ -76,7 +76,7 @@ class UpdateExchangeRatesCommand extends Command
if (3 !== strlen($this->base_current)) {
$io->error('Choosen Base current is not valid. Check your settings!');
return;
return 1;
}
$io->note('Update currency exchange rates with base currency: '.$this->base_current);
@ -121,5 +121,6 @@ class UpdateExchangeRatesCommand extends Command
$this->em->flush();
$io->success(sprintf('%d (of %d) currency exchange rates were updated.', $success_counter, count($candidates)));
return 0;
}
}