On Mon, 4 Jan 2021 at 15:21, Pierre R. <pierre-...@processus.org> wrote:

> I do not agree with having values per default, this is error prone in
> most of my use cases.
>
> In most case where I need enums, I often need to replicate those in
> database too, or in message broker serialized messages: in this context,
> whenever I need to fix a typo in a enum case name, for example, if I use
> default values, I would have errors with my existing database records or
> live messages.
>
> I prefer to keep an explicit switch/match to hydrate values from
> database or elsewhere, and use a value-less enum on the PHP side. Case
> names are the only semantically important value for the developer, and
> your code should not care about having a string value. In most cases
> only exchanges with the outside world in an heterogeneous environment
> (having a database makes it heterogeneous) care about having string
> values. In this case, I highly prefer having explicitely written
> (de)hydration code than automatic magic values happening over the place.
>

I agree.

Peter

Reply via email to