From 494c8375a6c15a71b4cb9df37f3215121967f268 Mon Sep 17 00:00:00 2001 From: Papuc Vasile <32643188+CaReS0107@users.noreply.github.com> Date: Thu, 22 Feb 2024 12:08:50 +0200 Subject: [PATCH] Prevent issue: $instance must not be accessed before initialization (#2578) * Prevent issue: must not be accessed before initialization * Fix styling * Fix styling --------- Co-authored-by: CaReS0107 --- src/SchedulerManager.php | 2 +- tests/Feature/Models/MailatorScheduleTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SchedulerManager.php b/src/SchedulerManager.php index af96cb01e7ae..2c9cca7f8208 100644 --- a/src/SchedulerManager.php +++ b/src/SchedulerManager.php @@ -24,7 +24,7 @@ public function run(): void public function __destruct() { - if (! $this->instance->wasRecentlyCreated) { + if ($this->instance && ! $this->instance->wasRecentlyCreated) { $this->instance->save(); } } diff --git a/tests/Feature/Models/MailatorScheduleTest.php b/tests/Feature/Models/MailatorScheduleTest.php index d16811f40383..6295b5738e10 100644 --- a/tests/Feature/Models/MailatorScheduleTest.php +++ b/tests/Feature/Models/MailatorScheduleTest.php @@ -62,7 +62,7 @@ public function test_can_use_carbon_target_date_before(): void // MailatorSchedule::run(); // Mail::assertNothingSent(); - + $this->travelTo(now()->addDays(6)); MailatorSchedule::run();