From 82d2e2c088e4eddbb79bf89d5c089622ff222722 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Tue, 2 Dec 2025 16:53:06 +0100 Subject: [PATCH] Replace deprecated methods and interfaces of react/promise - It is no longer possible to resolve a promise without a value (use null instead) - method otherwise() is deprecated, use catch() instead - (Extended|Cancellable)PromiseInterface are removed since v3.0.0 ref https://reactphp.org/promise/changelog.html#300-2023-07-11 --- application/clicommands/ScheduleCommand.php | 4 ++-- library/Reporting/Actions/SendMail.php | 2 +- library/Reporting/Schedule.php | 11 ++++------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/application/clicommands/ScheduleCommand.php b/application/clicommands/ScheduleCommand.php index f50d046b..7e09792f 100644 --- a/application/clicommands/ScheduleCommand.php +++ b/application/clicommands/ScheduleCommand.php @@ -18,7 +18,7 @@ use ipl\Scheduler\Contract\Task; use ipl\Scheduler\Scheduler; use React\EventLoop\Loop; -use React\Promise\ExtendedPromiseInterface; +use React\Promise\PromiseInterface; use Throwable; class ScheduleCommand extends Command @@ -121,7 +121,7 @@ protected function attachJobsLogging(Scheduler $scheduler) Logger::debug($e->getTraceAsString()); }); - $scheduler->on(Scheduler::ON_TASK_RUN, function (Task $job, ExtendedPromiseInterface $_) { + $scheduler->on(Scheduler::ON_TASK_RUN, function (Task $job, PromiseInterface $_) { Logger::info('Running job %s', $job->getName()); }); diff --git a/library/Reporting/Actions/SendMail.php b/library/Reporting/Actions/SendMail.php index 64f9d4b7..64265431 100644 --- a/library/Reporting/Actions/SendMail.php +++ b/library/Reporting/Actions/SendMail.php @@ -55,7 +55,7 @@ function ($pdf) use ($mail, $name, $recipients) { $mail->attachPdf($pdf, $name); $mail->send(null, $recipients); } - )->otherwise(function (Throwable $e) { + )->catch(function (Throwable $e) { Logger::error($e); Logger::debug($e->getTraceAsString()); }); diff --git a/library/Reporting/Schedule.php b/library/Reporting/Schedule.php index ddd8bd3a..55e04337 100644 --- a/library/Reporting/Schedule.php +++ b/library/Reporting/Schedule.php @@ -12,7 +12,7 @@ use Ramsey\Uuid\Uuid; use React\EventLoop\Loop; use React\Promise; -use React\Promise\ExtendedPromiseInterface; +use React\Promise\PromiseInterface; use function md5; @@ -128,7 +128,7 @@ public function getChecksum(): string ); } - public function run(): ExtendedPromiseInterface + public function run(): PromiseInterface { $deferred = new Promise\Deferred(); Loop::futureTick(function () use ($deferred) { @@ -144,12 +144,9 @@ public function run(): ExtendedPromiseInterface return; } - $deferred->resolve(); + $deferred->resolve(null); }); - /** @var ExtendedPromiseInterface $promise */ - $promise = $deferred->promise(); - - return $promise; + return $deferred->promise(); } }