Skip to content

fix(php): refactor int/float conversions#12567

Open
ChristophWurst wants to merge 1 commit intomainfrom
fix/php/int-float-conversions
Open

fix(php): refactor int/float conversions#12567
ChristophWurst wants to merge 1 commit intomainfrom
fix/php/int-float-conversions

Conversation

@ChristophWurst
Copy link
Member

For #11224

Changed with opencode+claude-sonnet, reviewed manually.

Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors several PHP int/float conversions and string concatenations to be more explicit and type-safe (likely in preparation for stricter static analysis with Psalm v6), while keeping behavior the same.

Changes:

  • Add explicit float casts / float literals in arithmetic to avoid implicit int→float conversions.
  • Replace many '.' concatenations with interpolated strings in logs/messages.
  • Introduce temporary variables in a few places to avoid repeated count() calls and improve readability in log formatting.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
lib/functions.php Make take * 0.75 conversion explicit via float cast.
lib/Support/PerformanceLoggerTask.php Use float divisors for memory-to-MB calculation.
lib/Sieve/SieveClientFactory.php Switch debug log path building to interpolation.
lib/SetupChecks/MailConnectionPerformance.php Ensure timing accumulators/divisions are explicitly float-based; minor log formatting change.
lib/Service/Sync/ImapToDbSynchronizer.php Convert a number of log/error strings to interpolation.
lib/Service/SetupService.php Interpolated debug log for created account.
lib/Service/PreprocessingService.php Cache count() / mailbox id for clearer log message construction.
lib/Service/MailTransmission.php Interpolated exception messages for MDN sending errors.
lib/Service/MailManager.php Interpolated ServiceException message for subscription updates.
lib/Service/ItineraryService.php Cache count() values for clearer log messages.
lib/Service/Classification/ImportanceClassifier.php Cache counts for logs; make dataset split threshold conversion explicit.
lib/Service/AutoConfig/MxRecord.php Cache count for MX record debug logging.
lib/Service/AutoCompletion/AddressCollector.php Cache counts for debug logs.
lib/Service/AntiSpamService.php Interpolated error logs (message id).
lib/Service/AiIntegrations/AiIntegrationsService.php Interpolated cache keys; minor refactor for readability.
lib/SMTP/SmtpClientFactory.php Interpolated SMTP debug log filename.
lib/Migration/MigrateImportantFromImapAndDb.php Interpolated debug log strings for mailbox id.
lib/Listener/MailboxesSynchronizedSpecialMailboxesUpdater.php Interpolated info logs for missing special mailboxes.
lib/Listener/AccountSynchronizedThreadUpdaterListener.php Cache counts for logs; minor refactor for chunk logging.
lib/IMAP/Threading/ThreadBuilder.php Cache message count for threading performance log label.
lib/IMAP/MessageMapper.php Make estimated page-size computation more explicitly float-based; interpolated UID ranges/log counts.
lib/IMAP/IMAPClientFactory.php Interpolated IMAP debug log filename.
lib/Db/MessageMapper.php Interpolated performance logger label.
lib/Command/Thread.php Cache sizes/counts for console debug/output strings; interpolate output.
lib/Command/ExportAccount.php Small refactor to reuse interpolated ids/ports in output.
lib/Command/DiagnoseAccount.php Cache mailbox count for output string.
lib/Command/CreateAccount.php Interpolated CLI output message.
lib/Command/AddMissingTags.php Cache count for CLI output string.
lib/BackgroundJob/QuotaJob.php Make quota percentage computation explicitly float-based.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +105 to 106
$this->logger->info("Account {$account->getId()} does not have an junk mailbox");
$mailAccount->setJunkMailboxId(null);
$mailAccount->setSnoozeMailboxId($snoozeMailbox->getId());
} catch (DoesNotExistException $e) {
$this->logger->info('Account ' . $account->getId() . ' does not have an snooze mailbox');
$this->logger->info("Account {$account->getId()} does not have an snooze mailbox");
$flattened = iterator_to_array($this->flattenThreads($threads), false);
$logger->debug("Account $accountId has " . count($flattened) . ' messages with a new thread IDs');
$nFlattened = count($flattened);
$logger->debug("Account $accountId has $nFlattened messages with a new thread IDs");
Comment on lines +70 to +74
$chunkSize = self::WRITE_IDS_CHUNK_SIZE;
foreach (array_chunk($flattened, self::WRITE_IDS_CHUNK_SIZE) as $chunk) {
$this->mapper->writeThreadIds($chunk);

$logger->debug('Chunk of ' . self::WRITE_IDS_CHUNK_SIZE . ' messages updated');
$logger->debug("Chunk of $chunkSize messages updated");
$this->runInitialSync($client, $account, $mailbox, $logger);
} catch (MailboxDoesNotSupportModSequencesException $e) {
$logger->warning('Mailbox does not support mod-sequences error occured. Wiping cache and performing full sync for ' . $mailbox->getId(), [
$logger->warning("Mailbox does not support mod-sequences error occured. Wiping cache and performing full sync for {$mailbox->getId()}", [
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants