Commit 7dc6da6
committed
feature #36066 [Uid] use one class per type of UUID (nicolas-grekas)
This PR was merged into the 5.1-dev branch.
Discussion
----------
[Uid] use one class per type of UUID
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
(embeds #36064 for now)
Would it make sense to have one class per type of UUID?
This aligns the type system and UUID types, so that one could type hint e.g. `UuidV4 $uuid`.
This PR does so. `UuidV1`/2/3/4 and `NullUuid` all extend the base `Uuid` class, which provides common methods and the factories needed to create each king of UUID.
This means we don't need the `getType()` nor the `isNull()` methods since they can be replaced by instanceof checks.
As expected, `getTime()` and `getMac()` then now exist only on the `UuidV1` class - no need for any version check nor any `LogicException` anymore.
Each type is guaranteed to contain a UUID that matches its class' type. The base `Uuid` class is used for the "no type" type.
Commits
-------
62f6ac4 [Uid] use one class per type of UUID9 files changed
+245-99Lines changed: 245 additions & 99 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- src/Symfony/Component/Uid
- Tests
Expand file treeCollapse file tree
Open diff view settings
Collapse file
src/Symfony/Component/Uid/NullUuid.php
Copy file name to clipboard+27Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
Collapse file
src/Symfony/Component/Uid/Tests/UlidTest.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Uid/Tests/UlidTest.php+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
46 | 46 | |
47 | 47 | |
48 | 48 | |
49 | | - |
| 49 | + |
50 | 50 | |
51 | 51 | |
52 | 52 | |
|
Collapse file
src/Symfony/Component/Uid/Tests/UuidTest.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Uid/Tests/UuidTest.php+31-27Lines changed: 31 additions & 27 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
12 | 12 | |
13 | 13 | |
14 | 14 | |
| 15 | + |
15 | 16 | |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
16 | 21 | |
17 | 22 | |
18 | 23 | |
| ||
24 | 29 | |
25 | 30 | |
26 | 31 | |
27 | | - |
| 32 | + |
28 | 33 | |
29 | 34 | |
30 | 35 | |
31 | 36 | |
32 | | - |
| 37 | + |
33 | 38 | |
34 | 39 | |
35 | 40 | |
| ||
39 | 44 | |
40 | 45 | |
41 | 46 | |
42 | | - |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
43 | 53 | |
44 | 54 | |
45 | 55 | |
46 | 56 | |
47 | | - |
| 57 | + |
48 | 58 | |
49 | | - |
| 59 | + |
50 | 60 | |
51 | 61 | |
52 | 62 | |
53 | 63 | |
54 | 64 | |
55 | 65 | |
56 | | - |
| 66 | + |
57 | 67 | |
58 | 68 | |
59 | 69 | |
60 | 70 | |
61 | | - |
| 71 | + |
62 | 72 | |
63 | | - |
| 73 | + |
64 | 74 | |
65 | 75 | |
66 | 76 | |
67 | 77 | |
68 | | - |
| 78 | + |
| 79 | + |
69 | 80 | |
70 | | - |
| 81 | + |
| 82 | + |
71 | 83 | |
72 | 84 | |
73 | 85 | |
74 | 86 | |
75 | 87 | |
76 | 88 | |
77 | | - |
78 | | - |
79 | | - |
80 | | - |
81 | | - |
82 | | - |
83 | | - |
84 | | - |
85 | | - |
| 89 | + |
| 90 | + |
86 | 91 | |
87 | 92 | |
88 | 93 | |
89 | 94 | |
90 | | - |
91 | | - |
| 95 | + |
| 96 | + |
92 | 97 | |
93 | 98 | |
94 | 99 | |
| ||
99 | 104 | |
100 | 105 | |
101 | 106 | |
102 | | - |
| 107 | + |
103 | 108 | |
104 | 109 | |
105 | 110 | |
| ||
128 | 133 | |
129 | 134 | |
130 | 135 | |
131 | | - |
| 136 | + |
132 | 137 | |
133 | | - |
| 138 | + |
134 | 139 | |
135 | | - |
136 | | - |
137 | | - |
| 140 | + |
| 141 | + |
138 | 142 | |
139 | 143 | |
Collapse file
src/Symfony/Component/Uid/Ulid.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Uid/Ulid.php+2-2Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
53 | 53 | |
54 | 54 | |
55 | 55 | |
56 | | - |
| 56 | + |
57 | 57 | |
58 | 58 | |
59 | | - |
| 59 | + |
60 | 60 | |
61 | 61 | |
62 | 62 | |
|
Collapse file
src/Symfony/Component/Uid/Uuid.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Uid/Uuid.php+40-69Lines changed: 40 additions & 69 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
18 | 18 | |
19 | 19 | |
20 | 20 | |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
| 21 | + |
25 | 22 | |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
| 23 | + |
31 | 24 | |
32 | | - |
33 | | - |
34 | | - |
| 25 | + |
35 | 26 | |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | | - |
41 | | - |
42 | | - |
43 | | - |
| 27 | + |
| 28 | + |
44 | 29 | |
45 | 30 | |
46 | 31 | |
47 | 32 | |
48 | 33 | |
49 | | - |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
50 | 38 | |
51 | | - |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
52 | 57 | |
53 | 58 | |
54 | | - |
| 59 | + |
55 | 60 | |
56 | | - |
| 61 | + |
57 | 62 | |
58 | 63 | |
59 | | - |
| 64 | + |
60 | 65 | |
61 | | - |
| 66 | + |
62 | 67 | |
63 | 68 | |
64 | | - |
| 69 | + |
65 | 70 | |
66 | | - |
| 71 | + |
67 | 72 | |
68 | 73 | |
69 | | - |
| 74 | + |
70 | 75 | |
71 | | - |
| 76 | + |
72 | 77 | |
73 | 78 | |
74 | 79 | |
75 | 80 | |
76 | | - |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
77 | 86 | |
78 | 87 | |
79 | 88 | |
80 | 89 | |
81 | 90 | |
82 | 91 | |
83 | 92 | |
84 | | - |
85 | | - |
86 | | - |
87 | | - |
88 | | - |
89 | 93 | |
90 | 94 | |
91 | 95 | |
| ||
103 | 107 | |
104 | 108 | |
105 | 109 | |
106 | | - |
107 | | - |
108 | | - |
109 | | - |
110 | | - |
111 | | - |
112 | | - |
113 | | - |
114 | | - |
115 | | - |
116 | | - |
117 | | - |
118 | | - |
119 | | - |
120 | | - |
121 | | - |
122 | | - |
123 | | - |
124 | | - |
125 | | - |
126 | | - |
127 | | - |
128 | | - |
129 | | - |
130 | | - |
131 | | - |
132 | | - |
133 | | - |
134 | | - |
135 | | - |
136 | | - |
137 | | - |
138 | | - |
139 | 110 | |
140 | 111 | |
141 | 112 | |
|
Collapse file
src/Symfony/Component/Uid/UuidV1.php
Copy file name to clipboard+59Lines changed: 59 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
0 commit comments