Skip to content

[Uid] use one class per type of UUID #36066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2020

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Mar 13, 2020

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.

@nicolas-grekas nicolas-grekas added this to the next milestone Mar 13, 2020
@nicolas-grekas nicolas-grekas requested a review from lyrixx March 13, 2020 20:33
@nicolas-grekas nicolas-grekas force-pushed the uuid-classes branch 2 times, most recently from 029531a to 5f6a725 Compare March 13, 2020 20:43
@nicolas-grekas nicolas-grekas force-pushed the uuid-classes branch 2 times, most recently from 96561be to 8441fb0 Compare March 13, 2020 21:22
@fabpot
Copy link
Member

fabpot commented Mar 14, 2020

#36064 has been merged now.

@nicolas-grekas
Copy link
Member Author

thanks, rebased

@nicolas-grekas nicolas-grekas merged commit 7dc6da6 into symfony:master Mar 14, 2020
@nicolas-grekas nicolas-grekas deleted the uuid-classes branch March 14, 2020 13:56
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
@fabpot fabpot mentioned this pull request May 5, 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.

6 participants