diff --git a/examples/ExampleCommand.php b/examples/ExampleCommand.php index f1d91f7..becb74a 100644 --- a/examples/ExampleCommand.php +++ b/examples/ExampleCommand.php @@ -23,7 +23,7 @@ protected function initialize(InputInterface $input, OutputInterface $output) } // Execute will be called in a endless loop - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { // Tell the user what we're going to do. // This will be silenced by Symfony if the user doesn't want any output at all, @@ -52,6 +52,8 @@ protected function execute(InputInterface $input, OutputInterface $output) // Tell the user we're done $output->writeln('done'); } + + return self::SUCCESS; } /** @@ -59,14 +61,14 @@ protected function execute(InputInterface $input, OutputInterface $output) * @param InputInterface $input * @param OutputInterface $output */ - protected function finishIteration(InputInterface $input, OutputInterface $output) + protected function finishIteration(InputInterface $input, OutputInterface $output): void { // Do some cleanup/memory management here, don't forget to call the parent implementation! parent::finishIteration($input, $output); } // Called once on shutdown after the last iteration finished - protected function finalize(InputInterface $input, OutputInterface $output) + protected function finalize(InputInterface $input, OutputInterface $output): void { // Do some cleanup here, don't forget to call the parent implementation! parent::finalize($input, $output); diff --git a/src/Wrep/Daemonizable/Command/EndlessCommand.php b/src/Wrep/Daemonizable/Command/EndlessCommand.php index 6eca842..eecb51f 100644 --- a/src/Wrep/Daemonizable/Command/EndlessCommand.php +++ b/src/Wrep/Daemonizable/Command/EndlessCommand.php @@ -244,7 +244,7 @@ public function setCode(callable $code): static * @throws LogicException When this abstract method is not implemented * @see setCode() */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { return parent::execute($input, $output); } diff --git a/tests/Wrep/Daemonizable/Command/EndlessCommandTest.php b/tests/Wrep/Daemonizable/Command/EndlessCommandTest.php index b829ab0..d91d3e4 100644 --- a/tests/Wrep/Daemonizable/Command/EndlessCommandTest.php +++ b/tests/Wrep/Daemonizable/Command/EndlessCommandTest.php @@ -110,8 +110,10 @@ public function testInterruptSigtermFromDifferentContext(): void */ class EndlessSelfTerminatingCommand extends EndlessCommand { - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { posix_kill(posix_getpid(), SIGTERM); + + return self::SUCCESS; } }