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

[PropertyAccess] Fix handling of uninitialized property of anonymous class#44983

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

Closed
filiplikavcan wants to merge2 commits intosymfony:5.4frombratiask:5.4

Conversation

@filiplikavcan
Copy link
Contributor

@filiplikavcanfiliplikavcan commentedJan 11, 2022
edited by nicolas-grekas
Loading

QA
Branch?4.4
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
LicenseMIT
$object =newclass() {publicstring$uninitialized;};$this->propertyAccessor->getValue($object,'uninitialized');

Expected

ThrowsUninitializedPropertyException with message "The property "class@anonymous::$uninitialized" is not readable because it is typed "string". You should initialize it or declare a default value instead.".

Actual

ThrowsError with message "Typed property class@anonymous::$publication must not be accessed before initialization".

Side efect

Form with data of an anonymous class instance cannot be created. This code throws "Typed property class@anonymous::$name must not be accessed before initialization":

// in controller$data =newclass() {publicstring$name;};$form =$this->createForm(SomeFormType::class,$data);

This works as expected:

// in controllerclass SomeClass {publicstring$name;};$data =newSomeClass;$form =$this->createForm(SomeFormType::class,$data);

No exception is thrown because PropertyPathAccessor catches UninitializedPropertyException and returns null instead.

@carsonbot
Copy link

It looks like you unchecked the "Allow edits from maintainer" box. That is fine, but please note that if you have multiple commits, you'll need to squash your commits into one before this can be merged. Or, you can check the "Allow edits from maintainers" box and the maintainer can squash for you.

Cheers!

Carsonbot

@filiplikavcanfiliplikavcan changed the title[PropertyAccess] Fix handling of uninitialized property of anonymous …[PropertyAccess] Fix handling of uninitialized property of anonymous classJan 11, 2022
@filiplikavcan
Copy link
ContributorAuthor

filiplikavcan commentedJan 11, 2022
edited
Loading

Hm, the failing integration test does not seem to be related to the changes in this PR. Can somebody help me with that if it is related?

@carsonbot
Copy link

Hey!

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

Cheers!

Carsonbot

@nicolas-grekas
Copy link
Member

Thanks for the PR. Continued in#44983.
Please allow edits from maintainers next time!

nicolas-grekas added a commit that referenced this pull requestJan 12, 2022
… anonymous class (filiplikavcan)This PR was merged into the 4.4 branch.Discussion----------[PropertyAccess] Fix handling of uninitialized property of anonymous class| Q             | A| ------------- | ---| Branch?       | 4.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       |Fix#44983| License       | MIT| Doc PR        | -Commits-------27d5edf [PropertyAccess] Fix handling of uninitialized property of anonymous class
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

3 participants

@filiplikavcan@carsonbot@nicolas-grekas

[8]ページ先頭

©2009-2025 Movatter.jp