From 0f75c7e073ef0225d354d9fece4fb44968735563 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Thu, 10 Oct 2024 20:13:15 +0200 Subject: [PATCH 1/3] chore(dev-deps): bump coding-standard to 1.3.1 Signed-off-by: Daniel Kesselberg --- vendor-bin/cs-fixer/composer.lock | 77 +++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 15 deletions(-) diff --git a/vendor-bin/cs-fixer/composer.lock b/vendor-bin/cs-fixer/composer.lock index a4435b5cd8..166a4eb04a 100644 --- a/vendor-bin/cs-fixer/composer.lock +++ b/vendor-bin/cs-fixer/composer.lock @@ -7,21 +7,68 @@ "content-hash": "46c1bd20704b7b8aad3df18cc01261fa", "packages": [], "packages-dev": [ + { + "name": "kubawerlos/php-cs-fixer-custom-fixers", + "version": "v3.22.0", + "source": { + "type": "git", + "url": "https://github.com/kubawerlos/php-cs-fixer-custom-fixers.git", + "reference": "8701394f0c7cd450ac4fa577d24589122c1d5d5e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kubawerlos/php-cs-fixer-custom-fixers/zipball/8701394f0c7cd450ac4fa577d24589122c1d5d5e", + "reference": "8701394f0c7cd450ac4fa577d24589122c1d5d5e", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "ext-tokenizer": "*", + "friendsofphp/php-cs-fixer": "^3.61.1", + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.6.4 || ^10.5.29" + }, + "type": "library", + "autoload": { + "psr-4": { + "PhpCsFixerCustomFixers\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kuba Werłos", + "email": "werlos@gmail.com" + } + ], + "description": "A set of custom fixers for PHP CS Fixer", + "support": { + "issues": "https://github.com/kubawerlos/php-cs-fixer-custom-fixers/issues", + "source": "https://github.com/kubawerlos/php-cs-fixer-custom-fixers/tree/v3.22.0" + }, + "time": "2024-08-16T20:44:35+00:00" + }, { "name": "nextcloud/coding-standard", - "version": "v1.2.3", + "version": "v1.3.1", "source": { "type": "git", "url": "https://github.com/nextcloud/coding-standard.git", - "reference": "bc9c53a5306114b60c4363057aff9c2ed10a54da" + "reference": "e88acb0df6217b808d1632286ddfec9267a102e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nextcloud/coding-standard/zipball/bc9c53a5306114b60c4363057aff9c2ed10a54da", - "reference": "bc9c53a5306114b60c4363057aff9c2ed10a54da", + "url": "https://api.github.com/repos/nextcloud/coding-standard/zipball/e88acb0df6217b808d1632286ddfec9267a102e4", + "reference": "e88acb0df6217b808d1632286ddfec9267a102e4", "shasum": "" }, "require": { + "kubawerlos/php-cs-fixer-custom-fixers": "^3.22", "php": "^7.3|^8.0", "php-cs-fixer/shim": "^3.17" }, @@ -44,22 +91,22 @@ "description": "Nextcloud coding standards for the php cs fixer", "support": { "issues": "https://github.com/nextcloud/coding-standard/issues", - "source": "https://github.com/nextcloud/coding-standard/tree/v1.2.3" + "source": "https://github.com/nextcloud/coding-standard/tree/v1.3.1" }, - "time": "2024-08-23T14:32:32+00:00" + "time": "2024-09-19T09:07:10+00:00" }, { "name": "php-cs-fixer/shim", - "version": "v3.63.1", + "version": "v3.64.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/shim.git", - "reference": "27db669308f957ad1909e8c4aa4b957e4cfbc6c9" + "reference": "81ccfd24baf3a10810dab1152c403981a790b837" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/27db669308f957ad1909e8c4aa4b957e4cfbc6c9", - "reference": "27db669308f957ad1909e8c4aa4b957e4cfbc6c9", + "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/81ccfd24baf3a10810dab1152c403981a790b837", + "reference": "81ccfd24baf3a10810dab1152c403981a790b837", "shasum": "" }, "require": { @@ -96,18 +143,18 @@ "description": "A tool to automatically fix PHP code style", "support": { "issues": "https://github.com/PHP-CS-Fixer/shim/issues", - "source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.63.1" + "source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.64.0" }, - "time": "2024-08-26T14:03:48+00:00" + "time": "2024-08-30T23:10:11+00:00" } ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, - "platform": [], - "platform-dev": [], + "platform": {}, + "platform-dev": {}, "platform-overrides": { "php": "8.1" }, From 1874205dda5ffe731aae174635ba3c6c1fe9e767 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Thu, 10 Oct 2024 20:15:33 +0200 Subject: [PATCH 2/3] style: apply coding-standard 1.3.1 Signed-off-by: Daniel Kesselberg --- lib/Account.php | 4 +++- lib/BackgroundJob/MigrateImportantJob.php | 2 +- lib/BackgroundJob/QuotaJob.php | 2 +- lib/BackgroundJob/SyncJob.php | 2 +- lib/BackgroundJob/TrainImportanceClassifierJob.php | 2 +- lib/Command/ExportAccount.php | 2 +- lib/Controller/AccountsController.php | 4 ++-- lib/Controller/ContactIntegrationController.php | 8 ++++---- lib/Controller/InternalAddressController.php | 10 ++++++---- lib/Controller/MessageApiController.php | 6 +++--- lib/Controller/OutboxController.php | 2 +- lib/Controller/SieveController.php | 5 +++-- lib/Db/MessageMapper.php | 10 +++++----- lib/Db/MessageSnoozeMapper.php | 5 ++++- lib/Events/MessageSentEvent.php | 6 ++++-- lib/Events/NewMessageReceivedEvent.php | 4 +++- lib/IMAP/FolderMapper.php | 4 ++-- lib/IMAP/ImapMessageFetcher.php | 3 ++- lib/Listener/AddressCollectionListener.php | 6 ++++-- lib/Listener/NewMessageClassificationListener.php | 2 +- lib/Listener/NewMessagesNotifier.php | 7 ++++--- lib/Migration/MigrateImportantFromImapAndDb.php | 2 +- lib/Migration/Version1140Date20221113205737.php | 2 +- lib/Migration/Version1140Date20221206162029.php | 2 +- lib/Migration/Version3500Date20231115182612.php | 2 +- lib/Migration/Version3600Date20240227172825.php | 4 +++- lib/Migration/Version3700Date20240430115406.php | 4 +++- lib/Migration/Version3800Date20240628163133.php | 2 +- lib/Model/EventData.php | 6 ++++-- lib/Model/IMAPMessage.php | 4 ++-- lib/Provider/Command/MessageSend.php | 2 +- lib/Provider/MailProvider.php | 8 ++++---- lib/Send/AHandler.php | 2 +- lib/Send/AntiAbuseHandler.php | 6 ++++-- lib/Send/Chain.php | 3 ++- lib/Send/CopySentMessageHandler.php | 3 ++- lib/Send/FlagRepliedMessageHandler.php | 3 ++- lib/Send/SendHandler.php | 3 ++- .../AiIntegrations/AiIntegrationsService.php | 14 +++++++------- lib/Service/AntiSpamService.php | 7 ++++--- lib/Service/Attachment/AttachmentService.php | 6 +++--- lib/Service/DkimService.php | 2 +- lib/Service/IMipService.php | 2 +- lib/Service/MailTransmission.php | 6 +++--- lib/Service/OutboxService.php | 3 ++- lib/Service/PhishingDetection/ContactCheck.php | 7 +++++-- lib/Service/PhishingDetection/CustomEmailCheck.php | 4 ++-- lib/Service/PhishingDetection/LinkCheck.php | 10 +++++----- .../PhishingDetection/PhishingDetectionService.php | 8 +++++++- lib/Service/PreprocessingService.php | 4 ++-- lib/Service/SnoozeService.php | 4 ++-- lib/Service/TransmissionService.php | 7 ++++--- tests/Unit/Service/AiIntegrationsServiceTest.php | 12 ++++++------ tests/bootstrap.php | 4 ++-- 54 files changed, 147 insertions(+), 107 deletions(-) diff --git a/lib/Account.php b/lib/Account.php index ad1697a20e..f234e4886f 100644 --- a/lib/Account.php +++ b/lib/Account.php @@ -15,7 +15,9 @@ use ReturnTypeWillChange; class Account implements JsonSerializable { - public function __construct(private MailAccount $account) { + public function __construct( + private MailAccount $account, + ) { } public function getMailAccount(): MailAccount { diff --git a/lib/BackgroundJob/MigrateImportantJob.php b/lib/BackgroundJob/MigrateImportantJob.php index c72d5b42ae..30b2dd19e4 100644 --- a/lib/BackgroundJob/MigrateImportantJob.php +++ b/lib/BackgroundJob/MigrateImportantJob.php @@ -36,7 +36,7 @@ public function __construct(MailboxMapper $mailboxMapper, MigrateImportantFromImapAndDb $migration, LoggerInterface $logger, ITimeFactory $timeFactory, - IMAPClientFactory $imapClientFactory + IMAPClientFactory $imapClientFactory, ) { parent::__construct($timeFactory); $this->mailboxMapper = $mailboxMapper; diff --git a/lib/BackgroundJob/QuotaJob.php b/lib/BackgroundJob/QuotaJob.php index 61b2527f8f..d79baed675 100644 --- a/lib/BackgroundJob/QuotaJob.php +++ b/lib/BackgroundJob/QuotaJob.php @@ -62,7 +62,7 @@ protected function run($argument): void { return; } - if(!$account->getMailAccount()->canAuthenticateImap()) { + if (!$account->getMailAccount()->canAuthenticateImap()) { $this->logger->debug('No authentication on IMAP possible, skipping quota job'); return; } diff --git a/lib/BackgroundJob/SyncJob.php b/lib/BackgroundJob/SyncJob.php index b5508a3d9c..a2e72e9491 100644 --- a/lib/BackgroundJob/SyncJob.php +++ b/lib/BackgroundJob/SyncJob.php @@ -73,7 +73,7 @@ protected function run($argument) { return; } - if(!$account->getMailAccount()->canAuthenticateImap()) { + if (!$account->getMailAccount()->canAuthenticateImap()) { $this->logger->debug('No authentication on IMAP possible, skipping background sync job'); return; } diff --git a/lib/BackgroundJob/TrainImportanceClassifierJob.php b/lib/BackgroundJob/TrainImportanceClassifierJob.php index c43d453d58..d6482cbe62 100644 --- a/lib/BackgroundJob/TrainImportanceClassifierJob.php +++ b/lib/BackgroundJob/TrainImportanceClassifierJob.php @@ -58,7 +58,7 @@ protected function run($argument) { return; } - if(!$account->getMailAccount()->canAuthenticateImap()) { + if (!$account->getMailAccount()->canAuthenticateImap()) { $this->logger->debug('Cron importance classifier training not possible: no authentication on IMAP possible'); return; } diff --git a/lib/Command/ExportAccount.php b/lib/Command/ExportAccount.php index 6039dbaf3e..8ebcc0abdb 100644 --- a/lib/Command/ExportAccount.php +++ b/lib/Command/ExportAccount.php @@ -83,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Account ' . $account->getId() . ':'); $output->writeln('- E-Mail: ' . $account->getEmail()); $output->writeln('- Name: ' . $account->getName()); - $output->writeln('- Provision: ' . ($account->getMailAccount()->getProvisioningId() ? 'set' : 'none'). ' ID: ' . ($account->getMailAccount()->getProvisioningId() ?: 'N/A')); + $output->writeln('- Provision: ' . ($account->getMailAccount()->getProvisioningId() ? 'set' : 'none') . ' ID: ' . ($account->getMailAccount()->getProvisioningId() ?: 'N/A')); $output->writeln('- IMAP user: ' . $account->getMailAccount()->getInboundUser()); $output->writeln('- IMAP host: ' . $account->getMailAccount()->getInboundHost() . ':' . $account->getMailAccount()->getInboundPort() . ', security: ' . $account->getMailAccount()->getInboundSslMode()); $output->writeln('- SMTP user: ' . $account->getMailAccount()->getOutboundUser()); diff --git a/lib/Controller/AccountsController.php b/lib/Controller/AccountsController.php index 2bfebcf3ab..e6febb7cce 100644 --- a/lib/Controller/AccountsController.php +++ b/lib/Controller/AccountsController.php @@ -65,7 +65,7 @@ public function __construct(string $appName, SyncService $syncService, IConfig $config, IRemoteHostValidator $hostValidator, - MailboxSync $mailboxSync + MailboxSync $mailboxSync, ) { parent::__construct($appName, $request); $this->accountService = $accountService; @@ -274,7 +274,7 @@ public function patchAccount(int $id, $this->mailManager->getMailbox($this->currentUserId, $junkMailboxId); $dbAccount->setJunkMailboxId($junkMailboxId); } - if($searchBody !== null) { + if ($searchBody !== null) { $dbAccount->setSearchBody($searchBody); } return new JSONResponse( diff --git a/lib/Controller/ContactIntegrationController.php b/lib/Controller/ContactIntegrationController.php index 626cc44674..108dc13bdd 100644 --- a/lib/Controller/ContactIntegrationController.php +++ b/lib/Controller/ContactIntegrationController.php @@ -85,15 +85,15 @@ public function newContact(?string $contactName = null, ?string $mail = null): J */ #[TrapError] public function autoComplete(string $term, bool $forceSAB = false): JSONResponse { - $cached = $this->cache->get($this->uid.$term); - if($cached !== null) { + $cached = $this->cache->get($this->uid . $term); + if ($cached !== null) { $decoded = json_decode($cached, true); - if($decoded !== null) { + if ($decoded !== null) { return new JSONResponse($decoded); } } $res = $this->service->autoComplete($term, $forceSAB); - $this->cache->set($this->uid.$term, json_encode($res), 24 * 3600); + $this->cache->set($this->uid . $term, json_encode($res), 24 * 3600); return new JSONResponse($res); } } diff --git a/lib/Controller/InternalAddressController.php b/lib/Controller/InternalAddressController.php index dab6fb930b..f46d33a542 100644 --- a/lib/Controller/InternalAddressController.php +++ b/lib/Controller/InternalAddressController.php @@ -21,9 +21,11 @@ class InternalAddressController extends Controller { private ?string $uid; - public function __construct(IRequest $request, + public function __construct( + IRequest $request, ?string $userId, - private InternalAddressService $internalAddressService) { + private InternalAddressService $internalAddressService, + ) { parent::__construct(Application::APP_ID, $request); $this->internalAddressService = $internalAddressService; @@ -57,7 +59,7 @@ public function setAddress(string $address, string $type): JsonResponse { */ #[TrapError] public function removeAddress(string $address, string $type): JsonResponse { - if($this->uid === null) { + if ($this->uid === null) { return JsonResponse::error('User not found', Http::STATUS_UNAUTHORIZED); } @@ -78,7 +80,7 @@ public function removeAddress(string $address, string $type): JsonResponse { */ #[TrapError] public function list(): JsonResponse { - if($this->uid === null) { + if ($this->uid === null) { return JsonResponse::error('User not found', Http::STATUS_UNAUTHORIZED); } $list = $this->internalAddressService->getInternalAddresses( diff --git a/lib/Controller/MessageApiController.php b/lib/Controller/MessageApiController.php index 417adf0230..38230139d9 100644 --- a/lib/Controller/MessageApiController.php +++ b/lib/Controller/MessageApiController.php @@ -168,7 +168,7 @@ public function send( } $recipients = array_merge($to, $cc, $bcc); - foreach($recipients as $recipient) { + foreach ($recipients as $recipient) { if (!is_array($recipient)) { return new DataResponse('Recipient address must be an array.', Http::STATUS_BAD_REQUEST); } @@ -292,7 +292,7 @@ public function get(int $id): DataResponse { $json['rawUrl'] = $this->urlGenerator->linkToOCSRouteAbsolute('mail.messageApi.getRaw', ['id' => $id]); - if(!$loadBody) { + if (!$loadBody) { return new DataResponse($json, Http::STATUS_PARTIAL_CONTENT); } @@ -427,7 +427,7 @@ public function getAttachment(int $id, string $attachmentId): DataResponse { private function handleAttachments(): array { $fileAttachments = $this->request->getUploadedFile('attachments'); $hasAttachments = isset($fileAttachments['name']); - if(!$hasAttachments) { + if (!$hasAttachments) { return []; } diff --git a/lib/Controller/OutboxController.php b/lib/Controller/OutboxController.php index e12ee31eaf..cac4da38c9 100644 --- a/lib/Controller/OutboxController.php +++ b/lib/Controller/OutboxController.php @@ -236,7 +236,7 @@ public function send(int $id): JsonResponse { $message = $this->service->sendMessage($message, $account); - if($message->getStatus() !== LocalMessage::STATUS_PROCESSED) { + if ($message->getStatus() !== LocalMessage::STATUS_PROCESSED) { return JsonResponse::error('Could not send message', Http::STATUS_INTERNAL_SERVER_ERROR, [$message]); } return JsonResponse::success( diff --git a/lib/Controller/SieveController.php b/lib/Controller/SieveController.php index 6d4ebdae06..1350c46847 100644 --- a/lib/Controller/SieveController.php +++ b/lib/Controller/SieveController.php @@ -37,7 +37,8 @@ class SieveController extends Controller { private IRemoteHostValidator $hostValidator; private LoggerInterface $logger; - public function __construct(IRequest $request, + public function __construct( + IRequest $request, string $UserId, MailAccountMapper $mailAccountMapper, SieveClientFactory $sieveClientFactory, @@ -121,7 +122,7 @@ public function updateAccount(int $id, int $sievePort, string $sieveUser, string $sievePassword, - string $sieveSslMode + string $sieveSslMode, ): JSONResponse { if (!$this->hostValidator->isValid($sieveHost)) { return MailJsonResponse::fail( diff --git a/lib/Db/MessageMapper.php b/lib/Db/MessageMapper.php index 47cf21292a..0084ecbf95 100644 --- a/lib/Db/MessageMapper.php +++ b/lib/Db/MessageMapper.php @@ -378,8 +378,8 @@ public function updateBulk(Account $account, bool $permflagsEnabled, Message ... $updateData = []; foreach ($flags as $flag) { - $updateData[$flag.'_true'] = []; - $updateData[$flag.'_false'] = []; + $updateData[$flag . '_true'] = []; + $updateData[$flag . '_false'] = []; } foreach ($messages as $message) { @@ -460,7 +460,7 @@ public function updateBulk(Account $account, bool $permflagsEnabled, Message ... $queryTrue->expr()->eq('mailbox_id', $queryTrue->createNamedParameter($mailboxId, IQueryBuilder::PARAM_INT)), $queryTrue->expr()->eq($flag, $queryTrue->createNamedParameter(0, IQueryBuilder::PARAM_INT)) )); - foreach (array_chunk($updateData[$flag.'_true'], 1000) as $chunk) { + foreach (array_chunk($updateData[$flag . '_true'], 1000) as $chunk) { $queryTrue->setParameter('uids', $chunk, IQueryBuilder::PARAM_INT_ARRAY); $queryTrue->executeStatement(); } @@ -474,7 +474,7 @@ public function updateBulk(Account $account, bool $permflagsEnabled, Message ... $queryFalse->expr()->eq('mailbox_id', $queryFalse->createNamedParameter($mailboxId, IQueryBuilder::PARAM_INT)), $queryFalse->expr()->eq($flag, $queryFalse->createNamedParameter(1, IQueryBuilder::PARAM_INT)) )); - foreach (array_chunk($updateData[$flag.'_false'], 1000) as $chunk) { + foreach (array_chunk($updateData[$flag . '_false'], 1000) as $chunk) { $queryFalse->setParameter('uids', $chunk, IQueryBuilder::PARAM_INT_ARRAY); $queryFalse->executeStatement(); } @@ -924,7 +924,7 @@ public function findIdsByQuery(Mailbox $mailbox, SearchQuery $query, string $sor if ($uids !== null) { // In the case of body+subject search we need a combination of both results, // thus the orWhere in every other case andWhere should do the job. - if(!empty($query->getSubjects())) { + if (!empty($query->getSubjects())) { $textOrs[] = $qb->expr()->in('m.uid', $qb->createParameter('uids')); } else { $select->andWhere( diff --git a/lib/Db/MessageSnoozeMapper.php b/lib/Db/MessageSnoozeMapper.php index 9c7d6a0b66..f86efd6be9 100644 --- a/lib/Db/MessageSnoozeMapper.php +++ b/lib/Db/MessageSnoozeMapper.php @@ -18,7 +18,10 @@ * @template-extends QBMapper */ class MessageSnoozeMapper extends QBMapper { - public function __construct(IDBConnection $db, private ITimeFactory $time) { + public function __construct( + IDBConnection $db, + private ITimeFactory $time, + ) { parent::__construct($db, 'mail_messages_snoozed', MessageSnooze::class); } diff --git a/lib/Events/MessageSentEvent.php b/lib/Events/MessageSentEvent.php index c2d47f16b4..b51ff7cfc8 100644 --- a/lib/Events/MessageSentEvent.php +++ b/lib/Events/MessageSentEvent.php @@ -20,8 +20,10 @@ class MessageSentEvent extends Event { /** @var Account */ private $account; - public function __construct(Account $account, - private LocalMessage $localMessage) { + public function __construct( + Account $account, + private LocalMessage $localMessage, + ) { parent::__construct(); $this->account = $account; } diff --git a/lib/Events/NewMessageReceivedEvent.php b/lib/Events/NewMessageReceivedEvent.php index 7b27b8fee7..1d63326f1c 100644 --- a/lib/Events/NewMessageReceivedEvent.php +++ b/lib/Events/NewMessageReceivedEvent.php @@ -11,7 +11,9 @@ use OCP\EventDispatcher\Event; class NewMessageReceivedEvent extends Event { - public function __construct(private string $uri) { + public function __construct( + private string $uri, + ) { parent::__construct(); } diff --git a/lib/IMAP/FolderMapper.php b/lib/IMAP/FolderMapper.php index a4815de2f3..f8892e3cf2 100644 --- a/lib/IMAP/FolderMapper.php +++ b/lib/IMAP/FolderMapper.php @@ -138,7 +138,7 @@ public function getFoldersStatusAsObject(Horde_Imap_Client_Socket $client, foreach ($multiStatus as $mailbox => $status) { try { if (!isset($status['messages'], $status['unseen'])) { - throw new ServiceException('Could not fetch stats of mailbox: '.$mailbox); + throw new ServiceException('Could not fetch stats of mailbox: ' . $mailbox); } $statuses[$mailbox] = new MailboxStats( $status['messages'], @@ -259,7 +259,7 @@ public function delete(Horde_Imap_Client_Socket $client, string $folderId): void try { $client->deleteMailbox($folderId); } catch (Horde_Imap_Client_Exception $e) { - throw new ServiceException('Could not delete mailbox: '.$e->getMessage(), 0, $e); + throw new ServiceException('Could not delete mailbox: ' . $e->getMessage(), 0, $e); } } } diff --git a/lib/IMAP/ImapMessageFetcher.php b/lib/IMAP/ImapMessageFetcher.php index e3cd701513..3b5726c445 100644 --- a/lib/IMAP/ImapMessageFetcher.php +++ b/lib/IMAP/ImapMessageFetcher.php @@ -63,7 +63,8 @@ class ImapMessageFetcher { private bool $isOneClickUnsubscribe = false; private ?string $unsubscribeMailto = null; - public function __construct(int $uid, + public function __construct( + int $uid, string $mailbox, Horde_Imap_Client_Base $client, string $userId, diff --git a/lib/Listener/AddressCollectionListener.php b/lib/Listener/AddressCollectionListener.php index eaa53245e0..5489f159ed 100644 --- a/lib/Listener/AddressCollectionListener.php +++ b/lib/Listener/AddressCollectionListener.php @@ -32,10 +32,12 @@ class AddressCollectionListener implements IEventListener { /** @var LoggerInterface */ private $logger; - public function __construct(IUserPreferences $preferences, + public function __construct( + IUserPreferences $preferences, AddressCollector $collector, LoggerInterface $logger, - private TransmissionService $transmissionService) { + private TransmissionService $transmissionService, + ) { $this->collector = $collector; $this->logger = $logger; $this->preferences = $preferences; diff --git a/lib/Listener/NewMessageClassificationListener.php b/lib/Listener/NewMessageClassificationListener.php index 780fbd3723..01c0ca5f4f 100644 --- a/lib/Listener/NewMessageClassificationListener.php +++ b/lib/Listener/NewMessageClassificationListener.php @@ -92,7 +92,7 @@ public function handle(Event $event): void { $important = $this->tagMapper->getTagByImapLabel(Tag::LABEL_IMPORTANT, $event->getAccount()->getUserId()); } catch (DoesNotExistException $e) { // just in case - if we get here, the tag is missing - $this->logger->error('Could not find important tag for ' . $event->getAccount()->getUserId(). ' ' . $e->getMessage(), [ + $this->logger->error('Could not find important tag for ' . $event->getAccount()->getUserId() . ' ' . $e->getMessage(), [ 'exception' => $e, ]); return; diff --git a/lib/Listener/NewMessagesNotifier.php b/lib/Listener/NewMessagesNotifier.php index def7380f2f..c6be5db3d9 100644 --- a/lib/Listener/NewMessagesNotifier.php +++ b/lib/Listener/NewMessagesNotifier.php @@ -21,7 +21,8 @@ */ class NewMessagesNotifier implements IEventListener { - public function __construct(private IEventDispatcher $eventDispatcher, + public function __construct( + private IEventDispatcher $eventDispatcher, private IURLGenerator $urlGenerator, ) { } @@ -29,12 +30,12 @@ public function __construct(private IEventDispatcher $eventDispatcher, * @inheritDoc */ public function handle(Event $event): void { - if(!$event instanceof NewMessagesSynchronized) { + if (!$event instanceof NewMessagesSynchronized) { return; } /** @var Message $message */ - foreach($event->getMessages() as $message) { + foreach ($event->getMessages() as $message) { $uri = $this->urlGenerator->linkToOCSRouteAbsolute('mail.messageApi.get', ['id' => $message->getId()]); $this->eventDispatcher->dispatchTyped(new NewMessageReceivedEvent($uri)); } diff --git a/lib/Migration/MigrateImportantFromImapAndDb.php b/lib/Migration/MigrateImportantFromImapAndDb.php index 3216f1f692..f8da7cd798 100644 --- a/lib/Migration/MigrateImportantFromImapAndDb.php +++ b/lib/Migration/MigrateImportantFromImapAndDb.php @@ -35,7 +35,7 @@ class MigrateImportantFromImapAndDb { public function __construct(MessageMapper $messageMapper, MailboxMapper $mailboxMapper, - LoggerInterface $logger + LoggerInterface $logger, ) { $this->messageMapper = $messageMapper; $this->mailboxMapper = $mailboxMapper; diff --git a/lib/Migration/Version1140Date20221113205737.php b/lib/Migration/Version1140Date20221113205737.php index 1e19e05488..ce51713e96 100644 --- a/lib/Migration/Version1140Date20221113205737.php +++ b/lib/Migration/Version1140Date20221113205737.php @@ -21,7 +21,7 @@ class Version1140Date20221113205737 extends SimpleMigrationStep { public function __construct( MessageMapper $messageMapper, - LoggerInterface $logger + LoggerInterface $logger, ) { $this->logger = $logger; $this->messageMapper = $messageMapper; diff --git a/lib/Migration/Version1140Date20221206162029.php b/lib/Migration/Version1140Date20221206162029.php index 02234f420c..772659baba 100644 --- a/lib/Migration/Version1140Date20221206162029.php +++ b/lib/Migration/Version1140Date20221206162029.php @@ -21,7 +21,7 @@ class Version1140Date20221206162029 extends SimpleMigrationStep { public function __construct( MessageMapper $messageMapper, - LoggerInterface $logger + LoggerInterface $logger, ) { $this->logger = $logger; $this->messageMapper = $messageMapper; diff --git a/lib/Migration/Version3500Date20231115182612.php b/lib/Migration/Version3500Date20231115182612.php index d5556bd3e0..728ed7d76d 100644 --- a/lib/Migration/Version3500Date20231115182612.php +++ b/lib/Migration/Version3500Date20231115182612.php @@ -19,7 +19,7 @@ class Version3500Date20231115182612 extends SimpleMigrationStep { public function __construct( - private IDBConnection $connection + private IDBConnection $connection, ) { } diff --git a/lib/Migration/Version3600Date20240227172825.php b/lib/Migration/Version3600Date20240227172825.php index 58d9f2d950..c413173507 100644 --- a/lib/Migration/Version3600Date20240227172825.php +++ b/lib/Migration/Version3600Date20240227172825.php @@ -17,7 +17,9 @@ class Version3600Date20240227172825 extends SimpleMigrationStep { - public function __construct(private IAppConfig $appConfig) { + public function __construct( + private IAppConfig $appConfig, + ) { } /** diff --git a/lib/Migration/Version3700Date20240430115406.php b/lib/Migration/Version3700Date20240430115406.php index 6ce31c0478..24eefd77ca 100644 --- a/lib/Migration/Version3700Date20240430115406.php +++ b/lib/Migration/Version3700Date20240430115406.php @@ -20,7 +20,9 @@ class Version3700Date20240430115406 extends SimpleMigrationStep { - public function __construct(private IDBConnection $connection) { + public function __construct( + private IDBConnection $connection, + ) { } /** diff --git a/lib/Migration/Version3800Date20240628163133.php b/lib/Migration/Version3800Date20240628163133.php index dda7d691e2..a76fc0cbc4 100644 --- a/lib/Migration/Version3800Date20240628163133.php +++ b/lib/Migration/Version3800Date20240628163133.php @@ -19,7 +19,7 @@ class Version3800Date20240628163133 extends SimpleMigrationStep { public function __construct( - private IDBConnection $connection + private IDBConnection $connection, ) { } diff --git a/lib/Model/EventData.php b/lib/Model/EventData.php index 2248331512..2b3be5bc7d 100644 --- a/lib/Model/EventData.php +++ b/lib/Model/EventData.php @@ -14,8 +14,10 @@ class EventData implements JsonSerializable { - public function __construct(private string $summary, - private string $description) { + public function __construct( + private string $summary, + private string $description, + ) { } public function getSummary(): string { diff --git a/lib/Model/IMAPMessage.php b/lib/Model/IMAPMessage.php index e87e0236cc..6f172b912c 100644 --- a/lib/Model/IMAPMessage.php +++ b/lib/Model/IMAPMessage.php @@ -276,7 +276,7 @@ public function getFullMessage(int $id, bool $loadBody = true): array { $mailBody = $this->plainMessage; $data = $this->jsonSerialize(); - if($this->hasHtmlMessage && $loadBody) { + if ($this->hasHtmlMessage && $loadBody) { $data['body'] = $this->getHtmlBody($id); } @@ -290,7 +290,7 @@ public function getFullMessage(int $id, bool $loadBody = true): array { [$mailBody, $signature] = $this->htmlService->parseMailBody($mailBody); $data['signature'] = $signature; $data['attachments'] = array_merge($this->attachments, $this->inlineAttachments); - if($loadBody) { + if ($loadBody) { $data['body'] = $mailBody; } return $data; diff --git a/lib/Provider/Command/MessageSend.php b/lib/Provider/Command/MessageSend.php index 6f747135a2..4d5275da6e 100644 --- a/lib/Provider/Command/MessageSend.php +++ b/lib/Provider/Command/MessageSend.php @@ -26,7 +26,7 @@ public function __construct( protected ITimeFactory $time, protected AccountService $accountService, protected OutboxService $outboxService, - protected AttachmentService $attachmentService + protected AttachmentService $attachmentService, ) { } diff --git a/lib/Provider/MailProvider.php b/lib/Provider/MailProvider.php index 29877ef17c..9c4d082b50 100644 --- a/lib/Provider/MailProvider.php +++ b/lib/Provider/MailProvider.php @@ -24,7 +24,7 @@ public function __construct( protected ContainerInterface $container, protected AccountService $accountService, protected LoggerInterface $logger, - protected IL10N $l10n + protected IL10N $l10n, ) { } @@ -96,7 +96,7 @@ public function listServices(string $userId): array { * @return IService|null returns service object or null if none found * */ - public function findServiceById(string $userId, string $serviceId): IService|null { + public function findServiceById(string $userId, string $serviceId): ?IService { // determine if a valid user and service id was submitted if (empty($userId) && !ctype_digit($serviceId)) { return null; @@ -104,7 +104,7 @@ public function findServiceById(string $userId, string $serviceId): IService|nul // retrieve service details from data store try { $account = $this->accountService->find($userId, (int)$serviceId); - } catch(ClientException $e) { + } catch (ClientException $e) { $this->logger->error('Error occurred while retrieving mail account details', [ 'exception' => $e ]); return null; } @@ -122,7 +122,7 @@ public function findServiceById(string $userId, string $serviceId): IService|nul * * @return IService|null returns service object or null if none found */ - public function findServiceByAddress(string $userId, string $address): IService|null { + public function findServiceByAddress(string $userId, string $address): ?IService { // retrieve service details from data store $accounts = $this->accountService->findByUserIdAndAddress($userId, $address); // evaluate if service details where found diff --git a/lib/Send/AHandler.php b/lib/Send/AHandler.php index e687ce993f..420f9ee878 100644 --- a/lib/Send/AHandler.php +++ b/lib/Send/AHandler.php @@ -12,7 +12,7 @@ abstract class AHandler { - protected AHandler|null $next = null; + protected ?AHandler $next = null; public function setNext(AHandler $next): AHandler { $this->next = $next; return $next; diff --git a/lib/Send/AntiAbuseHandler.php b/lib/Send/AntiAbuseHandler.php index 5d176f109c..6141e7e5c0 100644 --- a/lib/Send/AntiAbuseHandler.php +++ b/lib/Send/AntiAbuseHandler.php @@ -15,9 +15,11 @@ class AntiAbuseHandler extends AHandler { - public function __construct(private IUserManager $userManager, + public function __construct( + private IUserManager $userManager, private AntiAbuseService $service, - private LoggerInterface $logger) { + private LoggerInterface $logger, + ) { } public function process(Account $account, LocalMessage $localMessage): LocalMessage { if ($localMessage->getStatus() === LocalMessage::STATUS_IMAP_SENT_MAILBOX_FAIL diff --git a/lib/Send/Chain.php b/lib/Send/Chain.php index b8d2c97094..c851359b2a 100644 --- a/lib/Send/Chain.php +++ b/lib/Send/Chain.php @@ -15,7 +15,8 @@ use OCP\DB\Exception; class Chain { - public function __construct(private SentMailboxHandler $sentMailboxHandler, + public function __construct( + private SentMailboxHandler $sentMailboxHandler, private AntiAbuseHandler $antiAbuseHandler, private SendHandler $sendHandler, private CopySentMessageHandler $copySentMessageHandler, diff --git a/lib/Send/CopySentMessageHandler.php b/lib/Send/CopySentMessageHandler.php index 38b62d67ed..1206e9c7c4 100644 --- a/lib/Send/CopySentMessageHandler.php +++ b/lib/Send/CopySentMessageHandler.php @@ -17,7 +17,8 @@ use Psr\Log\LoggerInterface; class CopySentMessageHandler extends AHandler { - public function __construct(private IMAPClientFactory $imapClientFactory, + public function __construct( + private IMAPClientFactory $imapClientFactory, private MailboxMapper $mailboxMapper, private LoggerInterface $logger, private MessageMapper $messageMapper, diff --git a/lib/Send/FlagRepliedMessageHandler.php b/lib/Send/FlagRepliedMessageHandler.php index a56b1c1176..7c058bfc42 100644 --- a/lib/Send/FlagRepliedMessageHandler.php +++ b/lib/Send/FlagRepliedMessageHandler.php @@ -19,7 +19,8 @@ use Psr\Log\LoggerInterface; class FlagRepliedMessageHandler extends AHandler { - public function __construct(private IMAPClientFactory $imapClientFactory, + public function __construct( + private IMAPClientFactory $imapClientFactory, private MailboxMapper $mailboxMapper, private LoggerInterface $logger, private MessageMapper $messageMapper, diff --git a/lib/Send/SendHandler.php b/lib/Send/SendHandler.php index c3e2edaea0..09e007067c 100644 --- a/lib/Send/SendHandler.php +++ b/lib/Send/SendHandler.php @@ -12,7 +12,8 @@ use OCA\Mail\Db\LocalMessage; class SendHandler extends AHandler { - public function __construct(private IMailTransmission $transmission, + public function __construct( + private IMailTransmission $transmission, ) { } diff --git a/lib/Service/AiIntegrations/AiIntegrationsService.php b/lib/Service/AiIntegrations/AiIntegrationsService.php index dcadf0b7d3..afd41fa19d 100644 --- a/lib/Service/AiIntegrations/AiIntegrationsService.php +++ b/lib/Service/AiIntegrations/AiIntegrationsService.php @@ -71,18 +71,18 @@ public function __construct(ContainerInterface $container, Cache $cache, IMAPCli * * @throws ServiceException */ - public function summarizeThread(Account $account, string $threadId, array $messages, string $currentUserId): null|string { + public function summarizeThread(Account $account, string $threadId, array $messages, string $currentUserId): ?string { try { $manager = $this->container->get(IManager::class); } catch (\Throwable $e) { throw new ServiceException('Text processing is not available in your current Nextcloud version', 0, $e); } - if(in_array(SummaryTaskType::class, $manager->getAvailableTaskTypes(), true)) { + if (in_array(SummaryTaskType::class, $manager->getAvailableTaskTypes(), true)) { $messageIds = array_map(function ($message) { return $message->getMessageId(); }, $messages); $cachedSummary = $this->cache->getValue($this->cache->buildUrlKey($messageIds)); - if($cachedSummary) { + if ($cachedSummary) { return $cachedSummary; } $client = $this->clientFactory->getClient($account); @@ -171,7 +171,7 @@ public function getSmartReply(Account $account, Mailbox $mailbox, Message $messa throw new ServiceException('Text processing is not available in your current Nextcloud version', 0, $e); } if (in_array(FreePromptTaskType::class, $manager->getAvailableTaskTypes(), true)) { - $cachedReplies = $this->cache->getValue('smartReplies_'.$message->getId()); + $cachedReplies = $this->cache->getValue('smartReplies_' . $message->getId()); if ($cachedReplies) { return json_decode($cachedReplies, true, 512); } @@ -199,7 +199,7 @@ public function getSmartReply(Account $account, Mailbox $mailbox, Message $messa Here is the ***E-MAIL*** for which you must suggest the replies to: - ***START_OF_E-MAIL***".$messageBody." + ***START_OF_E-MAIL***" . $messageBody . " ***END_OF_E-MAIL*** @@ -210,7 +210,7 @@ public function getSmartReply(Account $account, Mailbox $mailbox, Message $messa $replies = $task->getOutput(); try { $decoded = json_decode($replies, true, 512, JSON_THROW_ON_ERROR); - $this->cache->addValue('smartReplies_'.$message->getId(), $replies); + $this->cache->addValue('smartReplies_' . $message->getId(), $replies); return $decoded; } catch (JsonException $e) { throw new ServiceException('Failed to decode smart replies JSON output', $e); @@ -318,7 +318,7 @@ private function isPersonalEmail(IMAPMessage $imapMessage): bool { $senderAddress = $imapMessage->getFrom()->first()?->getEmail(); - if($senderAddress !== null) { + if ($senderAddress !== null) { foreach ($commonPatterns as $pattern) { if (stripos($senderAddress, $pattern) !== false) { return false; diff --git a/lib/Service/AntiSpamService.php b/lib/Service/AntiSpamService.php index 8a063fcc2b..4147abe619 100644 --- a/lib/Service/AntiSpamService.php +++ b/lib/Service/AntiSpamService.php @@ -32,7 +32,8 @@ class AntiSpamService { private const NAME = 'antispam_reporting'; private const MESSAGE_TYPE = 'message/rfc822'; - public function __construct(private IConfig $config, + public function __construct( + private IConfig $config, private MessageMapper $dbMessageMapper, private MailManager $mailManager, private IMAPClientFactory $imapClientFactory, @@ -47,7 +48,7 @@ public function getSpamEmail(): string { } public function getHamEmail(): string { - return $this->config->getAppValue('mail', self::NAME. '_ham'); + return $this->config->getAppValue('mail', self::NAME . '_ham'); } public function getSpamSubject(): string { @@ -63,7 +64,7 @@ public function setSpamEmail(string $email): void { } public function setHamEmail(string $email): void { - $this->config->setAppValue('mail', self::NAME. '_ham', $email); + $this->config->setAppValue('mail', self::NAME . '_ham', $email); } public function deleteConfig(): void { diff --git a/lib/Service/Attachment/AttachmentService.php b/lib/Service/Attachment/AttachmentService.php index a6f5666a4d..155b4d38c3 100644 --- a/lib/Service/Attachment/AttachmentService.php +++ b/lib/Service/Attachment/AttachmentService.php @@ -336,8 +336,8 @@ private function hasDownloadPermissions(File $file, string $fileName): bool { $share = $storage->getShare(); $attributes = $share->getAttributes(); - if($attributes->getAttribute('permissions', 'download') === false) { - $this->logger->warning('Could not create attachment, no download permission for file: '.$fileName); + if ($attributes->getAttribute('permissions', 'download') === false) { + $this->logger->warning('Could not create attachment, no download permission for file: ' . $fileName); return false; } @@ -364,7 +364,7 @@ private function handleCloudAttachment(Account $account, array $attachment): ?in if (!$file instanceof File) { return null; } - if(!$this->hasDownloadPermissions($file, $fileName)) { + if (!$this->hasDownloadPermissions($file, $fileName)) { return null; } diff --git a/lib/Service/DkimService.php b/lib/Service/DkimService.php index d55af887d3..d0b0502a3a 100644 --- a/lib/Service/DkimService.php +++ b/lib/Service/DkimService.php @@ -38,7 +38,7 @@ public function __construct( IMAPClientFactory $clientFactory, MessageMapper $messageMapper, ICacheFactory $cacheFactory, - IDkimValidator $dkimValidator + IDkimValidator $dkimValidator, ) { $this->clientFactory = $clientFactory; $this->messageMapper = $messageMapper; diff --git a/lib/Service/IMipService.php b/lib/Service/IMipService.php index b23f2de22d..88617bccd1 100644 --- a/lib/Service/IMipService.php +++ b/lib/Service/IMipService.php @@ -34,7 +34,7 @@ public function __construct( LoggerInterface $logger, MailboxMapper $mailboxMapper, MailManager $mailManager, - MessageMapper $messageMapper + MessageMapper $messageMapper, ) { $this->accountService = $accountService; $this->calendarManager = $manager; diff --git a/lib/Service/MailTransmission.php b/lib/Service/MailTransmission.php index 0cdbded2e8..029f3ab828 100644 --- a/lib/Service/MailTransmission.php +++ b/lib/Service/MailTransmission.php @@ -66,7 +66,7 @@ public function __construct( private LoggerInterface $logger, private PerformanceLogger $performanceLogger, private AliasesService $aliasesService, - private TransmissionService $transmissionService + private TransmissionService $transmissionService, ) { } @@ -348,7 +348,7 @@ public function sendMdn(Account $account, Mailbox $mailbox, Message $message): v } if (count($fetchResults) < 1) { - throw new ServiceException('Message "' .$message->getId() . '" not found.'); + throw new ServiceException('Message "' . $message->getId() . '" not found.'); } $imapDate = $fetchResults[0]->getImapDate(); @@ -360,7 +360,7 @@ public function sendMdn(Account $account, Mailbox $mailbox, Message $message): v $originalRecipient = $mdnHeaders->getHeader('original-recipient'); if ($dispositionNotificationTo === null) { - throw new ServiceException('Message "' .$message->getId() . '" has no disposition-notification-to header.'); + throw new ServiceException('Message "' . $message->getId() . '" has no disposition-notification-to header.'); } $headers = new Horde_Mime_Headers(); diff --git a/lib/Service/OutboxService.php b/lib/Service/OutboxService.php index ff214a4dce..708e2640e8 100644 --- a/lib/Service/OutboxService.php +++ b/lib/Service/OutboxService.php @@ -56,7 +56,8 @@ class OutboxService { /** @var LoggerInterface */ private $logger; - public function __construct(IMailTransmission $transmission, + public function __construct( + IMailTransmission $transmission, LocalMessageMapper $mapper, AttachmentService $attachmentService, IEventDispatcher $eventDispatcher, diff --git a/lib/Service/PhishingDetection/ContactCheck.php b/lib/Service/PhishingDetection/ContactCheck.php index 9c7609b6e5..196d64d38d 100644 --- a/lib/Service/PhishingDetection/ContactCheck.php +++ b/lib/Service/PhishingDetection/ContactCheck.php @@ -14,7 +14,10 @@ use OCP\IL10N; class ContactCheck { - public function __construct(private ContactsIntegration $contactIntegration, private IL10N $l10n) { + public function __construct( + private ContactsIntegration $contactIntegration, + private IL10N $l10n, + ) { $this->l10n = $l10n; $this->contactIntegration = $contactIntegration; } @@ -23,7 +26,7 @@ public function run(string $fn, string $email): PhishingDetectionResult { $emails = []; $contacts = $this->contactIntegration->getContactsWithName($fn, true); foreach ($contacts as $contact) { - if(!isset($contact['email'])) { + if (!isset($contact['email'])) { continue; } foreach ($contact['email'] as $contactEmail) { diff --git a/lib/Service/PhishingDetection/CustomEmailCheck.php b/lib/Service/PhishingDetection/CustomEmailCheck.php index 82f2375978..ed99d18714 100644 --- a/lib/Service/PhishingDetection/CustomEmailCheck.php +++ b/lib/Service/PhishingDetection/CustomEmailCheck.php @@ -20,10 +20,10 @@ public function __construct(IL10N $l10n) { } public function run(string $fromEmail, ?string $customEmail): PhishingDetectionResult { - if(!(isset($customEmail))) { + if (!(isset($customEmail))) { return new PhishingDetectionResult(PhishingDetectionResult::CUSTOM_EMAIL_CHECK, false); } - if($fromEmail === $customEmail) { + if ($fromEmail === $customEmail) { return new PhishingDetectionResult(PhishingDetectionResult::CUSTOM_EMAIL_CHECK, false); } return new PhishingDetectionResult(PhishingDetectionResult::CUSTOM_EMAIL_CHECK, true, $this->l10n->t('Sender is using a custom email: %1$s instead of the sender email: %2$s', [$customEmail, $fromEmail])); diff --git a/lib/Service/PhishingDetection/LinkCheck.php b/lib/Service/PhishingDetection/LinkCheck.php index 888188c4a7..e92ad60fa5 100644 --- a/lib/Service/PhishingDetection/LinkCheck.php +++ b/lib/Service/PhishingDetection/LinkCheck.php @@ -41,8 +41,8 @@ private function getInnerText(\DOMElement $node) : string { } private function parse(string $url): string { - if(!str_contains($url, '://')) { - return 'http://'.$url; + if (!str_contains($url, '://')) { + return 'http://' . $url; } return $url; } @@ -68,8 +68,8 @@ public function run(string $htmlMessage) : PhishingDetectionResult { foreach ($zippedArray as $zipped) { $un = new Normalizer($zipped['href']); $url = $un->normalize(); - if($this->textLooksLikeALink($zipped['linkText'])) { - if(parse_url($this->parse($url), PHP_URL_HOST) !== parse_url($this->parse($zipped['linkText']), PHP_URL_HOST)) { + if ($this->textLooksLikeALink($zipped['linkText'])) { + if (parse_url($this->parse($url), PHP_URL_HOST) !== parse_url($this->parse($zipped['linkText']), PHP_URL_HOST)) { $results[] = [ 'href' => $url, 'linkText' => $zipped['linkText'], @@ -77,7 +77,7 @@ public function run(string $htmlMessage) : PhishingDetectionResult { } } } - if(count($results) > 0) { + if (count($results) > 0) { return new PhishingDetectionResult(PhishingDetectionResult::LINK_CHECK, true, $this->l10n->t('Some addresses in this message are not matching the link text'), $results); } return new PhishingDetectionResult(PhishingDetectionResult::LINK_CHECK, false); diff --git a/lib/Service/PhishingDetection/PhishingDetectionService.php b/lib/Service/PhishingDetection/PhishingDetectionService.php index 9b0852a664..92d489d51e 100644 --- a/lib/Service/PhishingDetection/PhishingDetectionService.php +++ b/lib/Service/PhishingDetection/PhishingDetectionService.php @@ -14,7 +14,13 @@ use OCA\Mail\PhishingDetectionList; class PhishingDetectionService { - public function __construct(private ContactCheck $contactCheck, private CustomEmailCheck $customEmailCheck, private DateCheck $dateCheck, private ReplyToCheck $replyToCheck, private LinkCheck $linkCheck) { + public function __construct( + private ContactCheck $contactCheck, + private CustomEmailCheck $customEmailCheck, + private DateCheck $dateCheck, + private ReplyToCheck $replyToCheck, + private LinkCheck $linkCheck, + ) { $this->contactCheck = $contactCheck; $this->customEmailCheck = $customEmailCheck; $this->dateCheck = $dateCheck; diff --git a/lib/Service/PreprocessingService.php b/lib/Service/PreprocessingService.php index b1d07e09ab..ed8f46e00f 100644 --- a/lib/Service/PreprocessingService.php +++ b/lib/Service/PreprocessingService.php @@ -24,7 +24,7 @@ public function __construct( MessageMapper $messageMapper, LoggerInterface $logger, MailboxMapper $mailboxMapper, - PreviewEnhancer $previewEnhancer + PreviewEnhancer $previewEnhancer, ) { $this->messageMapper = $messageMapper; $this->logger = $logger; @@ -43,7 +43,7 @@ public function process(int $limitTimestamp, Account $account): void { }, $mailboxes)); $messages = []; - foreach(array_chunk($mailboxIds, 1000) as $chunk) { + foreach (array_chunk($mailboxIds, 1000) as $chunk) { $messages = array_merge($messages, $this->messageMapper->getUnanalyzed($limitTimestamp, $chunk)); } if ($messages === []) { diff --git a/lib/Service/SnoozeService.php b/lib/Service/SnoozeService.php index d8863c2b69..37d4cdb974 100644 --- a/lib/Service/SnoozeService.php +++ b/lib/Service/SnoozeService.php @@ -83,7 +83,7 @@ public function snoozeMessage( Account $srcAccount, Mailbox $srcMailbox, Account $dstAccount, - Mailbox $dstMailbox + Mailbox $dstMailbox, ): void { $newUid = $this->mailManager->moveMessage( $srcAccount, @@ -161,7 +161,7 @@ public function snoozeThread( Account $srcAccount, Mailbox $srcMailbox, Account $dstAccount, - Mailbox $dstMailbox + Mailbox $dstMailbox, ): void { $newUids = $this->mailManager->moveThread( $srcAccount, diff --git a/lib/Service/TransmissionService.php b/lib/Service/TransmissionService.php index 1b6ccb6c06..05ea0d819b 100644 --- a/lib/Service/TransmissionService.php +++ b/lib/Service/TransmissionService.php @@ -23,7 +23,8 @@ class TransmissionService { - public function __construct(private GroupsIntegration $groupsIntegration, + public function __construct( + private GroupsIntegration $groupsIntegration, private AttachmentService $attachmentService, private LoggerInterface $logger, private SmimeService $smimeService, @@ -55,7 +56,7 @@ static function ($recipient) use ($type) { * @return array|array[] */ public function getAttachments(LocalMessage $message): array { - if(empty($message->getAttachments())) { + if (empty($message->getAttachments())) { return []; } return array_map(static function (LocalAttachment $attachment) { @@ -97,7 +98,7 @@ public function handleAttachment(Account $account, array $attachment): ?\Horde_M $contentTypeHeader->decode($localAttachment->getMimeType()); $part->setType($contentTypeHeader->value); - foreach($contentTypeHeader->params as $label => $data) { + foreach ($contentTypeHeader->params as $label => $data) { $part->setContentTypeParameter($label, $data); } diff --git a/tests/Unit/Service/AiIntegrationsServiceTest.php b/tests/Unit/Service/AiIntegrationsServiceTest.php index 1e1545f5f2..ffa8ba4b1a 100644 --- a/tests/Unit/Service/AiIntegrationsServiceTest.php +++ b/tests/Unit/Service/AiIntegrationsServiceTest.php @@ -80,7 +80,7 @@ protected function setUp(): void { public function testSummarizeThreadNoBackend() { $account = new Account(new MailAccount()); $mailbox = new Mailbox(); - if($this->manager !== null) { + if ($this->manager !== null) { $this->container->method('get')->willReturn($this->manager); $this->manager ->method('getAvailableTaskTypes') @@ -101,7 +101,7 @@ public function testSmartReplyNoBackend() { $account = new Account(new MailAccount()); $mailbox = new Mailbox(); $message = new Message(); - if($this->manager !== null) { + if ($this->manager !== null) { $this->container->method('get')->willReturn($this->manager); $this->manager ->method('getAvailableTaskTypes') @@ -126,7 +126,7 @@ public function testGeneratedMessage() { $addessList = $this->createMock(AddressList::class); $addessList->method('first')->willreturn('normal@email.com'); $this->mailManager->method('getImapMessage')->willReturn($imapMessage); - if($this->manager !== null) { + if ($this->manager !== null) { $this->container->method('get')->willReturn($this->manager); $this->manager ->method('getAvailableTaskTypes') @@ -152,7 +152,7 @@ public function testGeneratedMessage() { } public function testLlmAvailable() { - if($this->manager !== null) { + if ($this->manager !== null) { $this->container->method('get')->willReturn($this->manager); $this->manager ->method('getAvailableTaskTypes') @@ -168,7 +168,7 @@ public function testLlmAvailable() { } public function testLlmUnavailable() { - if($this->manager !== null) { + if ($this->manager !== null) { $this->container->method('get')->willReturn($this->manager); $this->manager ->method('getAvailableTaskTypes') @@ -222,7 +222,7 @@ public function testCached() { $message3->setThreadRootId('some-thread-root-id-1'); $messages = [ $message1,$message2,$message3]; - if($this->manager !== null) { + if ($this->manager !== null) { $this->container->method('get')->willReturn($this->manager); $this->manager ->method('getAvailableTaskTypes') diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 6be6db263a..972e45933b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -8,8 +8,8 @@ */ define('PHPUNIT_RUN', 1); -require_once __DIR__.'/../../../lib/base.php'; -require_once __DIR__.'/../vendor/autoload.php'; +require_once __DIR__ . '/../../../lib/base.php'; +require_once __DIR__ . '/../vendor/autoload.php'; \OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); \OC_App::loadApp('mail'); From 567d4c634f4fb541aa24148f49066e6ceb159308 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Thu, 10 Oct 2024 20:16:26 +0200 Subject: [PATCH 3/3] chore: ignore code style changes in git blame Signed-off-by: Daniel Kesselberg --- .git-blame-ignore-revs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index d554e658c3..549b13b5d9 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -5,3 +5,5 @@ # Update to coding-standard 1.2.3 94ac6cf8c60f86d3de7aa25525a4659e6210f60b +# Update to coding-standard 1.3.1 +1874205dda5ffe731aae174635ba3c6c1fe9e767