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

[ObjectMapper] Preserve non-promoted constructor parameters#61785

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
fabpot merged 1 commit intosymfony:7.3fromrvanlaak:objectmapper-fix-61348
Sep 20, 2025

Conversation

@rvanlaak
Copy link
Contributor

@rvanlaakrvanlaak commentedSep 18, 2025
edited
Loading

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

The object mapper does already call the constructor, but its argument values were not determined / collected correctly as non-promoted parameters were skipped. Can not find or think of a valid reason for that. This PR fixes that the non-promoted constructor parameter values will get resolved and thereafter get mapped.

@carsonbot
Copy link

Hey!

Thanks for your PR. You are targeting branch "7.4" but it seems your PR description refers to branch "7.3".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

@frozenbrain
Copy link

frozenbrain commentedSep 18, 2025
edited
Loading

If non-promoted constructor parameters are now valid mapping targets, should we also support putting theMap attribute on those as well? Promoted parameters already support it, therefore I believe this should be also possible for non-promoted ones.

Also, one thing I noticed is that with this change a property with the same name as the constructor parameter has to exist, is that intentional? For example, the following code throws an exception, becauseTarget::$name does not exist:

class Target {    #[Map(if:false)]privatestring$nameUpper;publicfunction__construct(string$name)    {$this->nameUpper =strtoupper($name);    }}$mapper =newObjectMapper();$source =newstdClass();$source->name ='John';$target =$mapper->map($source, Target::class);

@rvanlaak
Copy link
ContributorAuthor

@frozenbrain nice catch, the PR now covers that case as well. See commite6009b3 for details on the fix.

The issue related tothe following comment:

// this may be filled later on see storeValue

When the property name differs from the constructor argument name, the constructor argument's value did actually not get filled in at a later time. It are the properties that get iterated over later on, which isn't aware of the constructor argument name anymore (as property field had a different name).

@rvanlaak
Copy link
ContributorAuthor

Failing check is unrelated.

@soyuka can you help with reviewing this PR?

Copy link
Contributor

@soyukasoyuka left a comment

Choose a reason for hiding this comment

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

indeed good catch

@fabpotfabpot modified the milestones:7.4,7.3Sep 20, 2025
@fabpot
Copy link
Member

Thank you@rvanlaak.

@fabpotfabpot merged commitf324858 intosymfony:7.3Sep 20, 2025
10 of 11 checks passed
@rvanlaakrvanlaak deleted the objectmapper-fix-61348 branchSeptember 23, 2025 11:06
@fabpotfabpot mentioned this pull requestSep 27, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

+1 more reviewer

@soyukasoyukasoyuka approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

7.3

Development

Successfully merging this pull request may close these issues.

[ObjectMapper] ObjectMapper::map calling constructor without any arguments

5 participants

@rvanlaak@carsonbot@frozenbrain@fabpot@soyuka

[8]ページ先頭

©2009-2025 Movatter.jp