Fix Carbon-related problems reported by PHPStan
[MAILPOET-2560]
This commit is contained in:
committed by
Jack Kitterhing
parent
cd01d5a948
commit
07fc94f046
@ -250,9 +250,9 @@ class Scheduler {
|
||||
$bounce_tasks = ScheduledTask::findFutureScheduledByType(Bounce::TASK_TYPE);
|
||||
if (count($bounce_tasks)) {
|
||||
$bounce_task = reset($bounce_tasks);
|
||||
if (Carbon::createFromTimestamp(current_time('timestamp'))->addHour(42)->lessThan($bounce_task->scheduled_at)) {
|
||||
if (Carbon::createFromTimestamp((int)current_time('timestamp'))->addHour(42)->lessThan($bounce_task->scheduled_at)) {
|
||||
$random_offset = rand(-6 * 60 * 60, 6 * 60 * 60);
|
||||
$bounce_task->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'))->addSecond((36 * 60 * 60) + $random_offset);
|
||||
$bounce_task->scheduled_at = Carbon::createFromTimestamp((int)current_time('timestamp'))->addSecond((36 * 60 * 60) + $random_offset);
|
||||
$bounce_task->save();
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ class ScheduledTask extends Model {
|
||||
|
||||
function rescheduleProgressively() {
|
||||
$scheduled_at = Carbon::createFromTimestamp($this->wp->currentTime('timestamp'));
|
||||
$timeout = min(self::BASIC_RESCHEDULE_TIMEOUT * pow(2, $this->reschedule_count), self::MAX_RESCHEDULE_TIMEOUT);
|
||||
$timeout = (int)min(self::BASIC_RESCHEDULE_TIMEOUT * pow(2, $this->reschedule_count), self::MAX_RESCHEDULE_TIMEOUT);
|
||||
$this->scheduled_at = $scheduled_at->addMinutes($timeout);
|
||||
$this->reschedule_count++;
|
||||
$this->status = ScheduledTask::STATUS_SCHEDULED;
|
||||
|
@ -25,11 +25,6 @@ parameters:
|
||||
count: 1
|
||||
path: %mailpoetDir%/lib/Cron/Workers/Scheduler.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$timestamp of static method Carbon\\\\Carbon\\:\\:createFromTimestamp\\(\\) expects int, int\\|string given\\.$#"
|
||||
count: 2
|
||||
path: %mailpoetDir%/lib/Cron/Workers/Scheduler.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$newsletter of method MailPoet\\\\Cron\\\\Workers\\\\StatsNotifications\\\\Scheduler\\:\\:schedule\\(\\) expects MailPoet\\\\Entities\\\\NewsletterEntity, MailPoet\\\\Entities\\\\NewsletterEntity\\|null given\\.$#"
|
||||
count: 1
|
||||
@ -150,11 +145,6 @@ parameters:
|
||||
count: 1
|
||||
path: %mailpoetDir%/lib/Models/ScheduledTask.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$value of method Carbon\\\\Carbon\\:\\:addMinutes\\(\\) expects int, float\\|int given\\.$#"
|
||||
count: 1
|
||||
path: %mailpoetDir%/lib/Models/ScheduledTask.php
|
||||
|
||||
-
|
||||
message: "#^Method MailPoet\\\\Models\\\\ScheduledTask\\:\\:findOneScheduledByNewsletterIdAndSubscriberId\\(\\) should return MailPoet\\\\Models\\\\ScheduledTask\\|null but returns MailPoet\\\\Models\\\\ScheduledTask\\|true\\|null\\.$#"
|
||||
count: 1
|
||||
|
Reference in New Issue
Block a user