chore(php): Refactor empty array check

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2023-05-10 18:21:52 +02:00
Родитель 457c36f0fc
Коммит 82a1233c94
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: CC42AC2A7F0E56D8
29 изменённых файлов: 59 добавлений и 59 удалений

Просмотреть файл

@ -88,7 +88,7 @@ class AddressList implements Countable, JsonSerializable {
* @return Address|null * @return Address|null
*/ */
public function first() { public function first() {
if (empty($this->addresses)) { if ($this->addresses === []) {
return null; return null;
} }
@ -135,7 +135,7 @@ class AddressList implements Countable, JsonSerializable {
// Check whether our array contains the other address // Check whether our array contains the other address
return $our->equals($address); return $our->equals($address);
}); });
if (empty($same)) { if ($same === []) {
// No dup found, hence the address is new and we // No dup found, hence the address is new and we
// have to add it // have to add it
$addresses[] = $address; $addresses[] = $address;

Просмотреть файл

@ -158,7 +158,7 @@ class Cache extends Horde_Imap_Client_Cache_Backend {
return $ret; return $ret;
} }
if (!empty($fields)) { if ($fields !== []) {
$fields = array_flip($fields); $fields = array_flip($fields);
} }
$ptr = &$this->_data[$mailbox]; $ptr = &$this->_data[$mailbox];
@ -171,7 +171,7 @@ class Cache extends Horde_Imap_Client_Cache_Backend {
} }
} }
$ret[$val] = (empty($fields) || empty($ptr[$val])) $ret[$val] = ($fields === [] || empty($ptr[$val]))
? $ptr[$val] ? $ptr[$val]
: array_intersect_key($ptr[$val], $fields); : array_intersect_key($ptr[$val], $fields);
} }
@ -234,7 +234,7 @@ class Cache extends Horde_Imap_Client_Cache_Backend {
public function getMetaData($mailbox, $uidvalid, $entries) { public function getMetaData($mailbox, $uidvalid, $entries) {
$this->_loadSliceMap($mailbox, $uidvalid); $this->_loadSliceMap($mailbox, $uidvalid);
return empty($entries) return $entries === []
? $this->_slicemap[$mailbox]['d'] ? $this->_slicemap[$mailbox]['d']
: array_intersect_key($this->_slicemap[$mailbox]['d'], array_flip($entries)); : array_intersect_key($this->_slicemap[$mailbox]['d'], array_flip($entries));
} }
@ -268,7 +268,7 @@ class Cache extends Horde_Imap_Client_Cache_Backend {
); );
} }
if (empty($deleted)) { if ($deleted === []) {
return; return;
} }

Просмотреть файл

@ -65,7 +65,7 @@ class AddMissingTags extends Command {
if ($accountId === 0) { if ($accountId === 0) {
$accounts = $this->mapper->getAllAccounts(); $accounts = $this->mapper->getAllAccounts();
$output->writeln(sprintf('%d accounts to check found', count($accounts))); $output->writeln(sprintf('%d accounts to check found', count($accounts)));
if (empty($accounts)) { if ($accounts === []) {
$output->writeLn('<error>No accounts exist</error>'); $output->writeLn('<error>No accounts exist</error>');
return 1; return 1;
} }

Просмотреть файл

@ -60,7 +60,7 @@ class LocalAttachmentMapper extends QBMapper {
* @return LocalAttachment[] * @return LocalAttachment[]
*/ */
public function findByLocalMessageIds(array $localMessageIds): array { public function findByLocalMessageIds(array $localMessageIds): array {
if (empty($localMessageIds)) { if ($localMessageIds === []) {
return []; return [];
} }
$qb = $this->db->getQueryBuilder(); $qb = $this->db->getQueryBuilder();

Просмотреть файл

@ -76,7 +76,7 @@ class LocalMessageMapper extends QBMapper {
} }
$rows->closeCursor(); $rows->closeCursor();
if (empty($ids)) { if ($ids === []) {
return []; return [];
} }

Просмотреть файл

@ -137,7 +137,7 @@ class MessageMapper extends QBMapper {
); );
$results = $this->findRelatedData($this->findEntities($query), $userId); $results = $this->findRelatedData($this->findEntities($query), $userId);
if (empty($results)) { if ($results === []) {
throw new DoesNotExistException("Message $id does not exist"); throw new DoesNotExistException("Message $id does not exist");
} }
return $results[0]; return $results[0];
@ -170,7 +170,7 @@ class MessageMapper extends QBMapper {
* @return int[] * @return int[]
*/ */
public function findUidsForIds(Mailbox $mailbox, array $ids) { public function findUidsForIds(Mailbox $mailbox, array $ids) {
if (empty($ids)) { if ($ids === []) {
// Shortcut for empty sets // Shortcut for empty sets
return []; return [];
} }
@ -447,7 +447,7 @@ class MessageMapper extends QBMapper {
$imapTags = $message->getTags(); $imapTags = $message->getTags();
$dbTags = $tags[$message->getMessageId()] ?? []; $dbTags = $tags[$message->getMessageId()] ?? [];
if (empty($imapTags) && empty($dbTags)) { if ($imapTags === [] && $dbTags === []) {
// neither old nor new tags // neither old nor new tags
return; return;
} }
@ -460,7 +460,7 @@ class MessageMapper extends QBMapper {
} }
$perf->step("Tagged messages"); $perf->step("Tagged messages");
if (empty($dbTags)) { if ($dbTags === []) {
// we have nothing to possibly remove // we have nothing to possibly remove
return; return;
} }
@ -1052,7 +1052,7 @@ class MessageMapper extends QBMapper {
* @return Message[] * @return Message[]
*/ */
public function findByMailboxAndIds(Mailbox $mailbox, string $userId, array $ids): array { public function findByMailboxAndIds(Mailbox $mailbox, string $userId, array $ids): array {
if (empty($ids)) { if ($ids === []) {
return []; return [];
} }
@ -1080,7 +1080,7 @@ class MessageMapper extends QBMapper {
* @return Message[] * @return Message[]
*/ */
public function findByIds(string $userId, array $ids): array { public function findByIds(string $userId, array $ids): array {
if (empty($ids)) { if ($ids === []) {
return []; return [];
} }

Просмотреть файл

@ -57,7 +57,7 @@ class RecipientMapper extends QBMapper {
* @return Recipient[] * @return Recipient[]
*/ */
public function findByLocalMessageIds(array $localMessageIds): array { public function findByLocalMessageIds(array $localMessageIds): array {
if (empty($localMessageIds)) { if ($localMessageIds === []) {
return []; return [];
} }
$qb = $this->db->getQueryBuilder(); $qb = $this->db->getQueryBuilder();
@ -105,7 +105,7 @@ class RecipientMapper extends QBMapper {
return; return;
} }
if (empty($oldRecipients)) { if ($oldRecipients === []) {
// No need for a diff, save and return // No need for a diff, save and return
$this->saveRecipients($localMessageId, $to); $this->saveRecipients($localMessageId, $to);
$this->saveRecipients($localMessageId, $cc); $this->saveRecipients($localMessageId, $cc);
@ -128,7 +128,7 @@ class RecipientMapper extends QBMapper {
$newTo = array_udiff($to, $oldTo, static function (Recipient $a, Recipient $b) { $newTo = array_udiff($to, $oldTo, static function (Recipient $a, Recipient $b) {
return strcmp($a->getEmail(), $b->getEmail()); return strcmp($a->getEmail(), $b->getEmail());
}); });
if (!empty($newTo)) { if ($newTo !== []) {
$this->saveRecipients($localMessageId, $newTo); $this->saveRecipients($localMessageId, $newTo);
} }
@ -143,7 +143,7 @@ class RecipientMapper extends QBMapper {
$newCC = array_udiff($cc, $oldCc, static function (Recipient $a, Recipient $b) { $newCC = array_udiff($cc, $oldCc, static function (Recipient $a, Recipient $b) {
return strcmp($a->getEmail(), $b->getEmail()); return strcmp($a->getEmail(), $b->getEmail());
}); });
if (!empty($newCC)) { if ($newCC !== []) {
$this->saveRecipients($localMessageId, $newCC); $this->saveRecipients($localMessageId, $newCC);
} }
@ -158,7 +158,7 @@ class RecipientMapper extends QBMapper {
$newBcc = array_udiff($bcc, $oldBcc, static function (Recipient $a, Recipient $b) { $newBcc = array_udiff($bcc, $oldBcc, static function (Recipient $a, Recipient $b) {
return strcmp($a->getEmail(), $b->getEmail()); return strcmp($a->getEmail(), $b->getEmail());
}); });
if (!empty($newBcc)) { if ($newBcc !== []) {
$this->saveRecipients($localMessageId, $newBcc); $this->saveRecipients($localMessageId, $newBcc);
} }

Просмотреть файл

@ -60,7 +60,7 @@ class TrustedSenderMapper extends QBMapper {
/** @var TrustedSender[] $rows */ /** @var TrustedSender[] $rows */
$rows = $this->findEntities($select); $rows = $this->findEntities($select);
return !empty($rows); return $rows !== [];
} }
public function create(string $uid, string $email, string $type): void { public function create(string $uid, string $email, string $type): void {

Просмотреть файл

@ -71,7 +71,7 @@ class ErrorMiddleware extends Middleware {
public function afterException($controller, $methodName, Exception $exception) { public function afterException($controller, $methodName, Exception $exception) {
$reflectionMethod = new ReflectionMethod($controller, $methodName); $reflectionMethod = new ReflectionMethod($controller, $methodName);
$attributes = $reflectionMethod->getAttributes(TrapError::class); $attributes = $reflectionMethod->getAttributes(TrapError::class);
if (empty($attributes)) { if ($attributes === []) {
return parent::afterException($controller, $methodName, $exception); return parent::afterException($controller, $methodName, $exception);
} }

Просмотреть файл

@ -64,7 +64,7 @@ class ProvisioningMiddleware extends Middleware {
return; return;
} }
$configs = $this->provisioningManager->getConfigs(); $configs = $this->provisioningManager->getConfigs();
if (empty($configs)) { if ($configs === []) {
return; return;
} }
try { try {

Просмотреть файл

@ -289,7 +289,7 @@ class MessageMapper {
return $fetchResult->exists(Horde_Imap_Client::FETCH_ENVELOPE); return $fetchResult->exists(Horde_Imap_Client::FETCH_ENVELOPE);
})); }));
if (empty($fetchResults)) { if ($fetchResults === []) {
$this->logger->debug("findByIds in $mailbox got " . count($ids) . " UIDs but found none"); $this->logger->debug("findByIds in $mailbox got " . count($ids) . " UIDs but found none");
} else { } else {
$minFetched = $fetchResults[0]->getUid(); $minFetched = $fetchResults[0]->getUid();
@ -813,7 +813,7 @@ class MessageMapper {
continue; continue;
} }
if (!empty($attachmentIds) && !in_array($part->getMimeId(), $attachmentIds, true)) { if ($attachmentIds !== [] && !in_array($part->getMimeId(), $attachmentIds, true)) {
// We are looking for specific parts only and this is not one of them // We are looking for specific parts only and this is not one of them
continue; continue;
} }

Просмотреть файл

@ -76,7 +76,7 @@ class PreviewEnhancer {
return array_merge($carry, [$message->getUid()]); return array_merge($carry, [$message->getUid()]);
}, []); }, []);
if (empty($needAnalyze)) { if ($needAnalyze === []) {
// Nothing to enhance // Nothing to enhance
return $messages; return $messages;
} }

Просмотреть файл

@ -140,7 +140,7 @@ class Container implements JsonSerializable {
} }
public function hasChildren(): bool { public function hasChildren(): bool {
return !empty($this->children); return $this->children !== [];
} }
/** /**

Просмотреть файл

@ -74,7 +74,7 @@ class FlagRepliedMessageListener implements IEventListener {
} }
$messages = $this->dbMessageMapper->findByMessageId($event->getAccount(), $event->getRepliedToMessageId()); $messages = $this->dbMessageMapper->findByMessageId($event->getAccount(), $event->getRepliedToMessageId());
if (empty($messages)) { if ($messages === []) {
return; return;
} }

Просмотреть файл

@ -68,7 +68,7 @@ class AddMissingMessageIds implements IRepairStep {
} }
$toFix = $this->mapper->findWithEmptyMessageId(); $toFix = $this->mapper->findWithEmptyMessageId();
if (empty($toFix)) { if ($toFix === []) {
return; return;
} }
$output->info(sprintf('%d messages need an update', count($toFix))); $output->info(sprintf('%d messages need an update', count($toFix)));

Просмотреть файл

@ -68,7 +68,7 @@ class MigrateImportantFromImapAndDb {
throw new ServiceException("Could not fetch UIDs of important messages: " . $e->getMessage(), 0, $e); throw new ServiceException("Could not fetch UIDs of important messages: " . $e->getMessage(), 0, $e);
} }
// add $label1 for all that are tagged on IMAP // add $label1 for all that are tagged on IMAP
if (!empty($uids)) { if ($uids !== []) {
try { try {
$this->messageMapper->addFlag($client, $mailbox, $uids, Tag::LABEL_IMPORTANT); $this->messageMapper->addFlag($client, $mailbox, $uids, Tag::LABEL_IMPORTANT);
} catch (Horde_Imap_Client_Exception $e) { } catch (Horde_Imap_Client_Exception $e) {
@ -81,7 +81,7 @@ class MigrateImportantFromImapAndDb {
public function migrateImportantFromDb(Horde_Imap_Client_Socket $client, Account $account, Mailbox $mailbox): void { public function migrateImportantFromDb(Horde_Imap_Client_Socket $client, Account $account, Mailbox $mailbox): void {
$uids = $this->mailboxMapper->findFlaggedImportantUids($mailbox->getId()); $uids = $this->mailboxMapper->findFlaggedImportantUids($mailbox->getId());
// store our data on imap // store our data on imap
if (!empty($uids)) { if ($uids !== []) {
try { try {
$this->messageMapper->addFlag($client, $mailbox, $uids, Tag::LABEL_IMPORTANT); $this->messageMapper->addFlag($client, $mailbox, $uids, Tag::LABEL_IMPORTANT);
} catch (Horde_Imap_Client_Exception $e) { } catch (Horde_Imap_Client_Exception $e) {

Просмотреть файл

@ -502,7 +502,7 @@ class IMAPMessage implements IMessage, JsonSerializable {
$msg->setFlagImportant(in_array('$important', $flags, true) || in_array('$labelimportant', $flags, true) || in_array(Tag::LABEL_IMPORTANT, $flags, true)); $msg->setFlagImportant(in_array('$important', $flags, true) || in_array('$labelimportant', $flags, true) || in_array(Tag::LABEL_IMPORTANT, $flags, true));
$msg->setFlagAttachments(false); $msg->setFlagAttachments(false);
$msg->setFlagMdnsent(in_array(Horde_Imap_Client::FLAG_MDNSENT, $flags, true)); $msg->setFlagMdnsent(in_array(Horde_Imap_Client::FLAG_MDNSENT, $flags, true));
if (!empty($this->scheduling)) { if ($this->scheduling !== []) {
$msg->setImipMessage(true); $msg->setImipMessage(true);
} }
@ -525,7 +525,7 @@ class IMAPMessage implements IMessage, JsonSerializable {
return in_array($flag, $allowed, true) === false; return in_array($flag, $allowed, true) === false;
}); });
if (empty($tags) === true) { if (($tags === []) === true) {
return $msg; return $msg;
} }
// cast all leftover $flags to be used as tags // cast all leftover $flags to be used as tags

Просмотреть файл

@ -188,7 +188,7 @@ class AttachmentService implements IAttachmentService {
* @return LocalAttachment[] * @return LocalAttachment[]
*/ */
public function saveLocalMessageAttachments(string $userId, int $messageId, array $attachmentIds): array { public function saveLocalMessageAttachments(string $userId, int $messageId, array $attachmentIds): array {
if (empty($attachmentIds)) { if ($attachmentIds === []) {
return []; return [];
} }
$this->mapper->saveLocalMessageAttachments($userId, $messageId, $attachmentIds); $this->mapper->saveLocalMessageAttachments($userId, $messageId, $attachmentIds);
@ -200,7 +200,7 @@ class AttachmentService implements IAttachmentService {
*/ */
public function updateLocalMessageAttachments(string $userId, LocalMessage $message, array $newAttachmentIds): array { public function updateLocalMessageAttachments(string $userId, LocalMessage $message, array $newAttachmentIds): array {
// no attachments any more. Delete any old ones and we're done // no attachments any more. Delete any old ones and we're done
if (empty($newAttachmentIds)) { if ($newAttachmentIds === []) {
$this->deleteLocalMessageAttachments($userId, $message->getId()); $this->deleteLocalMessageAttachments($userId, $message->getId());
return []; return [];
} }
@ -216,12 +216,12 @@ class AttachmentService implements IAttachmentService {
}, $message->getAttachments()); }, $message->getAttachments());
$add = array_diff($newAttachmentIds, $oldAttachmentIds); $add = array_diff($newAttachmentIds, $oldAttachmentIds);
if (!empty($add)) { if ($add !== []) {
$this->mapper->saveLocalMessageAttachments($userId, $message->getId(), $add); $this->mapper->saveLocalMessageAttachments($userId, $message->getId(), $add);
} }
$delete = array_diff($oldAttachmentIds, $newAttachmentIds); $delete = array_diff($oldAttachmentIds, $newAttachmentIds);
if (!empty($delete)) { if ($delete !== []) {
$this->deleteLocalMessageAttachmentsById($userId, $message->getId(), $delete); $this->deleteLocalMessageAttachmentsById($userId, $message->getId(), $delete);
} }
@ -236,7 +236,7 @@ class AttachmentService implements IAttachmentService {
public function handleAttachments(Account $account, array $attachments, \Horde_Imap_Client_Socket $client): array { public function handleAttachments(Account $account, array $attachments, \Horde_Imap_Client_Socket $client): array {
$attachmentIds = []; $attachmentIds = [];
if (empty($attachments)) { if ($attachments === []) {
return $attachmentIds; return $attachmentIds;
} }
@ -325,7 +325,7 @@ class AttachmentService implements IAttachmentService {
] ]
); );
if (empty($attachments)) { if ($attachments === []) {
return null; return null;
} }

Просмотреть файл

@ -195,7 +195,7 @@ class ImportanceClassifier {
$validationSet = array_slice($dataSet, 0, $validationThreshold); $validationSet = array_slice($dataSet, 0, $validationThreshold);
$trainingSet = array_slice($dataSet, $validationThreshold); $trainingSet = array_slice($dataSet, $validationThreshold);
$logger->debug('data set split into ' . count($trainingSet) . ' training and ' . count($validationSet) . ' validation sets with ' . count($trainingSet[0]['features'] ?? []) . ' dimensions'); $logger->debug('data set split into ' . count($trainingSet) . ' training and ' . count($validationSet) . ' validation sets with ' . count($trainingSet[0]['features'] ?? []) . ' dimensions');
if (empty($validationSet) || empty($trainingSet)) { if ($validationSet === [] || $trainingSet === []) {
$logger->info('not enough messages to train a classifier'); $logger->info('not enough messages to train a classifier');
$perf->end(); $perf->end();
return; return;

Просмотреть файл

@ -115,13 +115,13 @@ class DraftsService {
// if this message has a "sent at" datestamp and the type is set as Type Outbox // if this message has a "sent at" datestamp and the type is set as Type Outbox
// check for a valid recipient // check for a valid recipient
if ($message->getType() === LocalMessage::TYPE_OUTGOING && empty($toRecipients)) { if ($message->getType() === LocalMessage::TYPE_OUTGOING && $toRecipients === []) {
throw new ClientException('Cannot convert message to outbox message without at least one recipient'); throw new ClientException('Cannot convert message to outbox message without at least one recipient');
} }
$message = $this->mapper->saveWithRecipients($message, $toRecipients, $ccRecipients, $bccRecipients); $message = $this->mapper->saveWithRecipients($message, $toRecipients, $ccRecipients, $bccRecipients);
if (empty($attachments)) { if ($attachments === []) {
$message->setAttachments($attachments); $message->setAttachments($attachments);
return $message; return $message;
} }
@ -153,13 +153,13 @@ class DraftsService {
// if this message has a "sent at" datestamp and the type is set as Type Outbox // if this message has a "sent at" datestamp and the type is set as Type Outbox
// check for a valid recipient // check for a valid recipient
if ($message->getType() === LocalMessage::TYPE_OUTGOING && empty($toRecipients)) { if ($message->getType() === LocalMessage::TYPE_OUTGOING && $toRecipients === []) {
throw new ClientException('Cannot convert message to outbox message without at least one recipient'); throw new ClientException('Cannot convert message to outbox message without at least one recipient');
} }
$message = $this->mapper->updateWithRecipients($message, $toRecipients, $ccRecipients, $bccRecipients); $message = $this->mapper->updateWithRecipients($message, $toRecipients, $ccRecipients, $bccRecipients);
if (empty($attachments)) { if ($attachments === []) {
$message->setAttachments($this->attachmentService->updateLocalMessageAttachments($account->getUserId(), $message, [])); $message->setAttachments($this->attachmentService->updateLocalMessageAttachments($account->getUserId(), $message, []));
return $message; return $message;
} }
@ -216,7 +216,7 @@ class DraftsService {
*/ */
public function flush() { public function flush() {
$messages = $this->mapper->findDueDrafts($this->time->getTime()); $messages = $this->mapper->findDueDrafts($this->time->getTime());
if (empty($messages)) { if ($messages === []) {
return; return;
} }

Просмотреть файл

@ -104,7 +104,7 @@ class GroupsIntegration {
$members = array_filter($service->getUsers($groupId), static function (array $member) { $members = array_filter($service->getUsers($groupId), static function (array $member) {
return !empty($member['email']); return !empty($member['email']);
}); });
if (empty($members)) { if ($members === []) {
throw new ServiceException($groupId . " ({$service->getNamespace()}) has no members with email addresses"); throw new ServiceException($groupId . " ({$service->getNamespace()}) has no members with email addresses");
} }
return array_map(static function (array $member) use ($recipient) { return array_map(static function (array $member) use ($recipient) {

Просмотреть файл

@ -63,7 +63,7 @@ class IMipService {
public function process(): void { public function process(): void {
$messages = $this->messageMapper->findIMipMessagesAscending(); $messages = $this->messageMapper->findIMipMessagesAscending();
if (empty($messages)) { if ($messages === []) {
$this->logger->info('No iMIP messages to process.'); $this->logger->info('No iMIP messages to process.');
return; return;
} }
@ -106,7 +106,7 @@ class IMipService {
return $message->getMailboxId() === $mailbox->getId(); return $message->getMailboxId() === $mailbox->getId();
}); });
if (empty($filteredMessages)) { if ($filteredMessages === []) {
continue; continue;
} }

Просмотреть файл

@ -564,7 +564,7 @@ class MailManager implements IMailManager {
]; ];
}, array_merge(...array_values($quotas))); }, array_merge(...array_values($quotas)));
if (empty($storageQuotas)) { if ($storageQuotas === []) {
// Nothing left to do, and array_merge doesn't like to be called with zero arguments. // Nothing left to do, and array_merge doesn't like to be called with zero arguments.
return null; return null;
} }

Просмотреть файл

@ -165,7 +165,7 @@ class OutboxService {
$bccRecipients = self::convertToRecipient($bcc, Recipient::TYPE_BCC); $bccRecipients = self::convertToRecipient($bcc, Recipient::TYPE_BCC);
$message = $this->mapper->saveWithRecipients($message, $toRecipients, $ccRecipients, $bccRecipients); $message = $this->mapper->saveWithRecipients($message, $toRecipients, $ccRecipients, $bccRecipients);
if (empty($attachments)) { if ($attachments === []) {
$message->setAttachments($attachments); $message->setAttachments($attachments);
return $message; return $message;
} }
@ -196,7 +196,7 @@ class OutboxService {
$bccRecipients = self::convertToRecipient($bcc, Recipient::TYPE_BCC); $bccRecipients = self::convertToRecipient($bcc, Recipient::TYPE_BCC);
$message = $this->mapper->updateWithRecipients($message, $toRecipients, $ccRecipients, $bccRecipients); $message = $this->mapper->updateWithRecipients($message, $toRecipients, $ccRecipients, $bccRecipients);
if (empty($attachments)) { if ($attachments === []) {
$message->setAttachments($this->attachmentService->updateLocalMessageAttachments($account->getUserId(), $message, [])); $message->setAttachments($this->attachmentService->updateLocalMessageAttachments($account->getUserId(), $message, []));
return $message; return $message;
} }
@ -232,7 +232,7 @@ class OutboxService {
$this->timeFactory->getTime() $this->timeFactory->getTime()
); );
if (empty($messages)) { if ($messages === []) {
return; return;
} }

Просмотреть файл

@ -54,7 +54,7 @@ class PreprocessingService {
public function process(int $limitTimestamp, Account $account): void { public function process(int $limitTimestamp, Account $account): void {
$mailboxes = $this->mailboxMapper->findAll($account); $mailboxes = $this->mailboxMapper->findAll($account);
if (empty($mailboxes)) { if ($mailboxes === []) {
$this->logger->debug('No mailboxes found.'); $this->logger->debug('No mailboxes found.');
return; return;
} }
@ -64,7 +64,7 @@ class PreprocessingService {
$messages = $this->messageMapper->getUnanalyzed($limitTimestamp, $mailboxIds); $messages = $this->messageMapper->getUnanalyzed($limitTimestamp, $mailboxIds);
if (empty($messages)) { if ($messages === []) {
$this->logger->debug('No structure data to analyse.'); $this->logger->debug('No structure data to analyse.');
return; return;
} }
@ -74,7 +74,7 @@ class PreprocessingService {
return $message->getMailboxId() === $mailbox->getId(); return $message->getMailboxId() === $mailbox->getId();
}); });
if (empty($filteredMessages)) { if ($filteredMessages === []) {
continue; continue;
} }

Просмотреть файл

@ -83,7 +83,7 @@ class MailSearch implements IMailSearch {
$mailbox, $mailbox,
[$message] [$message]
); );
if (empty($processed)) { if ($processed === []) {
throw new DoesNotExistException("Message does not exist"); throw new DoesNotExistException("Message does not exist");
} }
return $processed[0]; return $processed[0];

Просмотреть файл

@ -408,7 +408,7 @@ class ImapToDbSynchronizer {
$perf->step('persist new messages'); $perf->step('persist new messages');
$mailbox->setSyncNewToken($client->getSyncToken($mailbox->getName())); $mailbox->setSyncNewToken($client->getSyncToken($mailbox->getName()));
$newOrVanished = !empty($newMessages); $newOrVanished = $newMessages !== [];
} }
if ($criteria & Horde_Imap_Client::SYNC_FLAGSUIDS) { if ($criteria & Horde_Imap_Client::SYNC_FLAGSUIDS) {
$response = $this->synchronizer->sync( $response = $this->synchronizer->sync(

Просмотреть файл

@ -151,7 +151,7 @@ class SyncService {
Mailbox $mailbox, Mailbox $mailbox,
array $knownIds, array $knownIds,
?SearchQuery $query): Response { ?SearchQuery $query): Response {
if (empty($knownIds)) { if ($knownIds === []) {
$newIds = $this->messageMapper->findAllIds($mailbox); $newIds = $this->messageMapper->findAllIds($mailbox);
} else { } else {
$newIds = $this->messageMapper->findNewIds($mailbox, $knownIds); $newIds = $this->messageMapper->findNewIds($mailbox, $knownIds);

Просмотреть файл

@ -41,7 +41,7 @@ function array_flat_map(callable $map, array $data): array {
*/ */
function chunk_uid_sequence(array $uids, int $bytes): array { function chunk_uid_sequence(array $uids, int $bytes): array {
$chunks = []; $chunks = [];
while (!empty($uids)) { while ($uids !== []) {
$take = count($uids); $take = count($uids);
while (strlen((new Horde_Imap_Client_Ids(array_slice($uids, 0, $take)))->tostring) >= $bytes) { while (strlen((new Horde_Imap_Client_Ids(array_slice($uids, 0, $take)))->tostring) >= $bytes) {
$take = (int)($take * 0.75); $take = (int)($take * 0.75);