diff --git a/application/Espo/Core/Acl/Table/DefaultRoleListProvider.php b/application/Espo/Core/Acl/Table/DefaultRoleListProvider.php index 8cedf7ab97..6d08c59a4f 100644 --- a/application/Espo/Core/Acl/Table/DefaultRoleListProvider.php +++ b/application/Espo/Core/Acl/Table/DefaultRoleListProvider.php @@ -47,12 +47,13 @@ class DefaultRoleListProvider implements RoleListProvider } /** - * @return array + * @return Role[] */ public function get(): array { $roleList = []; + /** @var iterable */ $userRoleList = $this->entityManager ->getRDBRepository('User') ->getRelation($this->user, 'roles') @@ -69,6 +70,7 @@ class DefaultRoleListProvider implements RoleListProvider ->find(); foreach ($teamList as $team) { + /** @var iterable */ $teamRoleList = $this->entityManager ->getRDBRepository('Team') ->getRelation($team, 'roles') diff --git a/application/Espo/Core/ExternalAccount/ClientManager.php b/application/Espo/Core/ExternalAccount/ClientManager.php index 1a5d910eec..1b22d0e066 100644 --- a/application/Espo/Core/ExternalAccount/ClientManager.php +++ b/application/Espo/Core/ExternalAccount/ClientManager.php @@ -34,8 +34,9 @@ use Espo\Core\Exceptions\Error; use Espo\Entities\Integration as IntegrationEntity; use Espo\Entities\ExternalAccount as ExternalAccountEntity; +use Espo\ORM\EntityManager; + use Espo\Core\{ - ORM\EntityManager, Utils\Metadata, Utils\Config, InjectableFactory, diff --git a/application/Espo/Core/Portal/Acl/Table/RoleListProvider.php b/application/Espo/Core/Portal/Acl/Table/RoleListProvider.php index 460fb078aa..d456715fac 100644 --- a/application/Espo/Core/Portal/Acl/Table/RoleListProvider.php +++ b/application/Espo/Core/Portal/Acl/Table/RoleListProvider.php @@ -65,6 +65,7 @@ class RoleListProvider implements RoleListProviderInterface { $roleList = []; + /** @var iterable */ $userRoleList = $this->entityManager ->getRDBRepository('User') ->getRelation($this->user, 'portalRoles') @@ -74,6 +75,7 @@ class RoleListProvider implements RoleListProviderInterface $roleList[] = $role; } + /** @var iterable */ $portalRoleList = $this->entityManager ->getRDBRepository('Portal') ->getRelation($this->portal, 'portalRoles') diff --git a/application/Espo/Core/Utils/Database/Schema/Converter.php b/application/Espo/Core/Utils/Database/Schema/Converter.php index 9ab0558316..a52f192e00 100644 --- a/application/Espo/Core/Utils/Database/Schema/Converter.php +++ b/application/Espo/Core/Utils/Database/Schema/Converter.php @@ -406,6 +406,7 @@ class Converter } if (!empty($uniqueIndex)) { + /** @var string[] $uniqueIndex */ $uniqueIndexName = implode('_', $uniqueIndex); $table->addUniqueIndex( diff --git a/application/Espo/Modules/Crm/Services/Campaign.php b/application/Espo/Modules/Crm/Services/Campaign.php index 0a2d5ab779..bce5a00a55 100644 --- a/application/Espo/Modules/Crm/Services/Campaign.php +++ b/application/Espo/Modules/Crm/Services/Campaign.php @@ -389,6 +389,7 @@ class Campaign extends \Espo\Services\Record implements $metTargetHash = []; $targetEntityList = []; + /** @var iterable<\Espo\Modules\Crm\Entities\TargetList> */ $excludingTargetListList = $this->getEntityManager() ->getRDBRepository('Campaign') ->getRelation($campaign, 'excludingTargetLists') @@ -408,6 +409,7 @@ class Campaign extends \Espo\Services\Record implements $addressFieldList = $this->entityTypeAddressFieldListMap[$targetEntityType]; + /** @var iterable<\Espo\Modules\Crm\Entities\TargetList> */ $targetListCollection = $this->getEntityManager() ->getRDBRepository('Campaign') ->getRelation($campaign, 'targetLists') diff --git a/application/Espo/Modules/Crm/Services/CaseObj.php b/application/Espo/Modules/Crm/Services/CaseObj.php index c630db0ccc..19bd874428 100644 --- a/application/Espo/Modules/Crm/Services/CaseObj.php +++ b/application/Espo/Modules/Crm/Services/CaseObj.php @@ -35,7 +35,7 @@ use Espo\{ Modules\Crm\Entities\CaseObj as CaseEntity, }; -use StdClass; +use stdClass; class CaseObj extends Record { @@ -85,6 +85,7 @@ class CaseObj extends Record public function getEmailAddressList(string $id): array { + /** @var CaseEntity */ $entity = $this->getEntity($id); $forbiddenFieldList = $this->acl->getScopeForbiddenFieldList($this->getEntityType()); @@ -129,7 +130,7 @@ class CaseObj extends Record return $list; } - protected function getAccountEmailAddress(CaseEntity $entity, array $dataList): ?StdClass + protected function getAccountEmailAddress(CaseEntity $entity, array $dataList): ?stdClass { $account = $this->entityManager->getEntity('Account', $entity->get('accountId')); @@ -156,7 +157,7 @@ class CaseObj extends Record ]; } - protected function getLeadEmailAddress(CaseEntity $entity, array $dataList): ?StdClass + protected function getLeadEmailAddress(CaseEntity $entity, array $dataList): ?stdClass { $lead = $this->entityManager->getEntity('Account', $entity->get('leadId')); diff --git a/application/Espo/Modules/Crm/Services/MassEmail.php b/application/Espo/Modules/Crm/Services/MassEmail.php index 3bcbf2d407..a72d45db03 100644 --- a/application/Espo/Modules/Crm/Services/MassEmail.php +++ b/application/Espo/Modules/Crm/Services/MassEmail.php @@ -29,6 +29,8 @@ namespace Espo\Modules\Crm\Services; +use Espo\Modules\Crm\Entities\MassEmail as MassEmailEntity; + use Espo\Core\{ Exceptions\Forbidden, Exceptions\BadRequest, @@ -118,14 +120,14 @@ class MassEmail extends RecordService $this->processTestSending($massEmail); } - protected function createTestQueue(Entity $massEmail, iterable $targetList): void + protected function createTestQueue(MassEmailEntity $massEmail, iterable $targetList): void { $queue = $this->injectableFactory->create(Queue::class); $queue->create($massEmail, true, $targetList); } - protected function processTestSending(Entity $massEmail): void + protected function processTestSending(MassEmailEntity $massEmail): void { $processor = $this->injectableFactory->create(Processor::class); diff --git a/application/Espo/Modules/Crm/Services/Opportunity.php b/application/Espo/Modules/Crm/Services/Opportunity.php index bab0786a16..e4f7a4ded7 100644 --- a/application/Espo/Modules/Crm/Services/Opportunity.php +++ b/application/Espo/Modules/Crm/Services/Opportunity.php @@ -364,11 +364,11 @@ class Opportunity extends Record $dtTo = new DateTime($dateTo); if (intval($dtTo->format('d')) !== 1) { - $dtTo->setDate($dtTo->format('Y'), $dtTo->format('m'), 1); + $dtTo->setDate((int) $dtTo->format('Y'), (int) $dtTo->format('m'), 1); $dtTo->modify('+ 1 month'); } else { - $dtTo->setDate($dtTo->format('Y'), $dtTo->format('m'), 1); + $dtTo->setDate((int) $dtTo->format('Y'), (int) $dtTo->format('m'), 1); } $interval = new DateInterval('P1M'); @@ -559,6 +559,7 @@ class Opportunity extends Record public function getEmailAddressList(string $id): array { + /** @var OpportunityEntity */ $entity = $this->getEntity($id); $forbiddenFieldList = $this->acl->getScopeForbiddenFieldList($this->getEntityType()); diff --git a/application/Espo/ORM/Query/SelectingBuilderTrait.php b/application/Espo/ORM/Query/SelectingBuilderTrait.php index 5fcfcb5388..237dfbcacd 100644 --- a/application/Espo/ORM/Query/SelectingBuilderTrait.php +++ b/application/Espo/ORM/Query/SelectingBuilderTrait.php @@ -113,7 +113,7 @@ trait SelectingBuilderTrait * Passing an array will reset a previously set order. * @param string|bool|null $direction OrderExpression::ASC|OrderExpression::DESC. * - * @phpstan-param Order|Order[]|Expression|string|array $orderBy + * @phpstan-param Order|Order[]|Expression|string|array|string[] $orderBy */ public function order($orderBy, $direction = null): self { diff --git a/application/Espo/ORM/Repository/RDBRelation.php b/application/Espo/ORM/Repository/RDBRelation.php index 31b686eaf8..22aca05bbd 100644 --- a/application/Espo/ORM/Repository/RDBRelation.php +++ b/application/Espo/ORM/Repository/RDBRelation.php @@ -286,7 +286,7 @@ class RDBRelation * Passing an array will reset a previously set order. * @param string|bool|null $direction Select::ORDER_ASC|Select::ORDER_DESC. * - * @phpstan-param Order|Order[]|Expression|string|array $orderBy + * @phpstan-param Order|Order[]|Expression|string|array|string[] $orderBy */ public function order($orderBy = 'id', $direction = null): Builder { diff --git a/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php b/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php index 715c936e35..30e8ad45fa 100644 --- a/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php +++ b/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php @@ -357,7 +357,7 @@ class RDBRelationSelectBuilder * Passing an array will reset a previously set order. * @param string|bool|null $direction Select::ORDER_ASC|Select::ORDER_DESC. * - * @phpstan-param Order|Order[]|Expression|string|array $orderBy + * @phpstan-param Order|Order[]|Expression|string|array|string[] $orderBy */ public function order($orderBy = 'id', $direction = null): self { diff --git a/application/Espo/ORM/Repository/RDBRepository.php b/application/Espo/ORM/Repository/RDBRepository.php index 239210154f..9d4b24190e 100644 --- a/application/Espo/ORM/Repository/RDBRepository.php +++ b/application/Espo/ORM/Repository/RDBRepository.php @@ -847,7 +847,7 @@ class RDBRepository implements Repository * Passing an array will reset a previously set order. * @param string|bool|null $direction Select::ORDER_ASC|Select::ORDER_DESC. * - * @phpstan-param Order|Order[]|Expression|string|array $orderBy + * @phpstan-param Order|Order[]|Expression|string|array|string[] $orderBy * @phpstan-return RDBSelectBuilder */ public function order($orderBy = 'id', $direction = null): RDBSelectBuilder diff --git a/application/Espo/ORM/Repository/RDBSelectBuilder.php b/application/Espo/ORM/Repository/RDBSelectBuilder.php index 920090b6cb..20e0ced968 100644 --- a/application/Espo/ORM/Repository/RDBSelectBuilder.php +++ b/application/Espo/ORM/Repository/RDBSelectBuilder.php @@ -316,7 +316,7 @@ class RDBSelectBuilder * Passing an array will reset a previously set order. * @param string|bool|null $direction Select::ORDER_ASC|Select::ORDER_DESC. * - * @phpstan-param Order|Order[]|Expression|string|array $orderBy + * @phpstan-param Order|Order[]|Expression|string|array|string[] $orderBy * @phpstan-return RDBSelectBuilder */ public function order($orderBy = 'id', $direction = null): self diff --git a/application/Espo/Services/App.php b/application/Espo/Services/App.php index 3539843e0c..b839bbc00b 100644 --- a/application/Espo/Services/App.php +++ b/application/Espo/Services/App.php @@ -33,6 +33,7 @@ use Espo\Services\Settings as SettingsService; use Espo\Repositories\PhoneNumber as PhoneNumberRepository; use Espo\Repositories\ArrayValue as ArrayValueRepository; +use Espo\Core\ORM\Entity as CoreEntity; use Espo\Core\{ Acl, @@ -511,6 +512,10 @@ class App while ($dataRow = $sth->fetch()) { $entity = $this->entityManager->getEntityFactory()->create($scope); + if (!$entity instanceof CoreEntity) { + continue; + } + $entity->set($dataRow); $entity->setAsFetched(); diff --git a/application/Espo/Services/Attachment.php b/application/Espo/Services/Attachment.php index c0fe81c50d..aa67e9e106 100644 --- a/application/Espo/Services/Attachment.php +++ b/application/Espo/Services/Attachment.php @@ -37,6 +37,7 @@ use Espo\Core\Exceptions\Error; use Espo\Core\Exceptions\NotFound; use Espo\Repositories\Attachment as AttachmentRepository; +use Espo\Entities\Attachment as AttachmentEntity; use stdClass; @@ -275,6 +276,7 @@ class Attachment extends Record $this->checkAttachmentField($relatedEntityType, $field); + /** @var AttachmentEntity|null */ $attachment = $this->getEntity($data->id); if (!$attachment) { @@ -464,6 +466,7 @@ class Attachment extends Record public function getFileData(string $id): stdClass { + /** @var AttachmentEntity|null */ $attachment = $this->getEntity($id); if (!$attachment) { diff --git a/application/Espo/Services/Email.php b/application/Espo/Services/Email.php index 3ff6f7c928..d0c4d053f0 100644 --- a/application/Espo/Services/Email.php +++ b/application/Espo/Services/Email.php @@ -430,6 +430,7 @@ class Email extends Record implements public function create(stdClass $data, CreateParams $params): Entity { + /** @var EmailEntity */ $entity = parent::create($data, $params); if ($entity->get('status') === EmailEntity::STATUS_SENDING) { @@ -441,6 +442,8 @@ class Email extends Record implements protected function beforeCreateEntity(Entity $entity, $data) { + /** @var EmailEntity $entity */ + if ($entity->get('status') === EmailEntity::STATUS_SENDING) { $messageId = Sender::generateMessageId($entity); @@ -450,6 +453,8 @@ class Email extends Record implements protected function afterUpdateEntity(Entity $entity, $data) { + /** @var EmailEntity $entity */ + if ($entity->get('status') === EmailEntity::STATUS_SENDING) { $this->sendEntity($entity, $this->getUser()); } diff --git a/application/Espo/Services/EmailAccount.php b/application/Espo/Services/EmailAccount.php index 65c6c7c56f..b5037a98bf 100644 --- a/application/Espo/Services/EmailAccount.php +++ b/application/Espo/Services/EmailAccount.php @@ -306,7 +306,7 @@ class EmailAccount extends Record implements return $this->injectableFactory->create(Importer::class); } - public function fetchFromMailServer(Entity $emailAccount) + public function fetchFromMailServer(EmailAccountEntity $emailAccount) { if ($emailAccount->get('status') != 'Active' || !$emailAccount->get('useImap')) { throw new Error("Email Account {$emailAccount->getId()} is not active."); @@ -622,14 +622,17 @@ class EmailAccount extends Record implements } } - public function findAccountForUser(User $user, $address) + /** + * @return EmailAccountEntity|null + */ + public function findAccountForUser(User $user, string $address) { $emailAccount = $this->entityManager ->getRDBRepository('EmailAccount') ->where([ 'emailAddress' => $address, 'assignedUserId' => $user->getId(), - 'status' => 'Active' + 'status' => 'Active', ]) ->findOne(); @@ -699,7 +702,7 @@ class EmailAccount extends Record implements } try { - $size = $storage->getSize($id); + $size = $storage->getSize((int) $id); } catch (Throwable $e) { return false; diff --git a/application/Espo/Services/EmailTemplate.php b/application/Espo/Services/EmailTemplate.php index c3a308ed43..591e9790a0 100644 --- a/application/Espo/Services/EmailTemplate.php +++ b/application/Espo/Services/EmailTemplate.php @@ -79,6 +79,7 @@ class EmailTemplate extends Record implements public function parse(string $id, array $params = [], bool $copyAttachments = false): array { + /** @var EmailTemplateEntity|null */ $emailTemplate = $this->getEntity($id); if (empty($emailTemplate)) { diff --git a/application/Espo/Services/InboundEmail.php b/application/Espo/Services/InboundEmail.php index 53d3951a1e..689db23312 100644 --- a/application/Espo/Services/InboundEmail.php +++ b/application/Espo/Services/InboundEmail.php @@ -1318,7 +1318,7 @@ class InboundEmail extends RecordService implements } try { - $size = $storage->getSize($id); + $size = $storage->getSize((int) $id); } catch (Throwable $e) { return false; diff --git a/application/Espo/Services/Note.php b/application/Espo/Services/Note.php index b02bcdeede..bce46aa5c7 100644 --- a/application/Espo/Services/Note.php +++ b/application/Espo/Services/Note.php @@ -51,6 +51,8 @@ class Note extends Record { parent::afterCreateEntity($entity, $data); + /** @var NoteEntity $entity */ + $this->processFollowAfterCreate($entity); } diff --git a/application/Espo/Services/Pdf.php b/application/Espo/Services/Pdf.php index fe9ee7a3a7..9432f4ddda 100644 --- a/application/Espo/Services/Pdf.php +++ b/application/Espo/Services/Pdf.php @@ -325,7 +325,7 @@ class Pdf private function buildFromTemplateInternal( Entity $entity, - Entity $template, + Template $template, bool $displayInline = false, ?array $additionalData = null, ?Params $params = null, diff --git a/application/Espo/Services/Portal.php b/application/Espo/Services/Portal.php index b6499e0712..29e676e80f 100644 --- a/application/Espo/Services/Portal.php +++ b/application/Espo/Services/Portal.php @@ -53,6 +53,8 @@ class Portal extends Record implements protected function afterUpdateEntity(Entity $entity, $data) { + /** @var PortalEntity $entity */ + $this->loadUrlField($entity); if (property_exists($data, 'portalRolesIds')) {