From 38d2a0582bf86edb24dbac930bd4337e24f1ea9f Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 25 May 2026 21:25:55 -0400 Subject: [PATCH] 2038 UuidV7 fix --- src/Framework/BbCodeParser.php | 4 ++-- src/Framework/Uuids/UuidV7.php | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Framework/BbCodeParser.php b/src/Framework/BbCodeParser.php index 07d0cea..3d9496c 100644 --- a/src/Framework/BbCodeParser.php +++ b/src/Framework/BbCodeParser.php @@ -100,7 +100,7 @@ final class BbCodeParser 'content' => '$1' ], 'listitem' => [ - 'pattern' => '/\[\*\](.*)/', + 'pattern' => '/\[li\](.*?)\[\/li\]/s', 'replace' => '
  • $1
  • ', 'content' => '$1' ], @@ -163,7 +163,7 @@ final class BbCodeParser } public function parse(string $source, $caseInsensitive = null): string { - $caseInsensitive = $caseInsensitive === self::CASE_INSENSITIVE ? true : false; + $caseInsensitive = ($caseInsensitive === null) ?? true; foreach ($this->parsers as $name => $parser) { $pattern = ($caseInsensitive) ? $parser['pattern'] . 'i' : $parser['pattern']; diff --git a/src/Framework/Uuids/UuidV7.php b/src/Framework/Uuids/UuidV7.php index 06ae901..8553f48 100644 --- a/src/Framework/Uuids/UuidV7.php +++ b/src/Framework/Uuids/UuidV7.php @@ -8,6 +8,7 @@ declare(strict_types = 1); * @license MIT */ namespace IOcornerstone\Framework\Uuids; +use DateTimeImmutable; class UuidV7 { @@ -18,8 +19,12 @@ class UuidV7 } public static function generateUuidV7(): string { - $timestamp = (int)(microtime(true) * 1000); // Real Unix milliseconds - $timeHex = str_pad(dechex((int)$timestamp), 12, '0', STR_PAD_LEFT); + /** + * $milliseconds = (int)(microtime(true) * 1000); // Real Unix milliseconds + */ + // The completely safe, object-oriented way (no 2038 issue ever) + $milliseconds = (int)((new DateTimeImmutable())->format('U.u') * 1000); + $timeHex = str_pad(dechex($milliseconds), 12, '0', STR_PAD_LEFT); $randomHex = bin2hex(random_bytes(10));