Skip to content

Conversation

@seyfahni
Copy link
Contributor

Add support for enum classes. They are serialized with a new serialize type MSGPACK_SERIALIZE_TYPE_ENUM (dynamic id 6) and stored by using the enum class name as key and the enum case name as value.

For example the serialized message pack blob from the added test (generated by msgpack-inspect):

--- - format: "fixmap"header: "0x82"length: 2children: - key: format: "nil"header: "0xc0"data: "0xc0"value: nullvalue: format: "fixint"header: "0x06"data: "0x06"value: 6 - key: format: "fixstr"header: "0xa8"length: 8data: "0x54657374456e756d"value: "TestEnum"value: format: "fixstr"header: "0xa5"length: 5data: "0x4f54484552"value: "OTHER"

Fixes issue #171.

This is incompatible with enums serialized before this change as they have been serialized as normal classes and thus did not set a numeric serialize type but the class name instead. Thus, old data will continue to fail deserialization in the same way if it does contain a serialized enum.

@rlerdorf
Copy link
Contributor

This looks good, let's merge it and get a new release out, please.

@rlerdorf
Copy link
Contributor

cc @m6w6

@m6w6
Copy link
Collaborator

m6w6 commented Aug 16, 2024

There are already quite some PRs waiting and rotting, I'll try to prepare a v3 with all the things ASAP 👍

@m6w6m6w6 closed this in 4ade6c3Aug 19, 2024
@m6w6
Copy link
Collaborator

m6w6 commented Aug 19, 2024

Merged as 93fe730

@seyfahniseyfahni deleted the 171-enum-serialization branch August 20, 2024 10:34
m6w6 added a commit that referenced this pull request Aug 20, 2024
m6w6 added a commit that referenced this pull request Aug 23, 2024
* Add support for PHP-8.1 Enums * merges #173 * fixes#171 * Add support for APCu * merges #162, #93 * Add OPT_ASSOC for roundtrip serialization of map. * merges #58
m6w6 added a commit that referenced this pull request Sep 25, 2024
* Add support for PHP-8.1 Enums * merges #173 * fixes#171 * Add support for APCu * merges #162, #93 * Add OPT_ASSOC for roundtrip serialization of map. * merges #58
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@seyfahni@rlerdorf@m6w6