fix(php): refactor int/float conversions#12567
Open
ChristophWurst wants to merge 1 commit intomainfrom
Open
Conversation
Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
There was a problem hiding this comment.
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()}", [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For #11224
Changed with opencode+claude-sonnet, reviewed manually.