Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[Uid] remove Uuid::getVariant() #36064
Let's simplify the API. One less concept to grasp.
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