From 5d5268c2c76a9fc0c1d11ad2d87cd3cc18aecdfe Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 4 Nov 2021 11:55:57 +0200 Subject: [PATCH] type fixes --- application/Espo/Core/Mail/EmailFactory.php | 5 ++++- application/Espo/Core/Mail/Importer.php | 6 ++++-- application/Espo/Core/Mail/Mail/Header/XQueueItemId.php | 3 +++ application/Espo/Core/Mail/Parsers/MailMimeParser.php | 1 + application/Espo/Core/Mail/Sender.php | 5 ++++- application/Espo/Core/Sms/SmsFactory.php | 5 ++++- 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/application/Espo/Core/Mail/EmailFactory.php b/application/Espo/Core/Mail/EmailFactory.php index 1740c28ab8..87156eca6d 100644 --- a/application/Espo/Core/Mail/EmailFactory.php +++ b/application/Espo/Core/Mail/EmailFactory.php @@ -49,6 +49,9 @@ class EmailFactory */ public function create(): Email { - return $this->entityManager->getNewEntity(Email::ENTITY_TYPE); + /** @var Email $email */ + $email = $this->entityManager->getNewEntity(Email::ENTITY_TYPE); + + return $email; } } diff --git a/application/Espo/Core/Mail/Importer.php b/application/Espo/Core/Mail/Importer.php index ef478a4165..30d9281113 100644 --- a/application/Espo/Core/Mail/Importer.php +++ b/application/Espo/Core/Mail/Importer.php @@ -100,10 +100,9 @@ class Importer $parser = $message->getParser() ?? $this->parserFactory->create(); + /** @var Email $email */ $email = $this->entityManager->getEntity('Email'); - assert($email instanceof Email); - $email->set('isBeingImported', true); $subject = ''; @@ -201,6 +200,7 @@ class Importer $duplicate = $this->findDuplicate($email); if ($duplicate && $duplicate->get('status') !== Email::STATUS_BEING_IMPORTED) { + /** @var Email $duplicate */ $duplicate = $this->entityManager->getEntity('Email', $duplicate->getId()); $this->processDuplicate( @@ -339,6 +339,7 @@ class Importer $this->entityManager->getLocker()->rollback(); if ($duplicate->get('status') !== Email::STATUS_BEING_IMPORTED) { + /** @var Email $duplicate */ $duplicate = $this->entityManager->getEntity('Email', $duplicate->getId()); $this->processDuplicate( @@ -618,6 +619,7 @@ class Importer return null; } + /** @var Email $duplicate */ $duplicate = $this->entityManager ->getRDBRepository('Email') ->select(['id', 'status']) diff --git a/application/Espo/Core/Mail/Mail/Header/XQueueItemId.php b/application/Espo/Core/Mail/Mail/Header/XQueueItemId.php index da27a6c2c4..6c7fda7985 100644 --- a/application/Espo/Core/Mail/Mail/Header/XQueueItemId.php +++ b/application/Espo/Core/Mail/Mail/Header/XQueueItemId.php @@ -43,6 +43,9 @@ class XQueueItemId implements Header\HeaderInterface protected $id = null; + /** + * @return self + */ public static function fromString($headerLine) { list($name, $value) = Header\GenericHeader::splitHeaderLine($headerLine); diff --git a/application/Espo/Core/Mail/Parsers/MailMimeParser.php b/application/Espo/Core/Mail/Parsers/MailMimeParser.php index 17fdf0317d..07620d6621 100644 --- a/application/Espo/Core/Mail/Parsers/MailMimeParser.php +++ b/application/Espo/Core/Mail/Parsers/MailMimeParser.php @@ -273,6 +273,7 @@ class MailMimeParser implements Parser continue; } + /** @var Attachment $attachment */ $attachment = $this->entityManager->getEntity('Attachment'); $contentType = $this->detectAttachmentContentType($attachmentPart); diff --git a/application/Espo/Core/Mail/Sender.php b/application/Espo/Core/Mail/Sender.php index 70f645feb7..347b669dc0 100644 --- a/application/Espo/Core/Mail/Sender.php +++ b/application/Espo/Core/Mail/Sender.php @@ -380,7 +380,8 @@ class Sender $address = $this->config->get('outboundEmailFromAddress'); if (!$this->systemInboundEmailIsCached && $address) { - $this->systemInboundEmail = $this->entityManager + /** @var ?InboundEmail $systemInboundEmail */ + $systemInboundEmail = $this->entityManager ->getRDBRepository('InboundEmail') ->where([ 'status' => 'Active', @@ -388,6 +389,8 @@ class Sender 'emailAddress' => $address, ]) ->findOne(); + + $this->systemInboundEmail = $systemInboundEmail; } $this->systemInboundEmailIsCached = true; diff --git a/application/Espo/Core/Sms/SmsFactory.php b/application/Espo/Core/Sms/SmsFactory.php index cec063c43b..21c0ce426f 100644 --- a/application/Espo/Core/Sms/SmsFactory.php +++ b/application/Espo/Core/Sms/SmsFactory.php @@ -49,6 +49,9 @@ class SmsFactory */ public function create(): SmsEntity { - return $this->entityManager->getNewEntity(SmsEntity::ENTITY_TYPE); + /** @var SmsEntity $sms */ + $sms = $this->entityManager->getNewEntity(SmsEntity::ENTITY_TYPE); + + return $sms; } }