diff --git a/application/Espo/Services/AdminNotifications.php b/application/Espo/Services/AdminNotifications.php index db3521bc10..8b7a73100d 100644 --- a/application/Espo/Services/AdminNotifications.php +++ b/application/Espo/Services/AdminNotifications.php @@ -41,9 +41,9 @@ class AdminNotifications implements { use Di\EntityManagerSetter; - protected $config; + private $config; - protected $configWriter; + private $configWriter; public function __construct(Config $config, ConfigWriter $configWriter) { @@ -54,12 +54,12 @@ class AdminNotifications implements /** * Job for checking a new version of EspoCRM. */ - public function jobCheckNewVersion() + public function jobCheckNewVersion(): void { $config = $this->config; if (!$config->get('adminNotifications') || !$config->get('adminNotificationsNewVersion')) { - return true; + return; } $latestRelease = $this->getLatestRelease(); @@ -69,7 +69,7 @@ class AdminNotifications implements $this->configWriter->save(); - return true; + return; } if ($config->get('latestVersion') != $latestRelease['version']) { @@ -81,25 +81,23 @@ class AdminNotifications implements $this->configWriter->save(); - return true; + return; } if (!empty($latestRelease['notes'])) { // @todo Find and modify notification. } - - return true; } /** * Job for checking a new version of installed extensions. */ - public function jobCheckNewExtensionVersion() + public function jobCheckNewExtensionVersion(): void { $config = $this->config; if (!$config->get('adminNotifications') || !$config->get('adminNotificationsNewExtensionVersion')) { - return true; + return; } $query = $this->entityManager->getQueryBuilder() @@ -136,7 +134,6 @@ class AdminNotifications implements $save = false; foreach ($latestReleases as $extensionName => $extensionData) { - if (empty($latestExtensionVersions[$extensionName])) { $latestExtensionVersions[$extensionName] = $extensionData['version']; $save = true; @@ -166,10 +163,12 @@ class AdminNotifications implements $this->configWriter->save(); } - - return true; } + /** + * @param array $requestData + * @return ?array + */ protected function getLatestRelease( ?string $url = null, array $requestData = [], diff --git a/application/Espo/Services/App.php b/application/Espo/Services/App.php index ad0c13430a..dfbd8aa811 100644 --- a/application/Espo/Services/App.php +++ b/application/Espo/Services/App.php @@ -110,6 +110,9 @@ class App $this->log = $log; } + /** + * @return array + */ public function getUserData(): array { $preferencesData = $this->preferences->getValueMap(); @@ -161,6 +164,7 @@ class App ]; foreach (($this->metadata->get(['app', 'appParams']) ?? []) as $paramKey => $item) { + /** @var ?class-string */ $className = $item['className'] ?? null; if (!$className) { @@ -190,7 +194,7 @@ class App ]; } - private function getUserDataForFrontend() + private function getUserDataForFrontend(): stdClass { $user = $this->user; @@ -230,7 +234,7 @@ class App return $data; } - private function getAclDataForFrontend() + private function getAclDataForFrontend(): stdClass { $data = $this->acl->getMapData(); @@ -251,7 +255,7 @@ class App return $data; } - private function getEmailAddressData() + private function getEmailAddressData(): stdClass { $user = $this->user; @@ -337,6 +341,9 @@ class App ]; } + /** + * @return int + */ private function getMaxUploadSize() { $maxSize = 0; @@ -391,20 +398,20 @@ class App return $value; } - public function jobClearCache() + public function jobClearCache(): void { $this->dataManager->clearCache(); } - public function jobRebuild() + public function jobRebuild(): void { $this->dataManager->rebuild(); } /** - * @todo Remove in 6.0. + * @todo Remove in 7.2. */ - public function jobPopulatePhoneNumberNumeric() + public function jobPopulatePhoneNumberNumeric(): void { $numberList = $this->entityManager ->getRDBRepository('PhoneNumber') @@ -416,9 +423,9 @@ class App } /** - * @todo Remove in 6.0. Move to another place. CLI command. + * @todo Remove in 7.2. Move to another place. CLI command. */ - public function jobPopulateArrayValues() + public function jobPopulateArrayValues(): void { $scopeList = array_keys($this->metadata->get(['scopes'])); @@ -517,9 +524,9 @@ class App } /** - * @todo Remove in 6.0. Move to another place. CLI command. + * @todo Remove in 7.2. Move to another place. CLI command. */ - public function jobPopulateOptedOutPhoneNumbers() + public function jobPopulateOptedOutPhoneNumbers(): void { $entityTypeList = ['Contact', 'Lead']; @@ -553,7 +560,7 @@ class App } } - private function filterPreferencesData(stdClass $data) + private function filterPreferencesData(stdClass $data): void { $passwordFieldList = $this->fieldUtil->getFieldByTypeList('Preferences', 'password'); diff --git a/application/Espo/Services/Attachment.php b/application/Espo/Services/Attachment.php index 6f298a58c9..27628d41c6 100644 --- a/application/Espo/Services/Attachment.php +++ b/application/Espo/Services/Attachment.php @@ -43,16 +43,31 @@ use stdClass; class Attachment extends Record { + /** + * @var string[] + */ protected $notFilteringAttributeList = ['contents']; + /** + * @var string[] + */ protected $attachmentFieldTypeList = ['file', 'image', 'attachmentMultiple']; + /** + * @var string[] + */ protected $inlineAttachmentFieldTypeList = ['wysiwyg']; + /** + * @var string[] + */ protected $adminOnlyHavingInlineAttachmentsEntityTypeList = [ 'TemplateManager', ]; + /** + * @var string[] + */ protected $imageTypeList = [ 'image/png', 'image/jpeg', @@ -60,6 +75,10 @@ class Attachment extends Record 'image/webp', ]; + /** + * @param string $fileData + * @throws Forbidden + */ public function upload($fileData): Entity { if (!$this->getAcl()->checkScope('Attachment', 'create')) { @@ -213,13 +232,11 @@ class Attachment extends Record } } - protected function checkAttachmentField($relatedEntityType, $field, $role = 'Attachment') + protected function checkAttachmentField(string $relatedEntityType, string $field, string $role = 'Attachment'): void { if ( - $this->getUser()->isAdmin() - && - $role === 'Inline Attachment' - && + $this->getUser()->isAdmin() && + $role === 'Inline Attachment' && in_array($relatedEntityType, $this->adminOnlyHavingInlineAttachmentsEntityTypeList) ) { return; diff --git a/application/Espo/Services/CurrencyRate.php b/application/Espo/Services/CurrencyRate.php index 2304ba7f77..a9d7450844 100644 --- a/application/Espo/Services/CurrencyRate.php +++ b/application/Espo/Services/CurrencyRate.php @@ -41,17 +41,17 @@ use Espo\Core\{ Acl, }; -use StdClass; +use stdClass; class CurrencyRate { - protected $config; + private $config; - protected $configWriter; + private $configWriter; - protected $dataManager; + private $dataManager; - protected $acl; + private $acl; public function __construct(Config $config, ConfigWriter $configWriter, DataManager $dataManager, Acl $acl) { @@ -61,7 +61,7 @@ class CurrencyRate $this->acl = $acl; } - public function get(): StdClass + public function get(): stdClass { if (!$this->acl->check('Currency')) { throw new Forbidden(); @@ -76,7 +76,7 @@ class CurrencyRate ); } - public function set(StdClass $rates): StdClass + public function set(stdClass $rates): stdClass { if (!$this->acl->check('Currency')) { throw new Forbidden(); diff --git a/application/Espo/Services/DashboardTemplate.php b/application/Espo/Services/DashboardTemplate.php index 0212044e53..399afa8f0d 100644 --- a/application/Espo/Services/DashboardTemplate.php +++ b/application/Espo/Services/DashboardTemplate.php @@ -38,7 +38,7 @@ use Espo\Entities\User; class DashboardTemplate extends Record { - protected function applyLayout(Entity $preferences, Entity $template, bool $append) + protected function applyLayout(Entity $preferences, Entity $template, bool $append): void { if (!$append) { $preferences->set([ @@ -87,6 +87,11 @@ class DashboardTemplate extends Record } } + /** + * @param string[] $userIdList + * @throws NotFound + * @throws Forbidden + */ public function deployToUsers(string $id, array $userIdList, bool $append = false): void { $template = $this->getEntityManager()->getEntity('DashboardTemplate', $id); diff --git a/application/Espo/Services/Email.php b/application/Espo/Services/Email.php index 1291c965bd..82bad7122e 100644 --- a/application/Espo/Services/Email.php +++ b/application/Espo/Services/Email.php @@ -73,6 +73,9 @@ class Email extends Record implements protected $getEntityBeforeUpdate = true; + /** + * @var string[] + */ protected $allowedForUpdateAttributeList = [ 'parentType', 'parentId', @@ -371,7 +374,10 @@ class Email extends Record implements } } - protected function applySmtpHandler(string $userId, string $emailAddress, array &$params) + /** + * @param array $params + */ + protected function applySmtpHandler(string $userId, string $emailAddress, array &$params): void { $userData = $this->getUserDataRepository()->getByUserId($userId); @@ -488,7 +494,10 @@ class Email extends Record implements return $entity; } - public function markAsReadByIdList(array $idList, $userId = null) + /** + * @param string[] $idList + */ + public function markAsReadByIdList(array $idList, ?string $userId = null): bool { foreach ($idList as $id) { $this->markAsRead($id, $userId); @@ -497,7 +506,10 @@ class Email extends Record implements return true; } - public function markAsNotReadByIdList(array $idList, $userId = null) + /** + * @param string[] $idList + */ + public function markAsNotReadByIdList(array $idList, ?string $userId = null): bool { foreach ($idList as $id) { $this->markAsNotRead($id, $userId); @@ -506,7 +518,10 @@ class Email extends Record implements return true; } - public function markAsImportantByIdList(array $idList, $userId = null) + /** + * @param string[] $idList + */ + public function markAsImportantByIdList(array $idList, ?string $userId = null): bool { foreach ($idList as $id) { $this->markAsImportant($id, $userId); @@ -515,7 +530,10 @@ class Email extends Record implements return true; } - public function markAsNotImportantByIdList(array $idList, $userId = null) + /** + * @param string[] $idList + */ + public function markAsNotImportantByIdList(array $idList, ?string $userId = null): bool { foreach ($idList as $id) { $this->markAsNotImportant($id, $userId); @@ -524,7 +542,10 @@ class Email extends Record implements return true; } - public function moveToTrashByIdList(array $idList, $userId = null) + /** + * @param string[] $idList + */ + public function moveToTrashByIdList(array $idList, ?string $userId = null): bool { foreach ($idList as $id) { $this->moveToTrash($id, $userId); @@ -533,7 +554,10 @@ class Email extends Record implements return true; } - public function moveToFolderByIdList(array $idList, $folderId, $userId = null) + /** + * @param string[] $idList + */ + public function moveToFolderByIdList(array $idList, ?string $folderId, ?string $userId = null): bool { foreach ($idList as $id) { $this->moveToFolder($id, $folderId, $userId); @@ -542,7 +566,10 @@ class Email extends Record implements return true; } - public function retrieveFromTrashByIdList(array $idList, $userId = null) + /** + * @param string[] $idList + */ + public function retrieveFromTrashByIdList(array $idList, ?string $userId = null): bool { foreach ($idList as $id) { $this->retrieveFromTrash($id, $userId); @@ -551,7 +578,7 @@ class Email extends Record implements return true; } - public function markAllAsRead(?string $userId = null) + public function markAllAsRead(?string $userId = null): bool { $userId = $userId ?? $this->getUser()->getId(); @@ -584,7 +611,7 @@ class Email extends Record implements return true; } - public function markAsRead(string $id, ?string $userId = null) + public function markAsRead(string $id, ?string $userId = null): bool { $userId = $userId ?? $this->getUser()->getId(); @@ -605,7 +632,7 @@ class Email extends Record implements return true; } - public function markAsNotRead(string $id, ?string $userId = null) + public function markAsNotRead(string $id, ?string $userId = null): bool { $userId = $userId ?? $this->getUser()->getId(); @@ -624,7 +651,7 @@ class Email extends Record implements return true; } - public function markAsImportant(string $id, ?string $userId = null) + public function markAsImportant(string $id, ?string $userId = null): bool { $userId = $userId ?? $this->getUser()->getId(); @@ -643,7 +670,7 @@ class Email extends Record implements return true; } - public function markAsNotImportant(string $id, ?string $userId = null) + public function markAsNotImportant(string $id, ?string $userId = null): bool { $userId = $userId ?? $this->getUser()->getId(); @@ -662,7 +689,7 @@ class Email extends Record implements return true; } - public function moveToTrash(string $id, ?string $userId = null) + public function moveToTrash(string $id, ?string $userId = null): bool { $userId = $userId ?? $this->getUser()->getId(); @@ -683,7 +710,7 @@ class Email extends Record implements return true; } - public function retrieveFromTrash(string $id, ?string $userId = null) + public function retrieveFromTrash(string $id, ?string $userId = null): bool { $userId = $userId ?? $this->getUser()->getId(); @@ -702,7 +729,7 @@ class Email extends Record implements return true; } - public function markNotificationAsRead(string $id, string $userId) + public function markNotificationAsRead(string $id, string $userId): void { $update = $this->entityManager->getQueryBuilder()->update() ->in('Notification') @@ -720,7 +747,7 @@ class Email extends Record implements $this->entityManager->getQueryExecutor()->execute($update); } - public function moveToFolder(string $id, ?string $folderId, ?string $userId = null) + public function moveToFolder(string $id, ?string $folderId, ?string $userId = null): bool { $userId = $userId ?? $this->getUser()->getId(); @@ -852,7 +879,11 @@ class Email extends Record implements ]; } - public function sendTestEmail(array $data) + /** + * @param array $data + * @throws Forbidden + */ + public function sendTestEmail(array $data): bool { $smtpParams = $data; diff --git a/application/Espo/Services/EmailAccount.php b/application/Espo/Services/EmailAccount.php index 1c8bb86464..1dbb4b3fbb 100644 --- a/application/Espo/Services/EmailAccount.php +++ b/application/Espo/Services/EmailAccount.php @@ -127,6 +127,9 @@ class EmailAccount extends Record implements return $emailAccount; } + /** + * @return ?array + */ public function getSmtpParamsFromAccount(EmailAccountEntity $emailAccount): ?array { $smtpParams = []; @@ -156,8 +159,12 @@ class EmailAccount extends Record implements return null; } - public function applySmtpHandler(EmailAccountEntity $emailAccount, array &$params) + /** + * @param array $params + */ + public function applySmtpHandler(EmailAccountEntity $emailAccount, array &$params): void { + /** @var ?class-string */ $handlerClassName = $emailAccount->get('smtpHandler'); if (!$handlerClassName) {