diff --git a/application/Espo/Controllers/EmailAccount.php b/application/Espo/Controllers/EmailAccount.php index dcca31a69f..3be0d5c650 100644 --- a/application/Espo/Controllers/EmailAccount.php +++ b/application/Espo/Controllers/EmailAccount.php @@ -29,6 +29,8 @@ namespace Espo\Controllers; +use Espo\Core\Exceptions\Error; +use Espo\Core\Exceptions\Forbidden; use Espo\Core\Mail\Account\PersonalAccount\Service; use Espo\Core\Mail\Account\Storage\Params as StorageParams; @@ -44,6 +46,8 @@ class EmailAccount extends Record /** * @return string[] + * @throws Forbidden + * @throws Error */ public function postActionGetFolders(Request $request): array { @@ -63,6 +67,10 @@ class EmailAccount extends Record return $this->getEmailAccountService()->getFolderList($params); } + /** + * @throws Error + * @throws Forbidden + */ public function postActionTestConnection(Request $request): bool { $data = $request->getParsedBody(); diff --git a/application/Espo/Controllers/EmailAddress.php b/application/Espo/Controllers/EmailAddress.php index 3efefa6ebf..ca395c296c 100644 --- a/application/Espo/Controllers/EmailAddress.php +++ b/application/Espo/Controllers/EmailAddress.php @@ -45,6 +45,8 @@ class EmailAddress extends RecordBase /** * @return array> + * @throws Forbidden + * @throws BadRequest */ public function actionSearchInAddressBook(Request $request): array { diff --git a/application/Espo/Controllers/FieldManager.php b/application/Espo/Controllers/FieldManager.php index 0cb103a6a2..a2424411ad 100644 --- a/application/Espo/Controllers/FieldManager.php +++ b/application/Espo/Controllers/FieldManager.php @@ -35,12 +35,12 @@ use Espo\{ }; use Espo\Core\{ + Exceptions\Conflict, Exceptions\Error, Exceptions\Forbidden, Exceptions\BadRequest, Api\Request, - DataManager, -}; + DataManager}; class FieldManager { @@ -50,6 +50,9 @@ class FieldManager private $fieldManagerTool; + /** + * @throws Forbidden + */ public function __construct(User $user, DataManager $dataManager, FieldManagerTool $fieldManagerTool) { $this->user = $user; @@ -59,6 +62,9 @@ class FieldManager $this->checkControllerAccess(); } + /** + * @throws Forbidden + */ protected function checkControllerAccess(): void { if (!$this->user->isAdmin()) { @@ -68,6 +74,8 @@ class FieldManager /** * @return array + * @throws BadRequest + * @throws Error */ public function getActionRead(Request $request): array { @@ -83,6 +91,9 @@ class FieldManager /** * @return array + * @throws BadRequest + * @throws Conflict + * @throws Error */ public function postActionCreate(Request $request): array { @@ -113,6 +124,8 @@ class FieldManager /** * @return array + * @throws BadRequest + * @throws Error */ public function patchActionUpdate(Request $request): array { @@ -121,6 +134,8 @@ class FieldManager /** * @return array + * @throws BadRequest + * @throws Error */ public function putActionUpdate(Request $request): array { @@ -146,6 +161,10 @@ class FieldManager return $fieldManagerTool->read($scope, $name); } + /** + * @throws BadRequest + * @throws Error + */ public function deleteActionDelete(Request $request): bool { $scope = $request->getRouteParam('scope'); @@ -162,6 +181,10 @@ class FieldManager return $result; } + /** + * @throws BadRequest + * @throws Error + */ public function postActionResetToDefault(Request $request): bool { $data = $request->getParsedBody(); @@ -173,7 +196,6 @@ class FieldManager $this->fieldManagerTool->resetToDefault($data->scope, $data->name); $this->dataManager->clearCache(); - $this->dataManager->rebuildMetadata(); return true; diff --git a/application/Espo/Controllers/InboundEmail.php b/application/Espo/Controllers/InboundEmail.php index 1326f98ff1..5496910a9e 100644 --- a/application/Espo/Controllers/InboundEmail.php +++ b/application/Espo/Controllers/InboundEmail.php @@ -44,6 +44,7 @@ class InboundEmail extends Record /** * @return string[] + * @throws \Espo\Core\Exceptions\Error */ public function postActionGetFolders(Request $request): array { diff --git a/application/Espo/Controllers/Layout.php b/application/Espo/Controllers/Layout.php index 4b42c35e51..4c6cf2a852 100644 --- a/application/Espo/Controllers/Layout.php +++ b/application/Espo/Controllers/Layout.php @@ -29,10 +29,12 @@ namespace Espo\Controllers; +use Espo\Core\Exceptions\Error; use Espo\Core\Exceptions\Forbidden; use Espo\Core\Exceptions\BadRequest; use Espo\Core\Api\Request; +use Espo\Core\Exceptions\NotFound; use Espo\Services\Layout as Service; use Espo\Entities\User; @@ -50,6 +52,10 @@ class Layout /** * @return mixed + * @throws Forbidden + * @throws NotFound + * @throws Error + * @throws BadRequest */ public function getActionRead(Request $request) { @@ -67,6 +73,10 @@ class Layout /** * @return mixed + * @throws Forbidden + * @throws BadRequest + * @throws NotFound + * @throws Error */ public function putActionUpdate(Request $request) { @@ -95,6 +105,10 @@ class Layout /** * @return mixed + * @throws Forbidden + * @throws BadRequest + * @throws NotFound + * @throws Error */ public function postActionResetToDefault(Request $request) { @@ -113,6 +127,10 @@ class Layout /** * @return mixed + * @throws BadRequest + * @throws Forbidden + * @throws NotFound + * @throws Error */ public function getActionGetOriginal(Request $request) { diff --git a/application/Espo/Controllers/LeadCapture.php b/application/Espo/Controllers/LeadCapture.php index c82849a751..4267596504 100644 --- a/application/Espo/Controllers/LeadCapture.php +++ b/application/Espo/Controllers/LeadCapture.php @@ -99,6 +99,7 @@ class LeadCapture extends Record /** * @return stdClass[] + * @throws Forbidden */ public function getActionSmtpAccountDataList(): array { diff --git a/application/Espo/Controllers/MassAction.php b/application/Espo/Controllers/MassAction.php index 340caf247a..51648b4fbe 100644 --- a/application/Espo/Controllers/MassAction.php +++ b/application/Espo/Controllers/MassAction.php @@ -119,6 +119,7 @@ class MassAction /** * @return array + * @throws BadRequest */ private function prepareMassActionParams(stdClass $data): array { @@ -149,6 +150,9 @@ class MassAction throw new BadRequest("Bad search params for mass action."); } + /** + * @throws Error + */ private function convertResult(ServiceResult $serviceResult): stdClass { if (!$serviceResult->hasResult()) { diff --git a/application/Espo/Controllers/Metadata.php b/application/Espo/Controllers/Metadata.php index 72aa1253dd..1cb05d5dda 100644 --- a/application/Espo/Controllers/Metadata.php +++ b/application/Espo/Controllers/Metadata.php @@ -49,6 +49,7 @@ class Metadata extends Base /** * @return mixed + * @throws Forbidden */ public function getActionGet(Request $request) { diff --git a/application/Espo/Core/Utils/Database/Helper.php b/application/Espo/Core/Utils/Database/Helper.php index e924ff38c3..fc2337dd32 100644 --- a/application/Espo/Core/Utils/Database/Helper.php +++ b/application/Espo/Core/Utils/Database/Helper.php @@ -87,6 +87,9 @@ class Helper $this->config = $config; } + /** + * @throws \Doctrine\DBAL\Exception + */ public function getDbalConnection(): DbalConnection { if (!isset($this->dbalConnection)) { @@ -118,6 +121,7 @@ class Helper /** * @param array $params * @throws RuntimeException + * @throws \Doctrine\DBAL\Exception */ public function createDbalConnection(array $params = []): DbalConnection { diff --git a/application/Espo/Core/Utils/Database/Schema/Schema.php b/application/Espo/Core/Utils/Database/Schema/Schema.php index 6cd07d8e03..9afdd878cb 100644 --- a/application/Espo/Core/Utils/Database/Schema/Schema.php +++ b/application/Espo/Core/Utils/Database/Schema/Schema.php @@ -183,6 +183,7 @@ class Schema * Rebuild database schema. * * @param ?string[] $entityList + * @throws \Doctrine\DBAL\Schema\SchemaException */ public function rebuild(?array $entityList = null): bool { @@ -259,6 +260,7 @@ class Schema * Get SQL queries to get from one to another schema. * * @return string[] Array of SQL queries. + * @throws \Doctrine\DBAL\Schema\SchemaException */ public function getDiffSql(DBALSchema $fromSchema, DBALSchema $toSchema) { diff --git a/application/Espo/Core/Utils/Database/Schema/SchemaProxy.php b/application/Espo/Core/Utils/Database/Schema/SchemaProxy.php index 744be8c5c1..ce196998f4 100644 --- a/application/Espo/Core/Utils/Database/Schema/SchemaProxy.php +++ b/application/Espo/Core/Utils/Database/Schema/SchemaProxy.php @@ -51,6 +51,7 @@ class SchemaProxy /** * @param ?string[] $entityList + * @throws \Doctrine\DBAL\Schema\SchemaException */ public function rebuild(?array $entityList = null): bool { diff --git a/application/Espo/Core/Utils/Database/Schema/rebuildActions/FulltextIndex.php b/application/Espo/Core/Utils/Database/Schema/rebuildActions/FulltextIndex.php index e80f15b6f0..9daef23ec7 100644 --- a/application/Espo/Core/Utils/Database/Schema/rebuildActions/FulltextIndex.php +++ b/application/Espo/Core/Utils/Database/Schema/rebuildActions/FulltextIndex.php @@ -39,6 +39,7 @@ class FulltextIndex extends BaseRebuildActions { /** * @return void + * @throws \Doctrine\DBAL\Exception */ public function beforeRebuild() { diff --git a/application/Espo/Core/Utils/ScheduledJob.php b/application/Espo/Core/Utils/ScheduledJob.php index 4e58a9329d..6ad94981da 100644 --- a/application/Espo/Core/Utils/ScheduledJob.php +++ b/application/Espo/Core/Utils/ScheduledJob.php @@ -39,6 +39,8 @@ use Espo\Core\{ ORM\EntityManager, }; +use Exception; +use RuntimeException; use DateTime; class ScheduledJob @@ -151,8 +153,13 @@ class ScheduledJob */ public function isCronConfigured(): bool { - $r1From = new DateTime('-' . $this->checkingCronPeriod); - $r1To = new DateTime('+' . $this->checkingCronPeriod); + try { + $r1From = new DateTime('-' . $this->checkingCronPeriod); + $r1To = new DateTime('+' . $this->checkingCronPeriod); + } + catch (Exception $e) { + throw new RuntimeException(); + } $r2From = new DateTime('-1 hour'); $r2To = new DateTime(); diff --git a/application/Espo/Core/WebSocket/Pusher.php b/application/Espo/Core/WebSocket/Pusher.php index 4ff8b9a5e2..632f3924f5 100644 --- a/application/Espo/Core/WebSocket/Pusher.php +++ b/application/Espo/Core/WebSocket/Pusher.php @@ -35,6 +35,7 @@ use Ratchet\Wamp\WampServerInterface; use Symfony\Component\Process\PhpExecutableFinder; use Exception; +use RuntimeException; class Pusher implements WampServerInterface { @@ -97,7 +98,7 @@ class Pusher implements WampServerInterface $this->log("Error: No php-executable-path."); } - throw new Exception("No php-executable-path."); + throw new RuntimeException("No php-executable-path."); } $this->phpExecutablePath = $phpExecutablePath; diff --git a/application/Espo/EntryPoints/Image.php b/application/Espo/EntryPoints/Image.php index d848c68ef9..fb3dedc429 100644 --- a/application/Espo/EntryPoints/Image.php +++ b/application/Espo/EntryPoints/Image.php @@ -240,6 +240,7 @@ class Image implements EntryPoint /** * @return \GdImage * @phpstan-ignore-next-line + * @throws Error */ protected function createThumbImage(string $filePath, string $fileType, string $size) { diff --git a/application/Espo/Hooks/Common/StreamNotesAcl.php b/application/Espo/Hooks/Common/StreamNotesAcl.php index 73b5000301..55e680da11 100644 --- a/application/Espo/Hooks/Common/StreamNotesAcl.php +++ b/application/Espo/Hooks/Common/StreamNotesAcl.php @@ -53,6 +53,7 @@ class StreamNotesAcl /** * @param array $options + * @throws \Espo\Core\Exceptions\Error */ public function afterSave(Entity $entity, array $options): void { diff --git a/application/Espo/Modules/Crm/Controllers/Activities.php b/application/Espo/Modules/Crm/Controllers/Activities.php index f5fef9144d..d183894d71 100644 --- a/application/Espo/Modules/Crm/Controllers/Activities.php +++ b/application/Espo/Modules/Crm/Controllers/Activities.php @@ -171,6 +171,7 @@ class Activities /** * @throws Forbidden * @throws NotFound + * @throws BadRequest */ public function getActionListUpcoming(Request $request): stdClass { diff --git a/application/Espo/Modules/Crm/Controllers/Document.php b/application/Espo/Modules/Crm/Controllers/Document.php index 6f7352b359..94de26bc55 100644 --- a/application/Espo/Modules/Crm/Controllers/Document.php +++ b/application/Espo/Modules/Crm/Controllers/Document.php @@ -39,6 +39,9 @@ class Document extends \Espo\Core\Controllers\Record { /** * @return \stdClass[] + * @throws BadRequest + * @throws Forbidden + * @throws \Espo\Core\Exceptions\NotFound */ public function postActionGetAttachmentList(Request $request): array { diff --git a/application/Espo/Modules/Crm/Controllers/MassEmail.php b/application/Espo/Modules/Crm/Controllers/MassEmail.php index 1cf0d65a03..88c1ad23e1 100644 --- a/application/Espo/Modules/Crm/Controllers/MassEmail.php +++ b/application/Espo/Modules/Crm/Controllers/MassEmail.php @@ -57,6 +57,7 @@ class MassEmail extends \Espo\Core\Controllers\Record /** * @return stdClass[] + * @throws Forbidden */ public function getActionSmtpAccountDataList(): array { diff --git a/application/Espo/Modules/Crm/Controllers/Opportunity.php b/application/Espo/Modules/Crm/Controllers/Opportunity.php index 30aca91f46..e14fd2d22a 100644 --- a/application/Espo/Modules/Crm/Controllers/Opportunity.php +++ b/application/Espo/Modules/Crm/Controllers/Opportunity.php @@ -121,6 +121,8 @@ class Opportunity extends \Espo\Core\Controllers\Record /** * @return stdClass[] + * @throws Forbidden + * @throws BadRequest */ public function getActionEmailAddressList(Request $request): array { diff --git a/application/Espo/Modules/Crm/Services/Activities.php b/application/Espo/Modules/Crm/Services/Activities.php index 422546c69e..e439c06f4c 100644 --- a/application/Espo/Modules/Crm/Services/Activities.php +++ b/application/Espo/Modules/Crm/Services/Activities.php @@ -1628,6 +1628,7 @@ class Activities implements * @param ?string[] $scopeList * @return array> * @throws Forbidden + * @throws NotFound */ public function getEventsForTeams(array $teamIdList, string $from, string $to, ?array $scopeList = null): array { @@ -1639,6 +1640,7 @@ class Activities implements * @param ?string[] $scopeList * @return array> * @throws Forbidden + * @throws NotFound */ public function getTeamsEventList(array $teamIdList, string $from, string $to, ?array $scopeList = null): array { diff --git a/application/Espo/Modules/Crm/Services/Document.php b/application/Espo/Modules/Crm/Services/Document.php index d5feda2e60..b3c6131fae 100644 --- a/application/Espo/Modules/Crm/Services/Document.php +++ b/application/Espo/Modules/Crm/Services/Document.php @@ -43,6 +43,8 @@ class Document extends Record { /** * @return \Espo\ORM\Collection + * @throws NotFound + * @throws \Espo\Core\Exceptions\Forbidden */ public function getAttachmentList(string $id) { diff --git a/application/Espo/Modules/Crm/Services/Lead.php b/application/Espo/Modules/Crm/Services/Lead.php index 7d28bde22a..e848a5ce41 100644 --- a/application/Espo/Modules/Crm/Services/Lead.php +++ b/application/Espo/Modules/Crm/Services/Lead.php @@ -233,6 +233,8 @@ class Lead extends Record implements /** * @param stdClass|null $additionalData + * @throws Forbidden + * @throws ConflictSilent */ public function convert(string $id, object $recordsData, ?object $additionalData = null): LeadEntity { diff --git a/application/Espo/Modules/Crm/Services/MassEmail.php b/application/Espo/Modules/Crm/Services/MassEmail.php index 2bc78e7206..9a3e1a6c3b 100644 --- a/application/Espo/Modules/Crm/Services/MassEmail.php +++ b/application/Espo/Modules/Crm/Services/MassEmail.php @@ -132,6 +132,7 @@ class MassEmail extends Record /** * @param iterable $targetList + * @throws Error */ protected function createTestQueue(MassEmailEntity $massEmail, iterable $targetList): void { @@ -140,6 +141,9 @@ class MassEmail extends Record $queue->create($massEmail, true, $targetList); } + /** + * @throws Error + */ 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 e55ada7236..61da4dbed6 100644 --- a/application/Espo/Modules/Crm/Services/Opportunity.php +++ b/application/Espo/Modules/Crm/Services/Opportunity.php @@ -57,6 +57,10 @@ class Opportunity extends Record 'accountName', ]; + /** + * @throws Forbidden + * @throws \Exception + */ public function reportSalesPipeline( string $dateFilter, ?string $dateFrom = null, @@ -160,6 +164,10 @@ class Opportunity extends Record ]; } + /** + * @throws Forbidden + * @throws \Exception + */ public function reportByLeadSource( string $dateFilter, ?string $dateFrom = null, @@ -227,6 +235,10 @@ class Opportunity extends Record return (object) $result; } + /** + * @throws Forbidden + * @throws \Exception + */ public function reportByStage( string $dateFilter, ?string $dateFrom = null, @@ -307,6 +319,10 @@ class Opportunity extends Record return (object) $result; } + /** + * @throws Forbidden + * @throws \Exception + */ public function reportSalesByMonth( string $dateFilter, ?string $dateFrom = null, @@ -447,9 +463,9 @@ class Opportunity extends Record } /** - * * @param string $dateFilter * @return array{string,string} + * @throws \Exception */ protected function getDateRangeByFilter(string $dateFilter): array { @@ -578,6 +594,7 @@ class Opportunity extends Record /** * @return stdClass[] + * @throws \Espo\Core\Exceptions\Forbidden */ public function getEmailAddressList(string $id): array { diff --git a/application/Espo/Modules/Crm/Services/TargetList.php b/application/Espo/Modules/Crm/Services/TargetList.php index 99fa49a959..ce263235b8 100644 --- a/application/Espo/Modules/Crm/Services/TargetList.php +++ b/application/Espo/Modules/Crm/Services/TargetList.php @@ -311,6 +311,7 @@ class TargetList extends Record implements /** * @return RecordCollection + * @throws Error */ protected function findLinkedOptedOut(string $id, SearchParams $searchParams): RecordCollection { @@ -370,6 +371,10 @@ class TargetList extends Record implements return new RecordCollection($collection, $totalCount); } + /** + * @throws NotFound + * @throws Error + */ public function optOut(string $id, string $targetType, string $targetId): void { $targetList = $this->entityManager->getEntity('TargetList', $id); @@ -406,6 +411,10 @@ class TargetList extends Record implements $this->hookManager->process('TargetList', 'afterOptOut', $targetList, [], $hookData); } + /** + * @throws NotFound + * @throws Error + */ public function cancelOptOut(string $id, string $targetType, string $targetId): void { $targetList = $this->entityManager->getEntity('TargetList', $id); diff --git a/application/Espo/Services/Email.php b/application/Espo/Services/Email.php index d83c57065e..b654b006c8 100644 --- a/application/Espo/Services/Email.php +++ b/application/Espo/Services/Email.php @@ -459,7 +459,9 @@ class Email extends Record implements /** * @throws BadRequest * @throws Error - * @throws \Espo\Core\Exceptions\ForbiddenSilent + * @throws \Espo\Core\Exceptions\Forbidden + * @throws \Espo\Core\Exceptions\Conflict + * @throws \Espo\Core\Exceptions\BadRequest */ public function create(stdClass $data, CreateParams $params): Entity { diff --git a/application/Espo/Services/Pdf.php b/application/Espo/Services/Pdf.php index 7a8717b96a..6bef78a56c 100644 --- a/application/Espo/Services/Pdf.php +++ b/application/Espo/Services/Pdf.php @@ -312,6 +312,7 @@ class Pdf * Generate PDF. ACL check is processed if `$params` is null. * * @throws Error + * @throws Forbidden */ public function generate(Entity $entity, Template $template, ?Params $params = null, ?Data $data = null): string { @@ -329,6 +330,7 @@ class Pdf /** * @param ?array $additionalData * @throws Error + * @throws Forbidden * @deprecated */ public function buildFromTemplate( diff --git a/application/Espo/Tools/FieldManager/FieldManager.php b/application/Espo/Tools/FieldManager/FieldManager.php index 0971312490..a93bfccc7f 100644 --- a/application/Espo/Tools/FieldManager/FieldManager.php +++ b/application/Espo/Tools/FieldManager/FieldManager.php @@ -135,6 +135,9 @@ class FieldManager /** * @param array $fieldDefs * @return bool + * @throws BadRequest + * @throws Conflict + * @throws Error */ public function create(string $scope, string $name, array $fieldDefs) {