From b234ce576234ade7ff1f1eb8249f8dd88c855004 Mon Sep 17 00:00:00 2001 From: gontsov Date: Thu, 6 Aug 2026 15:37:19 +0500 Subject: [PATCH 1/2] feat: php8.5 support --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 008c6bc..c28a246 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "laravel" ], "require": { - "php": "8.2.*|8.3.*|8.4.*", + "php": "8.2.*|8.3.*|8.4.*|8.5.*", "ext-json": "*", "ext-pcntl": "*", "bensampo/laravel-enum": "^3.0|^4.0|^5.0|^6.0", From 8d405639b23535a2bf37d6bccd1e623742b8163c Mon Sep 17 00:00:00 2001 From: gontsov Date: Thu, 6 Aug 2026 15:41:49 +0500 Subject: [PATCH 2/2] fix: Carbon 3 support in commands promise:watch and promise:gc --- src/Core/GarbageCollector.php | 2 +- src/Core/PromiseWatcher.php | 2 +- src/Core/Support/DaemonWorker.php | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Core/GarbageCollector.php b/src/Core/GarbageCollector.php index 4dd5258..73ab365 100644 --- a/src/Core/GarbageCollector.php +++ b/src/Core/GarbageCollector.php @@ -42,7 +42,7 @@ public function __construct( $this->promiseChunkSize = $promiseChunkSize; $this->jobsChunkSize = $jobsChunkSize; - $this->lastIteration = Carbon::minValue(); + $this->lastIteration = $this->startOfTime(); } /** diff --git a/src/Core/PromiseWatcher.php b/src/Core/PromiseWatcher.php index 3a53bc5..3ec531f 100644 --- a/src/Core/PromiseWatcher.php +++ b/src/Core/PromiseWatcher.php @@ -26,7 +26,7 @@ public function __construct( private readonly int $promiseChunkSize = 100, ) { $this->sleepTime = $sleepTime; - $this->lastIteration = Carbon::minValue(); + $this->lastIteration = $this->startOfTime(); } public function watch(?callable $shouldQuitCallback = null, ?callable $shouldPausedCallback = null): void diff --git a/src/Core/Support/DaemonWorker.php b/src/Core/Support/DaemonWorker.php index 11ee3ee..b5bac86 100644 --- a/src/Core/Support/DaemonWorker.php +++ b/src/Core/Support/DaemonWorker.php @@ -3,11 +3,12 @@ namespace Tochka\Promises\Core\Support; use Carbon\Carbon; +use Carbon\CarbonImmutable; trait DaemonWorker { private int $sleepTime; - private Carbon $lastIteration; + private CarbonImmutable $lastIteration; /** * @param callable $callback @@ -37,7 +38,7 @@ public function daemon(callable $callback, ?callable $shouldQuitCallback = null, $callback(); - $this->lastIteration = Carbon::now(); + $this->lastIteration = $this->startOfTime(); } } @@ -63,4 +64,11 @@ private function sleepAfterLastIteration(): bool { return $this->lastIteration > Carbon::now()->subSeconds($this->sleepTime); } + + private function startOfTime(): CarbonImmutable + { + return method_exists(CarbonImmutable::class, 'startOfTime') + ? CarbonImmutable::startOfTime() + : Carbon::minValue()->toImmutable(); + } }