[PR #11666] Auto-detect values for EnumType columns #13171

Closed
opened 2026-01-22 16:16:25 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/11666

State: closed
Merged: Yes


Follow-up to #11657, leverages doctrine/dbal#6536.

This PR allows us to detect the enumType and options.values settings for a typed property with type: Types::ENUM.

Before:

#[Entity]
class Card
{
    #[Id]
    #[GeneratedValue]
    #[Column]
    public int $id;

    #[Column(
        type: Types::ENUM,
        enumType: Suit::class,
        options: ['values' => ['H', 'D', 'C', 'S']],
    )]
    public Suit $suit;
}

After:

#[Entity]
class Card
{
    #[Id]
    #[GeneratedValue]
    #[Column]
    public int $id;

    #[Column(type: Types::ENUM)]
    public Suit $suit;
}

Note that the type: Types::ENUM part is still required if we want to have an actual ENUM column in MySQL/MariaDB. We still default to Types::STRING or TYPES::INTEGER for columns types with a PHP enum as this is the more portable solution and the safer default.

**Original Pull Request:** https://github.com/doctrine/orm/pull/11666 **State:** closed **Merged:** Yes --- Follow-up to #11657, leverages doctrine/dbal#6536. This PR allows us to detect the `enumType` and `options.values` settings for a typed property with `type: Types::ENUM`. #### Before: ```php #[Entity] class Card { #[Id] #[GeneratedValue] #[Column] public int $id; #[Column( type: Types::ENUM, enumType: Suit::class, options: ['values' => ['H', 'D', 'C', 'S']], )] public Suit $suit; } ``` #### After: ```php #[Entity] class Card { #[Id] #[GeneratedValue] #[Column] public int $id; #[Column(type: Types::ENUM)] public Suit $suit; } ``` Note that the `type: Types::ENUM` part is still required if we want to have an actual `ENUM` column in MySQL/MariaDB. We still default to `Types::STRING` or `TYPES::INTEGER` for columns types with a PHP enum as this is the more portable solution and the safer default.
admin added the pull-request label 2026-01-22 16:16:25 +01:00
admin closed this issue 2026-01-22 16:16:26 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#13171