Skip to content

Commit

Permalink
Support 32-bit platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed May 31, 2019
1 parent 1541424 commit f44fcb6
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions lib/Internal/functions.php
Expand Up @@ -59,12 +59,26 @@ function createTypeError(array $expected, $given): \TypeError
*/
function getCurrentTime(): int
{
static $startTime;

if (\PHP_INT_SIZE === 4) {
if ($startTime === null) {
$startTime = \PHP_VERSION_ID >= 70300 ? \hrtime(false)[0] : \time();
}

if (\PHP_VERSION_ID >= 70300) {
list($seconds, $nanoseconds) = \hrtime(false);
$seconds -= $startTime;
return (int) ($seconds * 1000 + $nanoseconds / 1000000);
}

return ((\microtime(true) - $startTime) * 1000);
}

if (\PHP_VERSION_ID >= 70300) {
list($seconds, $nanoseconds) = \hrtime(false);
$time = (int) ($seconds * 1000 + $nanoseconds / 1000000);
} else {
$time = (int) (\microtime(true) * 1000);
return (int) ($seconds * 1000 + $nanoseconds / 1000000);
}

return $time < 0 ? -$time : $time;
return (\microtime(true) * 1000);
}

0 comments on commit f44fcb6

Please sign in to comment.