Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Uid] remove Uuid::getVariant()#36064

Merged
fabpot merged 1 commit into
symfony:mastersymfony/symfony:masterfrom
nicolas-grekas:uuid-no-variantnicolas-grekas/symfony:uuid-no-variantCopy head branch name to clipboard
Mar 14, 2020
Merged

[Uid] remove Uuid::getVariant()#36064
fabpot merged 1 commit into
symfony:mastersymfony/symfony:masterfrom
nicolas-grekas:uuid-no-variantnicolas-grekas/symfony:uuid-no-variantCopy head branch name to clipboard

Conversation

@nicolas-grekas
Copy link
Copy Markdown
Member

Q A
Branch? master
Bug fix? no
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

Let's simplify the API. One less concept to grasp.
I think there are no use cases for variants in modern tech, check:
https://en.wikipedia.org/wiki/Universally_unique_identifier#Variants

@fabpot
Copy link
Copy Markdown
Member

fabpot commented Mar 14, 2020

Thank you @nicolas-grekas.

@fabpot fabpot merged commit aed93cd into symfony:master Mar 14, 2020
nicolas-grekas added a commit that referenced this pull request Mar 14, 2020
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 UUID
@nicolas-grekas nicolas-grekas deleted the uuid-no-variant branch March 14, 2020 13:57
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.