Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[PropertyAccess] Reset object property to either null or uninitialized state#44880
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
base:7.4
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
carsonbot commentedDec 31, 2021
Hey! I see that this is your first PR. That is great! Welcome! Symfony has acontribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
carsonbot commentedDec 31, 2021
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 |
carsonbot commentedJan 1, 2022
Hey! I think@HeahDude has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
Description
I propose extending Property Accessor with an optional feature that could enable checking whether object setter has a non-nullable parameter and would call unset($object->parameter) instead of $object->setParameter($value) if $value is null and $object implements __unset() method.
Motivation
Form component could use this feature and reset non-nullable properties to uninitialized state when null value is submitted for a non-nullable property. Currently when a NotNull constraint is set on a property it is only evaluated for a new object (with uninitialized properties). Once the value for the property is set (for example through Doctrine hydration) and a user submits an empty/null value the constraint is never evaluated because execution fails on Property Accessor trying to call setter with non-nullable parameter.
Example