-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
Add support for value-of<BackedEnum> #537
Conversation
Added Integration tests too, raised an issue with my original work. |
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.
Excellent work, thanks!
Just a few minor comments; I'll try to address these during the train trip I'm about to make. 😁
throw new ClosingBracketMissing($this->symbol()); | ||
} | ||
|
||
if ($subType instanceof UnionType && count($subType->types()) === 1) { |
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.
This is not necessary, a union type always has at least 2 elements.
} | ||
} | ||
|
||
return new UnionType(...$list); |
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.
As said earlier, a union type must have at least two elements. We must handle the case where a backed enum has only one case (in which case we can directly return the first element of the list, I guess). This would also require a specific test for it!
use RuntimeException; | ||
|
||
/** @internal */ | ||
final class NonArrayOf extends RuntimeException implements InvalidType |
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.
This class seems not to be used.
Thank you for you work @robchett! This will be available in next release. |
No description provided.