Conversation

MrYamous

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

case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
Copy link
Member

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;
Copy link
Member

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.

Copy link
Contributor Author

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 ?

public string $suit;

// or for a more typed property
#[Column(type: Types::TEXT)]
Copy link
Member

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.

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.

@MrYamous

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

Sign up for free to join this conversation on . Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.