-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Doctrine] Add documentation for Enum usage #19169
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: 6.4
Are you sure you want to change the base?
Conversation
doctrine/use_enum.rst
Outdated
case Hearts = 'H'; | ||
case Diamonds = 'D'; | ||
case Clubs = 'C'; | ||
case Spades = 'S'; |
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.
missing indentation for cases
namespace App\Enum; | ||
|
||
#[Column(type: Types::TEXT, enumType: Suit::class)] | ||
public string $suit; |
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.
It's a rare use case to map a property using a BackedEnum and not use it in the model; I wouldn't show this case. I think the above example should be the only one documented.
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.
I see your point. I'm quite in favour of showing both even if one use is rare and let developers choose the one that fit to their needs. Maybe we can add a comment to point which is the most common/recommended way ?
doctrine/use_enum.rst
Outdated
public string $suit; | ||
|
||
// or for a more typed property | ||
#[Column(type: Types::TEXT)] |
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.
It's a single-line value, so it should be Types::STRING
instead.
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.
I like this. Thanks Matthieu for contributing this.
However, we try to avoid creating vey small doc pages (because the require navigating from one small page to another and that frustrates most users). So, if it's possible, we should merge this as a new section in another article ... maybe inside the main doctrine.rst
article? Thanks.
LGTM I will update this |
Doctrine supports PHP native Enums for a while but i didn't find anything in the docs about it
I'm note sure about version to target. Enums are available from PHP 8.1 and SF 5.4 is 7.2+ then 6.4 looked good to me