# Backed Enum and serialization

- Thread: https://externals.io/message/129670
- Original archive: https://news-web.php.net/php.internals/129670
- Started by ignace nyamagana butera on 2025-12-22T10:13:00+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #129670 — ignace nyamagana butera — 2025-12-22T10:13:00+00:00

URL: https://externals.io/message/129670#129670

Hi all,
recently through Máté, I discovered that Backed Enum behaviour was changed
for http_build_query in PHP8.4 see the github PR
https://github.com/php/php-src/issues/15650
This change was never discussed on the mailing list and seems to have been
prompt to align with a SOAP client serialization fix and to align with how
BackedEnum are serialized
using json_encode.

Now I believe the PHP does some serialization elsewhere for instance when
using fputcsv. My question is should Backed Enum also be handled
differently in case of fputcsv ?

IMHO if we want consistency in the PHP language the answer should be yes
and have BackedEnum converted to their value (string
or int) before serialization. Either way I believe a discussion about it
should take place. My goal would be to have a clear rule on how Backed Enum
is serialized across PHP regardless
of the feature. I have not made any attempt at screening or searching for
all serialization mechanisms in PHP but I presume they should all be listed
and updated to follow the same rule
for consistency.

Best regards,
Ignace
