Merge branch 'ilyaplot-4.x' into 5.x

This commit is contained in:
Ben Ramsey
2025-12-13 21:48:53 -06:00
3 changed files with 36 additions and 13 deletions
+30
View File
@@ -154,4 +154,34 @@ interface UuidFactoryInterface
* @return UuidInterface A UuidInterface instance that represents a version 6 UUID
*/
public function uuid6(?Hexadecimal $node = null, ?int $clockSeq = null): UuidInterface;
/**
* Returns a version 7 (Unix Epoch time) UUID
*
* @param DateTimeInterface|null $dateTime An optional date/time from which
* to create the version 7 UUID. If not provided, the UUID is generated
* using the current date/time.
*
* @return UuidInterface A UuidInterface instance that represents a
* version 7 UUID
*/
public function uuid7(?DateTimeInterface $dateTime = null): UuidInterface;
/**
* Returns a version 8 (Custom) UUID
*
* The bytes provided may contain any value according to your application's
* needs. Be aware, however, that other applications may not understand the
* semantics of the value.
*
* @param string $bytes A 16-byte octet string. This is an open blob
* of data that you may fill with 128 bits of information. Be aware,
* however, bits 48 through 51 will be replaced with the UUID version
* field, and bits 64 and 65 will be replaced with the UUID variant. You
* MUST NOT rely on these bits for your application needs.
*
* @return UuidInterface A UuidInterface instance that represents a
* version 8 UUID
*/
public function uuid8(string $bytes): UuidInterface;
}
+6
View File
@@ -363,6 +363,9 @@ class ExpectedBehaviorTest extends TestCase
'uuid3' => $uuid,
'uuid4' => $uuid,
'uuid5' => $uuid,
'uuid6' => $uuid,
'uuid7' => $uuid,
'uuid8' => $uuid,
'fromBytes' => $uuid,
'fromString' => $uuid,
'fromInteger' => $uuid,
@@ -377,6 +380,9 @@ class ExpectedBehaviorTest extends TestCase
$this->assertSame($uuid, Uuid::uuid3(Uuid::NAMESPACE_URL, 'https://example.com/foo'));
$this->assertSame($uuid, Uuid::uuid4());
$this->assertSame($uuid, Uuid::uuid5(Uuid::NAMESPACE_URL, 'https://example.com/foo'));
$this->assertSame($uuid, Uuid::uuid6());
$this->assertSame($uuid, Uuid::uuid7());
$this->assertSame($uuid, Uuid::uuid8(hex2bin('ffffffffffffffffffffffffffffffff')));
$this->assertSame($uuid, Uuid::fromBytes($bytes));
$this->assertSame($uuid, Uuid::fromString('ffffffff-ffff-ffff-ffff-ffffffffffff'));
$this->assertSame($uuid, Uuid::fromInteger('340282366920938463463374607431768211455'));
-13
View File
@@ -673,19 +673,6 @@ class UuidTest extends TestCase
$this->assertSame(Version::UnixTime, $uuid->getFields()->getVersion());
}
public function testUuid7ThrowsExceptionForUnsupportedFactory(): void
{
/** @var UuidFactoryInterface&MockInterface $factory */
$factory = Mockery::mock(UuidFactoryInterface::class);
Uuid::setFactory($factory);
$this->expectException(UnsupportedOperationException::class);
$this->expectExceptionMessage('The provided factory does not support the uuid7() method');
Uuid::uuid7();
}
public function testUuid7WithDateTime(): void
{
$dateTime = new DateTimeImmutable('@281474976710.655');