You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
null|TData generic parameter changed for the return type
Why: this would allow check the $this->createForm(FormType::class, ['rubbish']) compatibility: if the FormType does not extend AbstractType<array{0: 'rubbish'}> then it will be marked as incompatible.
Thoughts?
The text was updated successfully, but these errors were encountered:
Good idea, it makes perfect sense. But why return nullable FormInterface<null|TData>?
FormInterface:getData already returns null|TData. It has to, because create methods don't pass $data parameter, which then triggers empty_data callback.
Because createForm's second argument $data is declared as having = null by default in symfony, and having generic parameter nullable was the only way I could find working to make psalm happy about type-checking it.
FormInterface:getData already returns null|TData. It has to, because create methods don't pass $data parameter, which then triggers empty_data callback.
Indeed, but psalm wasn't accepting it 🤷 So it was more like - overcoming the psalm limitation (or a bug?), than a thoughtful decision :-D
Current definition is the following:
psalm-plugin-symfony/src/Stubs/5/Bundle/FrameworkBundle/Controller/AbstractController.stubphp
Lines 18 to 26 in fb801a9
I suggest to change it to:
What has changed:
TData $data
parameter addednull|TData
generic parameter changed for the return typeWhy: this would allow check the
$this->createForm(FormType::class, ['rubbish'])
compatibility: if theFormType
does not extendAbstractType<array{0: 'rubbish'}>
then it will be marked as incompatible.Thoughts?
The text was updated successfully, but these errors were encountered: