Skip to content

[Uid] Rework internal format conversion #58089

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
Aug 27, 2024

Conversation

alexandre-daubois
Copy link
Member

Q A
Branch? 7.2
Bug fix? no
New feature? no
Deprecations? no
Issues -
License MIT

On a second look, the control flow is a bit confusing so I propose this refactor to clear things up.

@nicolas-grekas
Copy link
Member

Thank you @alexandre-daubois.

@nicolas-grekas nicolas-grekas merged commit f892c58 into symfony:7.2 Aug 27, 2024
9 of 10 checks passed
@@ -214,6 +217,11 @@ private static function transformToRfc4122(string $uuid, int $format): string
$uuid = $ulid->toRfc4122();
}

if ($inputUuid === $uuid && !($format & self::FORMAT_RFC_4122)) {
// input format doesn't match the input string
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not throw here ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't want to trigger the heavy exception mechanism (even more for an exception we don't rethrow to the user) for something that we want to be very fast, like validating an UUID

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