Repository navigation
Use an enum type when looking up the class normalizer of an enum - #240
Merged
Merged
Conversation
getNormalizerOnClass always built the class type with Type::object(), so the guesser never saw a BackedEnumType for an enum class and never offered the EnumNormalizer. Extracting a backed enum directly gave its name and value, and hydrating it failed. An EnumNormalizer attribute without an explicit enum, on the enum or on an interface it implements, failed with a missing type for the same reason. The type is now built the way the type resolver builds it for a property of that class. An enum property with an explicit ObjectNormalizer also needs #239 to be hydrated again.
|
Hello 👋 Here are the most recent benchmark results, compared against StackHydrator
StackHydratorWithCryptography
StackHydratorWithLazy
This comment gets updated every time a new commit comes in. |
DanielBadura
approved these changes
Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
getNormalizerOnClass()built the class type withType::object(), so the guesser never offered theEnumNormalizerfor an enum class.extract(Status::Draft)returned['name' => 'Draft', 'value' => 'draft'],hydrate(Status::class, 'draft')failed, and an#[EnumNormalizer]without an explicit enum on the enum or on an interface it implements failed with a missing type. The class type is now built the way the type resolver builds it for a property.Things a caller can notice: extracting a backed enum directly now gives its value instead of name and value, and an enum inside an
ObjectMapNormalizernow fails on extract instead of producing data that could never be hydrated anyway. Metadata cached with the PSR-6 or PSR-16 factories keeps the old result until the cache is cleared. An enum property with an explicit#[ObjectNormalizer]round-trips once #239 is in as well.