This commit is contained in:
Yuri Kuznetsov
2021-11-05 12:33:36 +02:00
parent f0237005c0
commit 6cc19a52f1
11 changed files with 41 additions and 46 deletions

View File

@@ -165,10 +165,8 @@ class Parser
}
else {
if (!$isLineComment && !$isComment) {
if (!$isComment) {
if ($i && $string[$i] === '/' && $string[$i - 1] === '/') {
$isLineComment = true;
}
if ($i && $string[$i] === '/' && $string[$i - 1] === '/') {
$isLineComment = true;
}
if (!$isLineComment) {

View File

@@ -82,6 +82,8 @@ class TemplateRenderer
*/
public function setData($data): self
{
/** @var mixed $data */
if (!is_array($data) && !$data instanceof stdClass) {
throw new InvalidArgumentException();
}

View File

@@ -343,7 +343,7 @@ class InjectableFactory
$params = $class->getMethod($methodName)->getParameters();
if (!$params || !count($params)) {
if (!count($params)) {
return false;
}

View File

@@ -55,6 +55,8 @@ class Data
*/
public static function create($data = null): self
{
/** @var mixed $data */
if ($data !== null && !is_object($data) && !is_array($data)) {
throw new TypeError();
}

View File

@@ -99,7 +99,7 @@ class JobRunner
throw new Error();
}
/** @var JobEntity $jobEntity */
/** @var JobEntity|null $jobEntity */
$jobEntity = $this->entityManager->getEntity(JobEntity::ENTITY_TYPE, $id);
if (!$jobEntity) {
@@ -118,7 +118,6 @@ class JobRunner
private function runInternal(JobEntity $jobEntity, bool $throwException = false): void
{
$isSuccess = true;
$skipLog = false;
$exception = null;
@@ -172,7 +171,7 @@ class JobRunner
throw new $exception($exception->getMessage());
}
if ($jobEntity->getScheduledJobId() && !$skipLog) {
if ($jobEntity->getScheduledJobId()) {
$this->scheduleUtil->addLogRecord(
$jobEntity->getScheduledJobId(),
$status,

View File

@@ -156,6 +156,8 @@ class JobScheduler
*/
public function setData($data): self
{
/** @var mixed $data */
if (!is_null($data) && !is_array($data) && !$data instanceof Data) {
throw new TypeError();
}

View File

@@ -91,7 +91,7 @@ class ScheduleUtil
$runTime = date(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT);
}
/** @var ScheduledJobEntity $scheduledJob */
/** @var ScheduledJobEntity|null $scheduledJob */
$scheduledJob = $this->entityManager->getEntity(ScheduledJobEntity::ENTITY_TYPE, $scheduledJobId);
if (!$scheduledJob) {

View File

@@ -218,11 +218,9 @@ class Importer
try {
$dt = new DateTime($parser->getMessageAttribute($message, 'date'));
if ($dt) {
$dateSent = $dt->setTimezone(new DateTimeZone('UTC'))->format('Y-m-d H:i:s');
$dateSent = $dt->setTimezone(new DateTimeZone('UTC'))->format('Y-m-d H:i:s');
$email->set('dateSent', $dateSent);
}
$email->set('dateSent', $dateSent);
}
catch (Exception $e) {}
}
@@ -234,11 +232,9 @@ class Importer
try {
$dt = new DateTime($parser->getMessageAttribute($message, 'delivery-Date'));
if ($dt) {
$deliveryDate = $dt->setTimezone(new DateTimeZone('UTC'))->format('Y-m-d H:i:s');
$deliveryDate = $dt->setTimezone(new DateTimeZone('UTC'))->format('Y-m-d H:i:s');
$email->set('delivery-Date', $deliveryDate);
}
$email->set('delivery-Date', $deliveryDate);
}
catch (Exception $e) {}
}
@@ -272,7 +268,7 @@ class Importer
$inReplyTo = '<' . $inReplyTo . '>';
}
/** @var Email $replied */
/** @var Email|null $replied */
$replied = $this->entityManager
->getRDBRepository('Email')
->where([

View File

@@ -29,6 +29,8 @@
namespace Espo\Core\Mail\Parsers;
use Psr\Http\Message\StreamInterface;
use Espo\Entities\{
Email,
Attachment,
@@ -134,7 +136,7 @@ class MailMimeParser implements Parser
return null;
}
if ($messageId && strlen($messageId) && $messageId[0] !== '<') {
if ($messageId[0] !== '<') {
$messageId = '<' . $messageId . '>';
}
@@ -280,6 +282,7 @@ class MailMimeParser implements Parser
$disposition = $attachmentPart->getHeaderValue('Content-Disposition');
/** @var string|null $filename */
$filename = $attachmentPart->getHeaderParameter('Content-Disposition', 'filename', null);
if ($filename === null) {
@@ -295,6 +298,7 @@ class MailMimeParser implements Parser
$content = '';
/** @var StreamInterface|null $binaryContentStream */
$binaryContentStream = $attachmentPart->getBinaryContentStream();
if ($binaryContentStream) {
@@ -353,7 +357,7 @@ class MailMimeParser implements Parser
$email->set('body', $body);
}
/* @var $textCalendarPart MessagePart */
/** @var MessagePart|null $textCalendarPart */
$textCalendarPart =
$this->getMessage($message)->getAllPartsByMimeType('text/calendar')[0] ??
$this->getMessage($message)->getAllPartsByMimeType('application/ics')[0] ??
@@ -385,6 +389,7 @@ class MailMimeParser implements Parser
private function getAttachmentFilenameExtension(MimePart $part): ?string
{
/** @var string|null $filename */
$filename = $part->getHeaderParameter('Content-Disposition', 'filename', null);
if ($filename === null) {

View File

@@ -338,13 +338,11 @@ class Sender
if ($inboundEmail) {
$service = $this->getInboundEmailService();
if ($service) {
$params = $service->getSmtpParamsFromAccount($inboundEmail);
$params = $service->getSmtpParamsFromAccount($inboundEmail);
$this->applySmtp($params);
$this->applySmtp($params);
return;
}
return;
}
}
@@ -398,12 +396,8 @@ class Sender
return $this->systemInboundEmail;
}
private function getInboundEmailService(): ?InboundEmailService
private function getInboundEmailService(): InboundEmailService
{
if (!$this->serviceFactory) {
return null;
}
if (!$this->inboundEmailService) {
$this->inboundEmailService = $this->serviceFactory->create('InboundEmail');
}

View File

@@ -107,23 +107,20 @@ class Helper
}
return implode(' ', $arr);
default:
if (!$first && !$last) {
return null;
}
if (!$first) {
return $last;
}
if (!$last) {
return $first;
}
return $first . ' ' . $last;
}
return null;
if (!$first && !$last) {
return null;
}
if (!$first) {
return $last;
}
if (!$last) {
return $first;
}
return $first . ' ' . $last;
}
}