Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
MrYamous wants to merge5 commits intosymfony:6.4
base:6.4
Choose a base branch
Loading
fromMrYamous:doctrine/use-enums

Conversation

MrYamous
Copy link
Contributor

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
ContributorAuthor

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 beTypes::STRING instead.

Copy link
Member

@javiereguiluzjaviereguiluz left a 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 maindoctrine.rst article? Thanks.

@MrYamous
Copy link
ContributorAuthor

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 maindoctrine.rst article? Thanks.

LGTM I will update this

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@javiereguiluzjaviereguiluzjaviereguiluz left review comments

@ycerutoycerutoyceruto requested changes

@94noni94noni94noni approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
6.4
Development

Successfully merging this pull request may close these issues.

5 participants
@MrYamous@javiereguiluz@94noni@yceruto@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp