Skip to content

Allow Enum objects part of a type map to be serialized and deserialized#105

Open
agustingomes wants to merge 3 commits into
Crell:masterfrom
agustingomes:issues/10
Open

Allow Enum objects part of a type map to be serialized and deserialized#105
agustingomes wants to merge 3 commits into
Crell:masterfrom
agustingomes:issues/10

Conversation

@agustingomes
Copy link
Copy Markdown
Contributor

Description

This proposed change aims to allow Enum objects part of a TypeMap to be serialized and deserialized by establishing a serialized structure expected when working with enums in this context.

Motivation and context

fixes #10

How has this been tested?

composer all-checks helped validate the proposed changes.

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

Go over all the following points, and put an x in all the boxes that apply.

Please, please, please, don't send your pull request until all of the boxes are ticked. Once your pull request is created, it will trigger a build on our continuous integration server to make sure your tests and code style pass.

  • I have read the CONTRIBUTING document.
  • My pull request addresses exactly one patch/feature.
  • I have created a branch for this patch/feature.
  • Each individual commit in the pull request is meaningful.
  • I have added tests to cover my changes.
  • If my change requires a change to the documentation, I have updated it accordingly.

Comment thread composer.json
"require": {
"php": "~8.2",
"crell/attributeutils": "~1.3",
"crell/attributeutils": "dev-master#a118b55 as 1.3.1",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before merging this PR (if that is the direction we want to move towards) I will make sure I update this to a released version.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should probably go make a new release of that soon... 😅

Comment thread tests/TypeMapTest.php Outdated
Comment thread src/TypeMapOnNonObjectField.php Outdated
Comment thread src/TypeMapper.php Outdated
@agustingomes agustingomes force-pushed the issues/10 branch 2 times, most recently from ceb045c to b537a88 Compare March 27, 2026 22:48
Comment thread tests/SerdeTestCases.php Outdated
@Crell
Copy link
Copy Markdown
Owner

Crell commented Apr 22, 2026

(Haven't forgotten this, just been busy. And about to go on vacation for a few days.)

@agustingomes
Copy link
Copy Markdown
Contributor Author

agustingomes commented Apr 22, 2026

(Haven't forgotten this, just been busy. And about to go on vacation for a few days.)

No rush, I completely understand, time is often limited these days, so take your time.

This change uses the upstream commit allowing Crell#10 to be fixed.

NOTE: it is expected a new release of `crell/attributeutils` to be released. using directly the hash is for the purpose of validating the implementation changes in this PR
This commit implements serialization of an enum within a Type Map.

Therefore, individual enums being passed in a list, would be serialized as:

```
{"type": "enum", "value": "the-enum-value"}
```
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.

Enums lose type information when serialised as part of a static map

2 participants