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

[Serializer] Add feature description forAbstractNormalizer::REQUIRE_ALL_PROPERTIES context option#17979

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
xabbuh merged 7 commits intosymfony:6.3fromchristian-kolb:prevent-nullable-fallback
Nov 21, 2023

Conversation

@christian-kolb
Copy link
Contributor

This PR adds the feature description for the new context flag for the Serializer component introduced here:symfony/symfony#49553

@OskarStarkOskarStark added the Waiting Code MergeDocs for features pending to be merged labelFeb 28, 2023
@carsonbotcarsonbot modified the milestones:6.3,nextFeb 28, 2023
christian-kolband others added3 commitsFebruary 28, 2023 09:40
Co-authored-by: Oskar Stark <oskarstark@googlemail.com>
Co-authored-by: Oskar Stark <oskarstark@googlemail.com>
Co-authored-by: Oskar Stark <oskarstark@googlemail.com>
Co-authored-by: Oskar Stark <oskarstark@googlemail.com>
@christian-kolbchristian-kolb changed the title[Serializer] Add feature description forAbstractNormalizer::PREVENT_NULLABLE_FALLBACK context option[Serializer] Add feature description forAbstractNormalizer::REQUIRE_ALL_PROPERTIES context optionMay 5, 2023
nicolas-grekas added a commit to symfony/symfony that referenced this pull requestMay 5, 2023
…listed in the input (Christian Kolb)This PR was merged into the 6.3 branch.Discussion----------[Serializer] Add flag to require all properties to be listed in the input| Q             | A| ------------- | ---| Branch?       | 6.3| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Tickets       |Fix#49504| License       | MIT| Doc PR        |symfony/symfony-docs#17979The PR#40522 introduced a fallback for nullable properties to be set to `null` when they aren't provided as parameters.A drawback of that approach is that it easier for bugs to appear through typos or renamings of those properties. I think the current implementation makes perfect sense as a default. Therefore, this PR introduces a new context flag that prevents that fallback behaviour. This way nothing changes for existing systems, but for people wanting more control, it's possible to set a flag.### Example```phpfinal class Product{    public function __construct(        public string $name,        public ?int $costsInCent,    ) {    }}// This works and results in $costsInCent as null$product = $this->serializer->deserialize(    '{"name": "foo"}',    Product::class,    JsonEncoder::FORMAT,);// When using the flag, only the following JSON is valid$product = $this->serializer->deserialize(    '{"name": "foo", "costsInCent": null}',    Product::class,    JsonEncoder::FORMAT,    [        AbstractNormalizer::PREVENT_NULLABLE_FALLBACK => true,    ],);// This would result in an error due to missing parameters$product = $this->serializer->deserialize(    '{"name": "foo"}',    Product::class,    JsonEncoder::FORMAT,    [        AbstractNormalizer::PREVENT_NULLABLE_FALLBACK => true,    ],);```Commits-------d62410a [Serializer] Add flag to require all properties to be listed in the input
@christian-kolb
Copy link
ContributorAuthor

@OskarStark The connected PR was just merged 🙂
Can this also be merged? I saw that there have been a lot of commits in the meantime. Otherwise I do the changes again on the current version if that helps.

@xabbuhxabbuh removed the Waiting Code MergeDocs for features pending to be merged labelNov 21, 2023
@xabbuhxabbuh modified the milestones:next,6.3Nov 21, 2023
@xabbuh
Copy link
Member

Thank you@christian-kolb.

@xabbuhxabbuh merged commitc0eb95c intosymfony:6.3Nov 21, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@OskarStarkOskarStarkOskarStark approved these changes

+1 more reviewer

@maxbeckersmaxbeckersmaxbeckers approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

6.3

Development

Successfully merging this pull request may close these issues.

5 participants

@christian-kolb@xabbuh@OskarStark@maxbeckers@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp