-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Uid] Unify InvalidUuidException
and InvalidUlidException
#60328
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
base: 7.3
Are you sure you want to change the base?
Conversation
If we suddenly start to throw a different exception, wouldn't this break existing code that catches the "old" exception? |
Hi @derrabus ,
That's a great question. No, it wouldn't break, since it has never been released. That's why I'm opening this PR now, so that these two exceptions won't create backward compatibility promise starting from 7.3 and onward. |
Yes, it is not released yet |
This doesn't look like a good practice to me, so this sounds like a counter argument. What benefit do you expect from this PR over the current situation? Coincidentally, php-src is working on php/policies#17, that might give some food for thoughts on the topic. |
Specifically, I want to unify what exceptions are thrown form uid-classes. What I mean is following:
I want to unify it all so that whether you call Benefit is that |
I am not in favor of this change. If one wants to only care for one exception than for either |
One can not distinguish between public static function fromBase32(string $uid): static
{
if (26 !== \strlen($uid)) {
throw new InvalidArgumentException($uid, 'Invalid base-32 uid provided.');
}
return static::fromString($uid);
} So then it's not possible to distinguish anyway. |
As far as I remember, you were not in favor of the exceptions being introduced either. Also, I remember @nicolas-grekas was for the idea to have one single InvalidUidException, while I stated that it's better to have them separate. Now, I revised the code and see that it's better to have the unified interface so that make |
InvalidUuidException
and InvalidUlidException
Hi guys, I would like to move on if you don't mind |
I'm AFK until next week, I'll come back here ASAP. |
Sure, have a nice time Just want to make sure this doesn't get off to 7.3 release |
It's a small change, I think it mustn't need much work |
@nicolas-grekas , @fabpot , just a quick check-in, since I don't want to introduce BC promise for 7.3, is it all right right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me but let's keep only InvalidArgumentException, no need for InvalidUidException either.
This PR unifies
InvalidUuidException
andInvalidUlidException
, created as the part of #60226 .InvalidUidException
in itself gives enough context about its origin, and it's possible to determine whence the exception originated from by checking its getFile, or checking the trace.Therefore, it's not necessary to make two exceptions if there can be only one.