Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[JsonEncoder] Replace normalizers by value transformers#59290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
chalasr merged 1 commit intosymfony:7.3frommtarld:feat/merge-normalizer
Feb 20, 2025

Conversation

mtarld
Copy link
Contributor

@mtarldmtarld commentedDec 23, 2024
edited
Loading

QA
Branch?7.3
Bug fix?no
New feature?yes
Deprecations?no
IssuesFix#59288
LicenseMIT

For a better DX and to avoid confusion with Serializer's normalizers and denormalizers:

  1. Merge theNormalizerInterface andDenormalizerInterface to a singleValueTransformerInterface:
interface ValueTransformerInterface{publicfunctiontransform(mixed$value,array$options = []):mixed;publicstaticfunctiongetJsonValueType():Type;}
  1. Replace theNormalizer andDenormalizer attributes by a singleValueTransformer attribute:
#[\Attribute(\Attribute::TARGET_PROPERTY)]class ValueTransformer{// ...publicfunction__construct(callable|string|null$toNativeValue =null,// can be a callable or a ValueTransformerInterface service idcallable|string|null$toJsonValue =null,// can be a callable or a ValueTransformerInterface service id    ) {// ...    }// ...

/cc@wouterj

wouterj and yceruto reacted with rocket emoji
@carsonbotcarsonbot added this to the7.3 milestoneDec 23, 2024
@mtarldmtarld changed the title[JsonEncoder] Replace normalizers by value resolvers[JsonEncoder] Replace normalizers by value transformersDec 23, 2024
@chalasr
Copy link
Member

Looks like psalm made a good point

mtarld reacted with thumbs up emoji

@mtarld
Copy link
ContributorAuthor

Yep, I'm on it!

chalasr reacted with rocket emoji

@mtarldmtarldforce-pushed thefeat/merge-normalizer branch 2 times, most recently from93a0d7b to0968e58CompareDecember 23, 2024 15:00
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

toPhp or toNative?
what's the requirements of the value returned by toJson (which is going to be a PHP value ;) )

@mtarldmtarldforce-pushed thefeat/merge-normalizer branch 2 times, most recently from01c0880 to906e354CompareJanuary 6, 2025 11:49
@mtarldmtarldforce-pushed thefeat/merge-normalizer branch 4 times, most recently from7f848d9 to2049277CompareJanuary 8, 2025 14:24
@OskarStark
Copy link
Contributor

If I get it right, the PR header needs an update, right?

mtarld reacted with thumbs up emoji

@mtarld
Copy link
ContributorAuthor

Indeed, you're right, updated!

@nicolas-grekas
Copy link
Member

(rebase needed)

@mtarldmtarldforce-pushed thefeat/merge-normalizer branch 2 times, most recently from507d527 to2b64dcdCompareJanuary 27, 2025 11:58
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

just one phpdoc thing and LGTM, thanks.

@chalasr
Copy link
Member

Thank you@mtarld.

@chalasrchalasr merged commit68944f5 intosymfony:7.3Feb 20, 2025
9 of 11 checks passed
@fabpotfabpot mentioned this pull requestMay 2, 2025
fabpot added a commit that referenced this pull requestMay 23, 2025
This PR was merged into the 7.3 branch.Discussion----------[JsonStreamer] also reject `\DateTime` subclasses| Q             | A| ------------- | ---| Branch?       | 7.3| Bug fix?      | no| New feature?  | no| Deprecations? | no| Issues        | following#59290 (comment)| License       | MITCommits-------0d6cda3 also reject \DateTime subclasses
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@chalasrchalasrchalasr approved these changes

@derrabusderrabusAwaiting requested review from derrabus

Assignees
No one assigned
Projects
None yet
Milestone
7.3
Development

Successfully merging this pull request may close these issues.

[DX][JsonEncoder] Can we find a better name for normalizer/encoder
6 participants
@mtarld@chalasr@OskarStark@nicolas-grekas@derrabus@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp