Skip to content

Commit

Permalink
[module-webdriver] fix type error in PHP 8.1 when converting ms to sec (
Browse files Browse the repository at this point in the history
#103)

* [module-webdriver] fix type error in PHP 8.1 when converting milliseconds to seconds

* simplify using intval

Co-authored-by: Patrick Mac Gregor <[email protected]>
  • Loading branch information
2 people authored and Naktibalda committed Jul 27, 2022
1 parent 14718a2 commit 1c2680b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Codeception/Module/WebDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ protected function formatLogEntries(array $logEntries): string

foreach ($logEntries as $logEntry) {
// Timestamp is in milliseconds, but date() requires seconds.
$time = date('H:i:s', $logEntry['timestamp'] / 1000) .
$time = date('H:i:s', intval($logEntry['timestamp'] / 1000)) .
// Append the milliseconds to the end of the time string
'.' . ($logEntry['timestamp'] % 1000);
$formattedLogs .= "{$time} {$logEntry['level']} - {$logEntry['message']}\n";
Expand All @@ -729,7 +729,7 @@ protected function logJSErrors(ScenarioDriven $test, array $browserLogEntries):
&& $this->isJSError($logEntry['level'], $logEntry['message'])
) {
// Timestamp is in milliseconds, but date() requires seconds.
$time = date('H:i:s', $logEntry['timestamp'] / 1000) .
$time = date('H:i:s', intval($logEntry['timestamp'] / 1000)) .
// Append the milliseconds to the end of the time string
'.' . ($logEntry['timestamp'] % 1000);
$test->getScenario()->comment("{$time} {$logEntry['level']} - {$logEntry['message']}");
Expand Down

0 comments on commit 1c2680b

Please sign in to comment.