-
Notifications
You must be signed in to change notification settings - Fork 95
feat: stub DataMapperInterface #418
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Ensure TData of FormInterface is provided Set TData on mixed since we don't know the type of the child forms Add template for in DataMapperInterface refs: phpstan#417
@JefvdA
JefvdA
Jan 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it's stated in the docs ( https://symfony.com/doc/current/form/data_mappers.html#creating-a-data-mapper ), the following logic is needed:
// there is no data yet, so nothing to prepopulate if (null === $viewData) { return; }
This, as it seems that mapDataToForms is called before the data is avaialble. Which will mean that $viewData will be null at that time.
Thus I propose the following change:
For example, the stub file for the FormTypeInterface also has a generic type, but also has it defined nullable when it's being passed to it's buildForm method.
There are two different PRs with this stub: #422
- Both have the same mistake of not registering the stub.
- Both are slightly different so you should agree first how it should look like.
I've set TData of FormInterface to mixed since each child form can have a different type.
refs: #417