Skip to content

[Uid] Add NilUlid #41802

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
Jun 27, 2021
Merged

[Uid] Add NilUlid #41802

merged 1 commit into from
Jun 27, 2021

Conversation

fancyweb
Copy link
Contributor

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

NilUlid is not really official but I think it would be useful. The goal is to be able to do new NilUlid(); instead of new Ulid('00000000000000000000000000'); and therefore to detect it more easily (like for the NilUuid). Currently I'm creating the class manually. My use case is using it as a placeholder.

@@ -67,10 +67,14 @@ public static function fromString(string $ulid): parent
if (36 === \strlen($ulid) && Uuid::isValid($ulid)) {
$ulid = (new Uuid($ulid))->toBinary();
} elseif (22 === \strlen($ulid) && 22 === strspn($ulid, BinaryUtil::BASE58[''])) {
$ulid = BinaryUtil::fromBase($ulid, BinaryUtil::BASE58);
$ulid = str_pad(BinaryUtil::fromBase($ulid, BinaryUtil::BASE58), 16, "\0", \STR_PAD_LEFT);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs #41801

@nicolas-grekas nicolas-grekas added this to the 5.4 milestone Jun 23, 2021
@fabpot
Copy link
Member

fabpot commented Jun 27, 2021

Thank you @fancyweb.

@fabpot fabpot merged commit fa0e5a0 into symfony:5.4 Jun 27, 2021
@fancyweb fancyweb deleted the uid/nil-ulid branch June 28, 2021 07:13
This was referenced Nov 5, 2021
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.

7 participants