Skip to content

Commit bcee638

Browse files
authored
Merge pull request #17 from infocyph/feature/update
v1 fix
2 parents 7ab4ae2 + b799174 commit bcee638

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed

rector.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
<?php
2-
3-
declare(strict_types=1);
4-
5-
use Rector\Config\RectorConfig;
6-
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
7-
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
8-
9-
return static function (RectorConfig $rectorConfig): void {
10-
$rectorConfig->paths([
11-
__DIR__ . '/src'
12-
]);
13-
$rectorConfig->sets([
14-
constant("Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_82")
15-
]);
16-
$rectorConfig->skip([
17-
StringClassNameToClassConstantRector::class
18-
]);
19-
};
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
7+
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
8+
9+
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->paths([
11+
__DIR__ . '/src'
12+
]);
13+
$rectorConfig->sets([
14+
constant("Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_82")
15+
]);
16+
$rectorConfig->skip([
17+
StringClassNameToClassConstantRector::class
18+
]);
19+
};

src/UUID.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,13 @@ final class UUID
4949
public static function v1(string $node = null): string
5050
{
5151
[$unixTs, $subSec] = self::getUnixTimeSubSec();
52-
$time = $unixTs . $subSec;
53-
$time = str_pad(dechex((int)$time + self::$timeOffset), 16, '0', STR_PAD_LEFT);
54-
$clockSeq = random_int(0, 0x3fff);
52+
$time = str_pad(dechex((int)($unixTs . $subSec) + self::$timeOffset), 16, '0', STR_PAD_LEFT);
5553
return sprintf(
5654
'%08s-%04s-1%03s-%04x-%012s',
5755
substr($time, -8),
5856
substr($time, -12, 4),
5957
substr($time, -15, 3),
60-
$clockSeq | 0x8000,
58+
random_int(0, 0x3fff) & 0x3fff | 0x8000,
6159
$node ?? self::getNode()
6260
);
6361
}
@@ -323,8 +321,8 @@ private static function getTime(array $uuid, int $version): DateTimeInterface
323321
private static function getUnixTimeSubSec(int $version = 1): array
324322
{
325323
$timestamp = microtime();
326-
$unixTs = (int)substr($timestamp, 11);
327-
$subSec = (int)substr($timestamp, 2, 7);
324+
$unixTs = substr($timestamp, 11);
325+
$subSec = substr($timestamp, 2, 7);
328326
if ($version === 1) {
329327
return [$unixTs, $subSec];
330328
}

0 commit comments

Comments
 (0)