type fixes

This commit is contained in:
Yuri Kuznetsov
2022-03-11 14:09:17 +02:00
parent 40d62c4213
commit d34c8d1918
11 changed files with 111 additions and 28 deletions

View File

@@ -38,13 +38,16 @@ class EmailAddress extends Record
{
const ERASED_PREFIX = 'ERASED:';
/**
* @param array<int,array<string,mixed>> $result
*/
protected function findInAddressBookByEntityType(
string $filter,
int $limit,
string $entityType,
array &$result,
bool $onlyActual = false
) {
): void {
$whereClause = [
'OR' => [
@@ -161,7 +164,7 @@ class EmailAddress extends Record
}
}
protected function handleQueryBuilderUser(string $filter, QueryBuilder $queryBuilder)
protected function handleQueryBuilderUser(string $filter, QueryBuilder $queryBuilder): void
{
if ($this->acl->get('portalPermission') === 'no') {
$queryBuilder->where([
@@ -174,10 +177,13 @@ class EmailAddress extends Record
]);
}
protected function findInInboundEmail(string $query, int $limit, array &$result)
/**
* @param array<int,array<string,mixed>> $result
*/
protected function findInInboundEmail(string $query, int $limit, array &$result): void
{
if ($this->user->isPortal()) {
return [];
return;
}
$list = $this->entityManager
@@ -199,6 +205,9 @@ class EmailAddress extends Record
}
}
/**
* @return array<int,array<string,mixed>>
*/
public function searchInAddressBook(string $query, int $limit, bool $onlyActual = false): array
{
$result = [];
@@ -259,7 +268,10 @@ class EmailAddress extends Record
return $finalResult;
}
protected function getHavingEmailAddressEntityTypeList()
/**
* @return string[]
*/
protected function getHavingEmailAddressEntityTypeList(): array
{
$list = ['Account', 'Contact', 'Lead', 'User'];

View File

@@ -42,8 +42,14 @@ class EmailFolder extends Record implements Di\LanguageAware
{
use Di\LanguageSetter;
/**
* @var string[]
*/
protected $systemFolderList = ['inbox', 'important', 'sent'];
/**
* @var string[]
*/
protected $systemFolderEndList = ['drafts', 'trash'];
protected function beforeCreateEntity(Entity $entity, $data)
@@ -58,7 +64,7 @@ class EmailFolder extends Record implements Di\LanguageAware
}
}
public function moveUp(string $id)
public function moveUp(string $id): void
{
$entity = $this->entityManager->getEntity('EmailFolder', $id);
if (!$entity) {
@@ -95,7 +101,7 @@ class EmailFolder extends Record implements Di\LanguageAware
$this->entityManager->saveEntity($previousEntity);
}
public function moveDown(string $id)
public function moveDown(string $id): void
{
$entity = $this->entityManager->getEntity('EmailFolder', $id);

View File

@@ -51,11 +51,15 @@ class EmailTemplate extends Record implements
{
use Di\FieldUtilSetter;
/**
* @param array<string,mixed> $params
* @return array<string,mixed>
*/
public function parseTemplate(
EmailTemplateEntity $emailTemplate,
array $params = [],
$copyAttachments = false,
$skipAcl = false
bool $copyAttachments = false,
bool $skipAcl = false
): array {
$paramsInternal = Params::create()
@@ -77,6 +81,10 @@ class EmailTemplate extends Record implements
return get_object_vars($result->getValueMap());
}
/**
* @param array<string,mixed> $params
* @return array<string,mixed>
*/
public function parse(string $id, array $params = [], bool $copyAttachments = false): array
{
/** @var EmailTemplateEntity|null */
@@ -89,6 +97,9 @@ class EmailTemplate extends Record implements
return $this->parseTemplate($emailTemplate, $params, $copyAttachments);
}
/**
* @param array<string,mixed> $params
*/
public function getInsertFieldData(array $params): stdClass
{
$to = $params['to'] ?? null;

View File

@@ -52,7 +52,7 @@ class ExternalAccount extends Record implements Di\HookManagerAware
{
use Di\HookManagerSetter;
protected function getClient(string $integration, string $id)
protected function getClient(string $integration, string $id): ?object
{
/** @var IntegrationEntity|null $integrationEntity */
$integrationEntity = $this->entityManager->getEntity('Integration', $integration);
@@ -102,6 +102,11 @@ class ExternalAccount extends Record implements Di\HookManagerAware
return false;
}
/**
* @return bool
* @throws NotFound
* @throws Error
*/
public function authorizationCode(string $integration, string $userId, string $code)
{
$entity = $this->getExternalAccountEntity($integration, $userId);

View File

@@ -55,9 +55,9 @@ class GlobalSearch implements
use Di\AclSetter;
use Di\ConfigSetter;
protected $fullTextSearchDataComposerFactory;
private $fullTextSearchDataComposerFactory;
protected $selectBuilderFactory;
private $selectBuilderFactory;
public function __construct(
FullTextSearchDataComposerFactory $fullTextSearchDataComposerFactory,

View File

@@ -151,6 +151,9 @@ class InboundEmail extends RecordService implements
$service->storeSentMessage($emailAccount->getId(), $message);
}
/**
* @return ?array<string,mixed>
*/
public function getSmtpParamsFromAccount(InboundEmailEntity $emailAccount): ?array
{
$smtpParams = [];
@@ -187,8 +190,12 @@ class InboundEmail extends RecordService implements
return null;
}
public function applySmtpHandler(InboundEmailEntity $emailAccount, array &$params)
/**
* @param array<string,mixed> $params
*/
public function applySmtpHandler(InboundEmailEntity $emailAccount, array &$params): void
{
/** @var ?class-string */
$handlerClassName = $emailAccount->get('smtpHandler');
if (!$handlerClassName) {

View File

@@ -75,6 +75,9 @@ class Integration
$this->configWriter = $configWriter;
}
/**
* @return void
*/
protected function processAccessCheck()
{
if (!$this->user->isAdmin()) {

View File

@@ -29,6 +29,8 @@
namespace Espo\Services;
use Espo\Core\Utils\Language as LanguageUtil;
use Espo\Core\{
Acl,
Container,
@@ -39,13 +41,13 @@ use Espo\Entities\User;
class Language
{
protected $metadata;
private $metadata;
protected $acl;
private $acl;
protected $user;
private $user;
protected $container;
private $container;
public function __construct(
Metadata $metadata,
@@ -60,17 +62,20 @@ class Language
}
// TODO use proxy
protected function getDefaultLanguage()
protected function getDefaultLanguage(): LanguageUtil
{
return $this->container->get('defaultLanguage');
}
protected function getLanguage()
protected function getLanguage(): LanguageUtil
{
return $this->container->get('language');
}
public function getDataForFrontend(bool $default = false)
/**
* @return array<string,mixed>
*/
public function getDataForFrontend(bool $default = false): array
{
if ($default) {
$languageObj = $this->getDefaultLanguage();

View File

@@ -60,6 +60,12 @@ class LastViewed
$this->listLoadProcessor = $listLoadProcessor;
}
/**
* @param array{
* offset: int,
* maxSize: int,
* } $params
*/
public function getList(array $params): object
{
$repository = $this->entityManager->getRDBRepository('ActionHistoryRecord');

View File

@@ -29,6 +29,8 @@
namespace Espo\Services;
use Espo\Entities\LayoutRecord;
use Espo\Core\{
Exceptions\NotFound,
Exceptions\Forbidden,
@@ -46,6 +48,8 @@ use Espo\{
Tools\LayoutManager\LayoutManager,
};
use stdClass;
class Layout
{
/**
@@ -102,7 +106,7 @@ class Layout
}
/**
* @return array|object|null
* @return array<int,mixed>|stdClass|null
*/
public function getOriginal(string $scope, string $name, ?string $setId = null)
{
@@ -133,6 +137,11 @@ class Layout
return $result;
}
/**
* @return mixed
* @throws Forbidden
* @throws NotFound
*/
public function getForFrontend(string $scope, string $name)
{
try {
@@ -243,8 +252,13 @@ class Layout
return $data;
}
protected function getRecordFromSet(string $scope, string $name, string $setId, bool $skipCheck = false)
{
protected function getRecordFromSet(
string $scope,
string $name,
string $setId,
bool $skipCheck = false
): ?LayoutRecord {
$em = $this->entityManager;
$layoutSet = $em->getEntity('LayoutSet', $setId);
@@ -276,6 +290,10 @@ class Layout
return $layout;
}
/**
* @param mixed $data
* @return mixed
*/
public function update(string $scope, string $name, ?string $setId, $data)
{
if ($setId) {
@@ -310,6 +328,9 @@ class Layout
return $layoutManager->get($scope, $name);
}
/**
* @return array<int,mixed>|stdClass|null
*/
public function resetToDefault(string $scope, string $name, ?string $setId = null)
{
$this->dataManager->updateCacheTimestamp();
@@ -336,7 +357,7 @@ class Layout
return $this->getOriginal($scope, $name);
}
protected function getOriginalBottomPanelsDetail(string $scope, ?string $setId = null)
protected function getOriginalBottomPanelsDetail(string $scope, ?string $setId = null): stdClass
{
$relationships = $this->getOriginal($scope, 'relationships') ?? [];
@@ -366,12 +387,12 @@ class Layout
return $result;
}
protected function getForFrontendBottomPanelsDetail(string $scope)
protected function getForFrontendBottomPanelsDetail(string $scope): stdClass
{
return $this->getOriginalBottomPanelsDetail($scope);
}
protected function resetToDefaultBottomPanelsDetail(string $scope)
protected function resetToDefaultBottomPanelsDetail(string $scope): void
{
$this->layoutManager->resetToDefault($scope, 'relationships');
}

View File

@@ -45,6 +45,9 @@ use stdClass;
class LeadCapture extends Record
{
/**
* @var string[]
*/
protected $readOnlyAttributeList = ['apiKey'];
public function prepareEntityForOutput(Entity $entity)
@@ -164,12 +167,12 @@ class LeadCapture extends Record
return $this->injectableFactory->create(Tool::class);
}
public function leadCapture(string $apiKey, stdClass $data)
public function leadCapture(string $apiKey, stdClass $data): void
{
$this->createTool()->capture($apiKey, $data);
}
public function jobOptInConfirmation(stdClass $data)
public function jobOptInConfirmation(stdClass $data): void
{
if (empty($data->id)) {
throw new Error();
@@ -183,6 +186,10 @@ class LeadCapture extends Record
return $this->createTool()->confirmOptIn($id);
}
/**
* @return stdClass[]
* @throws Forbidden
*/
public function getSmtpAccountDataList(): array
{
if (!$this->getUser()->isAdmin()) {