mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #9647] Add enumFallbackValue optional parameter for PHP enum types #11771
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/doctrine/orm/pull/9647
State: closed
Merged: No
As proposed in https://github.com/doctrine/orm/issues/9433 I added the option to specify default value in case DB value is not castable to native PHP Enum.
The new option is called
enumDefaultValueand can be either null or Enum of the same type as the PHP property.Multiple cases are covered, e.g. if DB column is nullable, but
enumDefaultValueis set toSuit::Spadesand not null, in such case the PHP property will still be null if DB has null value, but will beSuit::Spadesfor any invalid value.In case DB value is NOT nullable and
enumDefaultValueis set toSuit::Spades, then if DB has empty value/null/invalid value thenSuit::Spadeswill be used.I encourage you to check the test, it explains the behavior.
In case
enumDefaultValueis not specified, then no behavior change occurs and the bundle works just like before.