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] Allow to denormalize objects that have constructor checks without using constructor#45508

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

Open
fbiesse wants to merge2 commits intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromfbiesse:feat/allow_denormalize_without_constructor

Conversation

fbiesse
Copy link

QA
Branch?6.1
Bug fix?no
New feature?yes
Deprecations?no
Tickets
LicenseMIT
Doc PR-

In some cases it would be great to be able to denormalize objects without having to pass by the constructor.
In my case, I have Value Objects that perform validations in their constructor. These objects are normalized, json encoded and persisted in a mongodb database.
If the validation rules changed, it is impossible to denormalize some objects because of the constructor checks, even if the properties exists.
This PR allow to use pure property reflection by skiping the constructor even if it is not private.

To allow this you only need to add the new context paramcreate_instance_without_constructor

BafS reacted with thumbs up emoji
@carsonbot
Copy link

Hey!

I think@BafS has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@dunglas
Copy link
Member

I'm not against this feature, but we should stop "polluting" the abstract class. Our long-term goal is to get rid of it. In my opinion, we should finish and merge#38487 first, then add features such as this one as small, single-responsibility classes.

@fbiesse
Copy link
Author

Sure, I agree that it would be clearer.
But#38487 is more than one year old and the last activity was on Oct 2021and unfinished, so this "small" feature will maybe wait more than one year before being integrated because of that. It's sad to read.

EmilMassey reacted with thumbs up emoji

@dunglas
Copy link
Member

Any help is welcome to finish#38487.

@fbiesse
Copy link
Author

I have a question. Not about the pull request but more about a way to go faster in my company's project.
I really need that functionality and I'm looking for a workaround.
It looks like I have to wait for#38487 that is untouched since Oct 20, 2020 and still on study. So I can avoid this because I'll be fired of my company if I tell them they have to wait 2 years ton continue the project :D.
I could work with my fork, but it's not a good idea because I don't know if the feature would be integrated in the future and I'll miss possible security fixes.
I think the best option would be to use jms/serializer that allow to do, but I didn't want to multiply serialization systems.
I know it's a limit in opensource projects and new features.
Do you see better options in my case, I'm pretty sure you already had this kind of problems.

Thank you.

@EmilMassey
Copy link

@fbiesse you can alwayscreate your own custom normalizer in your application to support your needs. That way you only need to maintain the normalizer instead of the whole fork.

fbiesse and dunglas reacted with thumbs up emoji

@fabpotfabpot modified the milestones:6.1,6.2May 20, 2022
@Korbeil
Copy link
Contributor

I have a question. Not about the pull request but more about a way to go faster in my company's project. I really need that functionality and I'm looking for a workaround. It looks like I have to wait for#38487 that is untouched since Oct 20, 2020 and still on study. So I can avoid this because I'll be fired of my company if I tell them they have to wait 2 years ton continue the project :D. I could work with my fork, but it's not a good idea because I don't know if the feature would be integrated in the future and I'll miss possible security fixes. I think the best option would be to use jms/serializer that allow to do, but I didn't want to multiply serialization systems. I know it's a limit in opensource projects and new features. Do you see better options in my case, I'm pretty sure you already had this kind of problems.

Thank you.

#38487 is somewhat finished for what I could do, the remaining issue is linked to#38487 (comment), if you can find a solution the PR will be unblocked, but there is not much to change appart from that.

@nicolas-grekasnicolas-grekas modified the milestones:6.2,6.3Nov 5, 2022
@nicolas-grekasnicolas-grekas modified the milestones:6.3,6.4May 23, 2023
@fbiesse
Copy link
Author

I just don't want to finish#38487 for my simple need. For me it's out of the context of this PR.

@nicolas-grekasnicolas-grekas modified the milestones:6.4,7.1Nov 15, 2023
@xabbuhxabbuh modified the milestones:7.1,7.2May 15, 2024
@GromNaN
Copy link
Member

#38487 have been closed. Is there any interest in updating this PR?

Automapper allows skipping the constructor using#[Mapper(constructorStrategy: ConstructorStrategy::NEVER)]. That can be considered as an alternative solution.

@fabpotfabpot modified the milestones:7.2,7.3Nov 20, 2024
@fabpotfabpot modified the milestones:7.3,7.4May 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@EmilMasseyEmilMasseyEmilMassey approved these changes

@dunglasdunglasAwaiting requested review from dunglasdunglas is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

9 participants
@fbiesse@carsonbot@dunglas@EmilMassey@Korbeil@GromNaN@fabpot@nicolas-grekas@xabbuh

[8]ページ先頭

©2009-2025 Movatter.jp