Skip to content

EnumCast: Use ::tryFrom in fromDb() - #177

Merged
nilmerg merged 1 commit into
mainfrom
enumcast-tryfrom
Oct 16, 2026
Merged

nilmerg merged 1 commit into
mainfrom
enumcast-tryfrom

Conversation

@nilmerg

@nilmerg nilmerg commented Oct 16, 2026

Copy link
Copy Markdown
Member

Schema changes may remove or add new values to an enum, so existing rows should not throw an exception. The consumer is supposed to ensure only valid values are persisted, hence toDb() still throws. Existing rows have to be seen as always valid, though.

@nilmerg nilmerg self-assigned this Oct 16, 2026
@cla-bot cla-bot Bot added the cla/signed label Oct 16, 2026
Comment thread src/Behavior/EnumCast.php Resolved
Schema changes may remove or add new values to an enum,
so existing rows should not throw an exception. The
consumer is supposed to ensure only valid values are
persisted, hence toDb() still throws. Existing rows
have to be seen as always valid, though.
@nilmerg
nilmerg merged commit 01a0d9a into main Oct 16, 2026
13 checks passed
@nilmerg
nilmerg deleted the enumcast-tryfrom branch October 16, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants