From c6c60fb47a0618b8c318e6e5afc49bc6ae9163e6 Mon Sep 17 00:00:00 2001 From: Abdelhamid Errahmouni Date: Tue, 7 Oct 2025 16:07:14 +0100 Subject: [PATCH 1/2] Refactor lastReceivedAt type to support CarbonImmutable --- src/Commands/HandleMessageReceived.php | 3 ++- src/Events/MailboxWatchAttemptsExceeded.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Commands/HandleMessageReceived.php b/src/Commands/HandleMessageReceived.php index b4c98c2..19fc0c6 100644 --- a/src/Commands/HandleMessageReceived.php +++ b/src/Commands/HandleMessageReceived.php @@ -2,6 +2,7 @@ namespace DirectoryTree\ImapEngine\Laravel\Commands; +use Carbon\CarbonImmutable; use DirectoryTree\ImapEngine\Laravel\Events\MessageReceived; use DirectoryTree\ImapEngine\MessageInterface; use Illuminate\Support\Carbon; @@ -16,7 +17,7 @@ class HandleMessageReceived public function __construct( protected WatchMailbox $command, protected int &$attempts = 0, - protected ?Carbon &$lastReceivedAt = null, + protected null|Carbon|CarbonImmutable &$lastReceivedAt = null, ) {} /** diff --git a/src/Events/MailboxWatchAttemptsExceeded.php b/src/Events/MailboxWatchAttemptsExceeded.php index 5c61262..1b9cbc8 100644 --- a/src/Events/MailboxWatchAttemptsExceeded.php +++ b/src/Events/MailboxWatchAttemptsExceeded.php @@ -3,6 +3,7 @@ namespace DirectoryTree\ImapEngine\Laravel\Events; use Carbon\Carbon; +use Carbon\CarbonImmutable; use Exception; class MailboxWatchAttemptsExceeded @@ -14,6 +15,6 @@ public function __construct( public string $mailbox, public int $attempts, public Exception $exception, - public ?Carbon $lastReceivedAt = null, + public null|Carbon|CarbonImmutable $lastReceivedAt = null, ) {} } From d1e395b17f6983f2dcbe00b9c95b0f9cd1847d50 Mon Sep 17 00:00:00 2001 From: Steve Bauman Date: Tue, 7 Oct 2025 16:22:53 -0400 Subject: [PATCH 2/2] Use CarbonInterface --- src/Commands/HandleMessageReceived.php | 5 ++--- src/Events/MailboxWatchAttemptsExceeded.php | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Commands/HandleMessageReceived.php b/src/Commands/HandleMessageReceived.php index 19fc0c6..26c6023 100644 --- a/src/Commands/HandleMessageReceived.php +++ b/src/Commands/HandleMessageReceived.php @@ -2,10 +2,9 @@ namespace DirectoryTree\ImapEngine\Laravel\Commands; -use Carbon\CarbonImmutable; +use Carbon\CarbonInterface; use DirectoryTree\ImapEngine\Laravel\Events\MessageReceived; use DirectoryTree\ImapEngine\MessageInterface; -use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Date; use Illuminate\Support\Facades\Event; @@ -17,7 +16,7 @@ class HandleMessageReceived public function __construct( protected WatchMailbox $command, protected int &$attempts = 0, - protected null|Carbon|CarbonImmutable &$lastReceivedAt = null, + protected ?CarbonInterface &$lastReceivedAt = null, ) {} /** diff --git a/src/Events/MailboxWatchAttemptsExceeded.php b/src/Events/MailboxWatchAttemptsExceeded.php index 1b9cbc8..f0e88c5 100644 --- a/src/Events/MailboxWatchAttemptsExceeded.php +++ b/src/Events/MailboxWatchAttemptsExceeded.php @@ -2,8 +2,7 @@ namespace DirectoryTree\ImapEngine\Laravel\Events; -use Carbon\Carbon; -use Carbon\CarbonImmutable; +use Carbon\CarbonInterface; use Exception; class MailboxWatchAttemptsExceeded @@ -15,6 +14,6 @@ public function __construct( public string $mailbox, public int $attempts, public Exception $exception, - public null|Carbon|CarbonImmutable $lastReceivedAt = null, + public ?CarbonInterface $lastReceivedAt = null, ) {} }