8000 [Uid] Add NilUlid by fancyweb · Pull Request #41802 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

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.

$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

0