Remove phpstan errors from the rest of the code
[MAILPOET-3235]
This commit is contained in:
@ -91,6 +91,7 @@ class PurchasedProduct {
|
||||
}
|
||||
|
||||
$woocommerceProducts = array_map(function($product) {
|
||||
assert($product instanceof \WP_Post);
|
||||
return [
|
||||
'id' => $product->ID,
|
||||
'name' => $product->post_title, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
|
@ -968,6 +968,7 @@ class MP2Migrator {
|
||||
$segmentsIds = implode(',', $segments);
|
||||
return '[mailpoet_subscribers_count segments=' . $segmentsIds . ']';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -12,7 +12,7 @@ class DaemonHttpRunner {
|
||||
public $timer;
|
||||
public $token;
|
||||
|
||||
/** @var Daemon */
|
||||
/** @var Daemon|null */
|
||||
private $daemon;
|
||||
|
||||
/** @var CronHelper */
|
||||
@ -69,6 +69,9 @@ class DaemonHttpRunner {
|
||||
if (!empty($error)) {
|
||||
return $this->abortWithError($error);
|
||||
}
|
||||
if ($this->daemon === null) {
|
||||
return $this->abortWithError(WPFunctions::get()->__('Daemon does not set correctly.', 'mailpoet'));
|
||||
}
|
||||
$this->settingsDaemonData['token'] = $this->token;
|
||||
$this->daemon->run($this->settingsDaemonData);
|
||||
// If we're using the WordPress trigger, check the conditions to stop cron if necessary
|
||||
|
@ -8,6 +8,7 @@ use MailPoet\Cron\Workers\SendingQueue\Tasks\Links;
|
||||
use MailPoet\Cron\Workers\SendingQueue\Tasks\Mailer as MailerTask;
|
||||
use MailPoet\Cron\Workers\SendingQueue\Tasks\Newsletter as NewsletterTask;
|
||||
use MailPoet\Cron\Workers\StatsNotifications\Scheduler as StatsNotificationsScheduler;
|
||||
use MailPoet\Entities\NewsletterEntity;
|
||||
use MailPoet\Logging\LoggerFactory;
|
||||
use MailPoet\Mailer\MailerError;
|
||||
use MailPoet\Mailer\MailerLog;
|
||||
@ -167,7 +168,9 @@ class SendingQueue {
|
||||
['newsletter_id' => $newsletter->id, 'task_id' => $queue->taskId]
|
||||
);
|
||||
$this->newsletterTask->markNewsletterAsSent($newsletter, $queue);
|
||||
$this->statsNotificationsScheduler->schedule($this->newslettersRepository->findOneById($newsletter->id));
|
||||
$newsletter = $this->newslettersRepository->findOneById($newsletter->id);
|
||||
assert($newsletter instanceof NewsletterEntity);
|
||||
$this->statsNotificationsScheduler->schedule($newsletter);
|
||||
}
|
||||
$this->enforceSendingAndExecutionLimits($timer);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ use MailPoet\Cron\CronHelper;
|
||||
use MailPoet\Entities\NewsletterEntity;
|
||||
use MailPoet\Entities\NewsletterLinkEntity;
|
||||
use MailPoet\Entities\ScheduledTaskEntity;
|
||||
use MailPoet\Entities\SendingQueueEntity;
|
||||
use MailPoet\Entities\StatsNotificationEntity;
|
||||
use MailPoet\Mailer\Mailer;
|
||||
use MailPoet\Mailer\MetaInfo;
|
||||
@ -117,8 +118,12 @@ class Worker {
|
||||
throw new \RuntimeException('Missing newsletter entity for statistic notification.');
|
||||
}
|
||||
$link = $this->newsletterLinkRepository->findTopLinkForNewsletter((int)$newsletter->getId());
|
||||
$context = $this->prepareContext($newsletter, $link);
|
||||
$subject = $newsletter->getLatestQueue()->getNewsletterRenderedSubject();
|
||||
$sendingQueue = $newsletter->getLatestQueue();
|
||||
if (!$sendingQueue instanceof SendingQueueEntity) {
|
||||
throw new \RuntimeException('Missing sending queue entity for statistic notification.');
|
||||
}
|
||||
$context = $this->prepareContext($newsletter, $sendingQueue, $link);
|
||||
$subject = $sendingQueue->getNewsletterRenderedSubject();
|
||||
return [
|
||||
'subject' => sprintf(_x('Stats for email %s', 'title of an automatic email containing statistics (newsletter open rate, click rate, etc)', 'mailpoet'), $subject),
|
||||
'body' => [
|
||||
@ -128,12 +133,12 @@ class Worker {
|
||||
];
|
||||
}
|
||||
|
||||
private function prepareContext(NewsletterEntity $newsletter, NewsletterLinkEntity $link = null) {
|
||||
private function prepareContext(NewsletterEntity $newsletter, SendingQueueEntity $sendingQueue, NewsletterLinkEntity $link = null) {
|
||||
$statistics = $this->newsletterStatisticsRepository->getStatistics($newsletter);
|
||||
$clicked = ($statistics->getClickCount() * 100) / $statistics->getTotalSentCount();
|
||||
$opened = ($statistics->getOpenCount() * 100) / $statistics->getTotalSentCount();
|
||||
$unsubscribed = ($statistics->getUnsubscribeCount() * 100) / $statistics->getTotalSentCount();
|
||||
$subject = $newsletter->getLatestQueue()->getNewsletterRenderedSubject();
|
||||
$subject = $sendingQueue->getNewsletterRenderedSubject();
|
||||
$subscribersCount = $this->subscribersRepository->getTotalSubscribers();
|
||||
$hasValidApiKey = $this->subscribersFeature->hasValidApiKey();
|
||||
$context = [
|
||||
|
@ -373,6 +373,9 @@ class ContainerConfigurator implements IContainerConfigurator {
|
||||
}
|
||||
|
||||
public static function getPremiumService($id, ContainerInterface $container = null) {
|
||||
if ($container === null) {
|
||||
return null;
|
||||
}
|
||||
if (!$container->has(IContainerConfigurator::PREMIUM_CONTAINER_SERVICE_SLUG)) {
|
||||
return null;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class TablePrefixMetadataFactory extends ClassMetadataFactory {
|
||||
|
||||
// prefix tables only after they are saved to cache so the prefix does not get included in cache
|
||||
// (getMetadataFor can call itself recursively but it saves to cache only after the recursive calls)
|
||||
$isCached = $this->getCacheDriver()->contains($classMetadata->getName() . $this->cacheSalt);
|
||||
$isCached = ($cache = $this->getCacheDriver()) ? $cache->contains($classMetadata->getName() . $this->cacheSalt) : false;
|
||||
if ($classMetadata instanceof ClassMetadata && $isCached) {
|
||||
$this->addPrefix($classMetadata);
|
||||
$this->prefixedMap[$classMetadata->getName()] = true;
|
||||
|
@ -73,12 +73,12 @@ class Links {
|
||||
$linkToReplace = $processedLink['link'];
|
||||
$replacementLink = $processedLink['processed_link'];
|
||||
if ($processedLink['type'] == self::LINK_TYPE_SHORTCODE) {
|
||||
$content = str_replace($linkToReplace, $replacementLink, $content);
|
||||
$content = str_replace($linkToReplace, $replacementLink, (string)$content);
|
||||
}
|
||||
$content = preg_replace(
|
||||
'/\[(.*?)\](\(' . preg_quote($linkToReplace, '/') . '\))/',
|
||||
'[$1](' . $replacementLink . ')',
|
||||
$content
|
||||
(string)$content
|
||||
);
|
||||
}
|
||||
return [
|
||||
|
@ -12,6 +12,7 @@ class DOM {
|
||||
*/
|
||||
public static function splitOn(DomNode $bound, DomNode $cutElement) {
|
||||
$ignoreTextAndCommentNodes = false;
|
||||
$grandparent = $cutElement->parent;
|
||||
for ($parent = $cutElement->parent; $bound != $parent; $parent = $grandparent) {
|
||||
// Clone parent node without children, but with attributes
|
||||
$parent->after($parent->toString());
|
||||
@ -23,6 +24,7 @@ class DOM {
|
||||
}
|
||||
|
||||
// Reattach cut_element and right siblings to grandparent
|
||||
/* @phpstan-ignore-next-line Because there is a wrong annotation in the library tburry/pquery */
|
||||
$grandparent = $parent->parent;
|
||||
$indexAfterParent = $parent->index() + 1;
|
||||
$right->move($grandparent, $indexAfterParent);
|
||||
|
Reference in New Issue
Block a user