Skip to content

Commit 4464d37

Browse files
committed
Tweaks
1 parent 56a7254 commit 4464d37

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

components/uid.rst

+19-17
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ to create each type of UUID:
3232
**UUID v1** (time-based)
3333

3434
Generates the UUID using a timestamp and the MAC address of your device
35-
(`read UUIDv1 spec <https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-uuid-version-1>`__).
35+
(`read the UUIDv1 spec <https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-uuid-version-1>`__).
3636
Both are obtained automatically, so you don't have to pass any constructor argument::
3737

3838
use Symfony\Component\Uid\Uuid;
3939

40-
// $uuid is an instance of Symfony\Component\Uid\UuidV1
4140
$uuid = Uuid::v1();
41+
// $uuid is an instance of Symfony\Component\Uid\UuidV1
4242

4343
.. tip::
4444

@@ -48,15 +48,15 @@ Both are obtained automatically, so you don't have to pass any constructor argum
4848
**UUID v2** (DCE security)
4949

5050
Similar to UUIDv1 but with a very high likelihood of ID collision
51-
(`read UUIDv2 spec <https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-uuid-version-2>`__).
51+
(`read the UUIDv2 spec <https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-uuid-version-2>`__).
5252
It's part of the authentication mechanism of DCE (Distributed Computing Environment)
5353
and the UUID includes the POSIX UIDs (user/group ID) of the user who generated it.
5454
This UUID variant is **not implemented** by the Uid component.
5555

5656
**UUID v3** (name-based, MD5)
5757

5858
Generates UUIDs from names that belong, and are unique within, some given namespace
59-
(`read UUIDv3 spec <https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-uuid-version-3>`__).
59+
(`read the UUIDv3 spec <https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-uuid-version-3>`__).
6060
This variant is useful to generate deterministic UUIDs from arbitrary strings.
6161
It works by populating the UUID contents with the``md5`` hash of concatenating
6262
the namespace and the name::
@@ -69,8 +69,8 @@ the namespace and the name::
6969
// $namespace = Uuid::v4();
7070

7171
// $name can be any arbitrary string
72-
// $uuid is an instance of Symfony\Component\Uid\UuidV3
7372
$uuid = Uuid::v3($namespace, $name);
73+
// $uuid is an instance of Symfony\Component\Uid\UuidV3
7474

7575
These are the default namespaces defined by the standard:
7676

@@ -81,20 +81,20 @@ These are the default namespaces defined by the standard:
8181

8282
**UUID v4** (random)
8383

84-
Generates a random UUID (`read UUIDv4 spec <https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-uuid-version-4>`__).
84+
Generates a random UUID (`read the UUIDv4 spec <https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-uuid-version-4>`__).
8585
Because of its randomness, it ensures uniqueness across distributed systems
8686
without the need for a central coordinating entity. It's privacy-friendly
8787
because it doesn't contain any information about where and when it was generated::
8888

8989
use Symfony\Component\Uid\Uuid;
9090

91-
// $uuid is an instance of Symfony\Component\Uid\UuidV4
9291
$uuid = Uuid::v4();
92+
// $uuid is an instance of Symfony\Component\Uid\UuidV4
9393

9494
**UUID v5** (name-based, SHA-1)
9595

9696
It's the same as UUIDv3 (explained above) but it uses ``sha1`` instead of
97-
``md5`` to hash the given namespace and name (`read UUIDv5 spec <https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-uuid-version-5>`__).
97+
``md5`` to hash the given namespace and name (`read the UUIDv5 spec <https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-uuid-version-5>`__).
9898
This makes it more secure and less prone to hash collisions.
9999

100100
.. _uid-uuid-v6:
@@ -103,12 +103,12 @@ This makes it more secure and less prone to hash collisions.
103103

104104
It rearranges the time-based fields of the UUIDv1 to make it lexicographically
105105
sortable (like :ref:`ULIDs <ulid>`). It's more efficient for database indexing
106-
(`read UUIDv6 spec <https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-uuid-version-6>`__)::
106+
(`read the UUIDv6 spec <https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-uuid-version-6>`__)::
107107

108108
use Symfony\Component\Uid\Uuid;
109109

110-
// $uuid is an instance of Symfony\Component\Uid\UuidV6
111110
$uuid = Uuid::v6();
111+
// $uuid is an instance of Symfony\Component\Uid\UuidV6
112112

113113
.. tip::
114114

@@ -121,26 +121,28 @@ sortable (like :ref:`ULIDs <ulid>`). It's more efficient for database indexing
121121

122122
Generates time-ordered UUIDs based on a high-resolution Unix Epoch timestamp
123123
source (the number of milliseconds since midnight 1 Jan 1970 UTC, leap seconds excluded)
124-
(`read UUIDv7 spec <https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-uuid-version-7>`__).
124+
(`read the UUIDv7 spec <https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-uuid-version-7>`__).
125125
It's recommended to use this version over UUIDv1 and UUIDv6 because it provides
126126
better entropy (and a more strict chronological order of UUID generation)::
127127

128128
use Symfony\Component\Uid\Uuid;
129129

130-
// $uuid is an instance of Symfony\Component\Uid\UuidV7
131130
$uuid = Uuid::v7();
131+
// $uuid is an instance of Symfony\Component\Uid\UuidV7
132132

133133
**UUID v8** (custom)
134134

135-
Provides an RFC-compatible format for experimental or vendor-specific use cases
136-
(`read UUIDv8 spec <https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-uuid-version-8>`__).
137-
The only requirement is to set the variant and version bits of the UUID. The rest
138-
of the UUID value is specific to each implementation and no format should be assumed::
135+
Provides an RFC-compatible format intended for experimental or vendor-specific use cases
136+
(`read the UUIDv8 spec <https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-uuid-version-8>`__).
137+
You must generate the UUID value yourself. The only requirement is to set the
138+
variant and version bits of the UUID correctly. The rest of the UUID content is
139+
implementation-specific, and no particular format should be assumed::
139140

140141
use Symfony\Component\Uid\Uuid;
141142

142-
// $uuid is an instance of Symfony\Component\Uid\UuidV8
143+
// pass your custom UUID value as the argument
143144
$uuid = Uuid::v8('d9e7a184-5d5b-11ea-a62a-3499710062d0');
145+
// $uuid is an instance of Symfony\Component\Uid\UuidV8
144146

145147
.. versionadded:: 6.2
146148

0 commit comments

Comments
 (0)