Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hello coding-standard 1.3.1 #10246

Merged
merged 3 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@

# Update to coding-standard 1.2.3
94ac6cf8c60f86d3de7aa25525a4659e6210f60b
# Update to coding-standard 1.3.1
1874205dda5ffe731aae174635ba3c6c1fe9e767
4 changes: 3 additions & 1 deletion lib/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lib/BackgroundJob/MigrateImportantJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/BackgroundJob/QuotaJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/BackgroundJob/SyncJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/BackgroundJob/TrainImportanceClassifierJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Command/ExportAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln('<info>Account ' . $account->getId() . ':</info>');
$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());
Expand Down
4 changes: 2 additions & 2 deletions lib/Controller/AccountsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions lib/Controller/ContactIntegrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
10 changes: 6 additions & 4 deletions lib/Controller/InternalAddressController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand All @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions lib/Controller/MessageApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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 [];
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/OutboxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 3 additions & 2 deletions lib/Controller/SieveController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions lib/Db/MessageMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 4 additions & 1 deletion lib/Db/MessageSnoozeMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
* @template-extends QBMapper<MessageSnooze>
*/
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);
}

Expand Down
6 changes: 4 additions & 2 deletions lib/Events/MessageSentEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion lib/Events/NewMessageReceivedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions lib/IMAP/FolderMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -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);
}
}
}
3 changes: 2 additions & 1 deletion lib/IMAP/ImapMessageFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions lib/Listener/AddressCollectionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/Listener/NewMessageClassificationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions lib/Listener/NewMessagesNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@
*/
class NewMessagesNotifier implements IEventListener {

public function __construct(private IEventDispatcher $eventDispatcher,
public function __construct(
private IEventDispatcher $eventDispatcher,
private IURLGenerator $urlGenerator,
) {
}
/**
* @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));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/MigrateImportantFromImapAndDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MigrateImportantFromImapAndDb {

public function __construct(MessageMapper $messageMapper,
MailboxMapper $mailboxMapper,
LoggerInterface $logger
LoggerInterface $logger,
) {
$this->messageMapper = $messageMapper;
$this->mailboxMapper = $mailboxMapper;
Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version1140Date20221113205737.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Version1140Date20221113205737 extends SimpleMigrationStep {

public function __construct(
MessageMapper $messageMapper,
LoggerInterface $logger
LoggerInterface $logger,
) {
$this->logger = $logger;
$this->messageMapper = $messageMapper;
Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version1140Date20221206162029.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Version1140Date20221206162029 extends SimpleMigrationStep {

public function __construct(
MessageMapper $messageMapper,
LoggerInterface $logger
LoggerInterface $logger,
) {
$this->logger = $logger;
$this->messageMapper = $messageMapper;
Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version3500Date20231115182612.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class Version3500Date20231115182612 extends SimpleMigrationStep {

public function __construct(
private IDBConnection $connection
private IDBConnection $connection,
) {
}

Expand Down
4 changes: 3 additions & 1 deletion lib/Migration/Version3600Date20240227172825.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

class Version3600Date20240227172825 extends SimpleMigrationStep {

public function __construct(private IAppConfig $appConfig) {
public function __construct(
private IAppConfig $appConfig,
) {
}

/**
Expand Down
4 changes: 3 additions & 1 deletion lib/Migration/Version3700Date20240430115406.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

class Version3700Date20240430115406 extends SimpleMigrationStep {

public function __construct(private IDBConnection $connection) {
public function __construct(
private IDBConnection $connection,
) {
}

/**
Expand Down
Loading
Loading