Fix phpstan level 6

[MAILPOET-1969]
This commit is contained in:
Pavel Dohnal
2019-04-09 13:46:03 +02:00
committed by M. Shull
parent 46a0b7501b
commit 3e66e9e1dd
36 changed files with 320 additions and 244 deletions

View File

@@ -121,7 +121,9 @@ class Newsletter {
if (!$queue_errors) {
// verify that the rendered body was successfully saved
$queue = SendingQueueModel::findOne($queue->id);
$queue_errors = ($queue->validate() !== true);
if ($queue instanceof SendingQueueModel) {
$queue_errors = ($queue->validate() !== true);
}
}
if ($queue_errors) {
$this->stopNewsletterPreProcessing(sprintf('QUEUE-%d-SAVE', $queue->id));

View File

@@ -9,6 +9,7 @@ use MailPoet\Mailer\Mailer;
use MailPoet\Models\Newsletter;
use MailPoet\Models\NewsletterLink;
use MailPoet\Models\ScheduledTask;
use MailPoet\Models\StatsNotification;
use MailPoet\Settings\SettingsController;
use MailPoet\Tasks\Sending;
use MailPoet\WP\Functions as WPFunctions;
@@ -81,8 +82,11 @@ class Worker {
private function getNewsletter(ScheduledTask $task) {
$statsNotificationModel = $task->statsNotification()->findOne();
if (!$statsNotificationModel instanceof StatsNotification) {
throw new \Exception('Newsletter not found');
}
$newsletter = $statsNotificationModel->newsletter()->findOne();
if (!$newsletter) {
if (!$newsletter instanceof Newsletter) {
throw new \Exception('Newsletter not found');
}
return $newsletter