mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #9304] Add support for PHP 8.1 enums. #11505
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/9304
State: closed
Merged: Yes
ORM based support for enums.
It works based on a new
ReflectionEnumPropertythat wraps around other reflection property types. This avoids the problem of other approaches that hook into DBAL Type abstraction, since that would require some kind of paramterization which is not supported at the moment. In addition it would at the moment require to register each enum explicitly, which this approach does not.This includes support for typed property detection, the previous example could be written as:
As for error handling, when the database returns an invalid enum case, then the regular
ValueErroris not caught thatBackedEnum::fromthrows.