-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
Union for variadic types #183
Comments
Hm, i think we can allowing extra arguments to Type\union and Type\intersection ( i prefer if these two provide the same API ). This will also prevent a BC break, in v2.0 we can drop $right and $left and make both union and intersection accept variadic arguments. |
🤔 Hmm, I kept in my that I was thinking about suggestion to define extra function to prevent boilerplate when we need define union type with a lot of cases. |
we can have |
Looks great for me. |
Are you up for a PR? |
I'm on it |
By the way, why you want to make |
it doesn't to me too, but that's solvable via |
Do you prefer runtime exception instead of statically analysed issue? |
the reason is i don't like WDYT about |
You right, |
There are a lot of situations may occur when we need to define union from several cases.
For example: need to define enum of states.
This would look like:
Inferred type would be:
I guess it would be great to have better solution like:
I do understand that
Psl\Type\Internal\UnionType
has only 2 branches: left and rightThat's why propose just implement a function with signature:
As alternatives I may guess there is more suitable name for function.
This may be named like
literals
orone_of
or etc.This function may also be implemented in user land, but I think it would be great to have unified solution inside core of the library.
Want to hear other guys thoughts.
If this would be approved, I may produce PR.
As I can see, this is very light enhancement.
The text was updated successfully, but these errors were encountered: