Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add serialization and deserialization support for PHP 8.1 Enums.#173

Closed
seyfahni wants to merge 1 commit into
msgpack:mastermsgpack/msgpack-php:masterfrom
Gameforge4D:171-enum-serializationGameforge4D/msgpack-php:171-enum-serializationCopy head branch name to clipboard
Closed

Add serialization and deserialization support for PHP 8.1 Enums.#173
seyfahni wants to merge 1 commit into
msgpack:mastermsgpack/msgpack-php:masterfrom
Gameforge4D:171-enum-serializationGameforge4D/msgpack-php:171-enum-serializationCopy head branch name to clipboard

Conversation

@seyfahni

Copy link
Copy Markdown
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: 2
  children:
    - key:
        format: "nil"
        header: "0xc0"
        data: "0xc0"
        value: null
      value:
        format: "fixint"
        header: "0x06"
        data: "0x06"
        value: 6
    - key:
        format: "fixstr"
        header: "0xa8"
        length: 8
        data: "0x54657374456e756d"
        value: "TestEnum"
      value:
        format: "fixstr"
        header: "0xa5"
        length: 5
        data: "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

rlerdorf commented Aug 9, 2024

Copy link
Copy Markdown
Contributor

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

@rlerdorf

rlerdorf commented Aug 9, 2024

Copy link
Copy Markdown
Contributor

cc @m6w6

@m6w6

m6w6 commented Aug 16, 2024

Copy link
Copy Markdown
Collaborator

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

@m6w6 m6w6 closed this in 4ade6c3 Aug 19, 2024
@m6w6

m6w6 commented Aug 19, 2024

Copy link
Copy Markdown
Collaborator

Merged as 93fe730

@seyfahni seyfahni 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 free to 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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.