ENHANCEMENT: added return types

This commit is contained in:
Jeroen De Meerleer 2022-10-04 13:29:27 +02:00
parent 66bc095b81
commit 8dfe1118b3
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
6 changed files with 10 additions and 17 deletions

View File

@ -18,7 +18,6 @@ use Symfony\Component\HttpKernel\KernelInterface;
#[AsCommand(name: 'webcron:cleanup', description: 'Cleanup runs')]
class CleanupCommand extends Command
{
protected static $defaultName = 'webcron:cleanup';
protected $kernel;
protected $doctrine;
@ -36,19 +35,13 @@ class CleanupCommand extends Command
->addOption('maxage', 'm', InputOption::VALUE_REQUIRED, 'The maximum age of the oldest runs');
}
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output) : int
{
$maxage = $input->getOption('maxage');
$jobs = $input->getOption('jobid');
$runRepo = $this->doctrine->getRepository(Run::class);
try {
$deleted = $runRepo->cleanupRuns($jobs, $maxage);
$output->writeln('Deleted ' . $deleted . ' runs');
return Command::SUCCESS;
} catch(Exception $exception) {
$output->writeln($exception->getMessage());
return Command::FAILURE;
}
$deleted = $runRepo->cleanupRuns($jobs, $maxage);
$output->writeln('Deleted ' . $deleted . ' runs');
return Command::SUCCESS;
}
}

View File

@ -35,7 +35,7 @@ class DaemonCommand extends Command
->addOption('async', 'a', InputOption::VALUE_NEGATABLE, 'Time limit in seconds before stopping the daemon.');
}
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output) : int
{
$jobRepo = $this->doctrine->getRepository(Job::class);
$timelimit = $input->getOption('time-limit') ?? false;

View File

@ -37,7 +37,7 @@ class DemoInstallCommand extends Command
->setHelp('This command installs the demo data');
}
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output) : int
{
$em = $this->doctrine->getManager();

View File

@ -49,7 +49,7 @@ class MailFailedRunsCommand extends Command
* @throws \Twig\Error\SyntaxError
* @throws \Twig\Error\LoaderError
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output) : int
{
$jobRepo = $this->doctrine->getRepository(Job::class);

View File

@ -31,7 +31,7 @@ class RunCommand extends Command
->addArgument('jobid', InputArgument::REQUIRED, 'The id of the job to be run');
}
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output) : int
{
$jobRepo = $this->doctrine->getRepository(Job::class);
$jobId = (int)$input->getArgument('jobid');

View File

@ -56,7 +56,7 @@ class UserCommand extends Command
->addOption('password', 'p', InputOption::VALUE_OPTIONAL, 'What action should be executed? [add, delete, update]', '');
}
protected function initialize(InputInterface $input, OutputInterface $output)
protected function initialize(InputInterface $input, OutputInterface $output) : void
{
$this->action = $input->getArgument('action');
$this->username = $input->getOption('username');
@ -64,7 +64,7 @@ class UserCommand extends Command
$this->io = new SymfonyStyle($input, $output);
}
protected function interact(InputInterface $input, OutputInterface $output)
protected function interact(InputInterface $input, OutputInterface $output) : void
{
if(!empty($this->password)) {
$this->io->warning('It is not safe to send password directly via STDIN');
@ -117,7 +117,7 @@ class UserCommand extends Command
}
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output) : int
{
switch ($this->action) {
case 'add':