-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Support array of enums #333
Conversation
@lstrojny thanks for the PR! I took the liberty and retargeted this to 3.2.0 as this is a feature. I took a quick look into ODM and if I'm not mistaken the changes here in |
That is correct. In fact I am using the feature branch with ODM and it just works |
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.
Also please squash your commits afterwards
/** @var string[]|int[] $values */ | ||
$values = array_map([self::class, 'fromEnum'], $enum); | ||
|
||
return $values; |
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.
Let's avoid recursion in favour of something along
/** @var string[]|int[] $values */ | |
$values = array_map([self::class, 'fromEnum'], $enum); | |
return $values; | |
return array_map(fn(BackedEnum $e) => $e->value, $enum); |
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.
But compatible with PHP 7.2 :(
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.
Done
Thanks! I've PRed doctrine/mongodb-odm#2532 with a test for future us. I'll see if there are any plans for releasing 3.2.0 here. |
Thanks @lstrojny! I'll be releasing 3.2.0 shortly so you may get back to stable branch ;) |
Support array of enums, so that e.g. with ODM you can do something like this