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] FixSerializedPath not working with constructor arguments#50193

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

Conversation

HypeMC
Copy link
Member

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

Currently the#[SerializedPath] attribute doesn't work with constructor arguments:

class Test{publicfunction__construct(        #[SerializedPath('[foo][bar]')]publicstring$bar,    ) {    }}$serializer->denormalize(['foo' => ['bar' =>'something']], Test::class);
In AbstractNormalizer.php line 384:                                                                                                                                      Cannot create an instance of "Test" from serialized data because its constructor requires parameter "bar" to be present.

Brajk19, juricaskorin, stipic, lskupnjak, plantas, spideyfusion, IvanBagaric97, matkomat, and dominikgalicc reacted with thumbs up emojistipic and ging-dev reacted with heart emoji
@HypeMCHypeMC requested a review fromdunglas as acode ownerApril 29, 2023 03:23
@carsonbotcarsonbot added this to the6.2 milestoneApr 29, 2023
@HypeMCHypeMC closed thisMay 6, 2023
@HypeMCHypeMC reopened thisMay 6, 2023
@HypeMCHypeMCforce-pushed theserialized-path-in-constructor branch frome13aa7a to0ff624cCompareMay 6, 2023 17:24
@nicolas-grekasnicolas-grekasforce-pushed theserialized-path-in-constructor branch from0ff624c to30e36edCompareMay 19, 2023 07:51
@nicolas-grekasnicolas-grekasforce-pushed theserialized-path-in-constructor branch from30e36ed to240c031CompareMay 19, 2023 07:59
@nicolas-grekas
Copy link
Member

Thank you@HypeMC.

@nicolas-grekasnicolas-grekas merged commit71f8c57 intosymfony:6.2May 19, 2023
@HypeMCHypeMC deleted the serialized-path-in-constructor branchMay 19, 2023 08:15
This was referencedMay 22, 2023
$reflectionClass = new \ReflectionClass($type);
$object = $this->instantiateObject($normalizedData, $type, $context, $reflectionClass, $allowedAttributes, $format);
$resolvedClass = $this->objectClassResolver ? ($this->objectClassResolver)($object) : $object::class;
$mappedClass = $this->getMappedClass($normalizedData, $type, $context);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning this breaks code where the doctrine discriminator has no property (ie exists only in the database)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@soyukasoyukasoyuka left review comments

@dunglasdunglasAwaiting requested review from dunglasdunglas is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
6.2
Development

Successfully merging this pull request may close these issues.

4 participants
@HypeMC@nicolas-grekas@soyuka@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp