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
Description
When PHP 7.4 typed property is accessed in form before initialization Symfony throws an exception with a message The property "App\Form\Model\ContactFormModel::$firstName" is not readable because it is typed "string". You should either initialize it or make it nullable using "?string" instead. which is entirely not true.
Possible Solution
Improve the error message, I will provide the PR. What do you think about The property "App\Form\Model\ContactFormModel::$firstName" is not readable because it is typed "string". You should either initialize it or make it nullable using "?string" **and initialize it to null** instead.?
The text was updated successfully, but these errors were encountered:
… in php 7.4 (lmasforne)
This PR was squashed before being merged into the 3.4 branch.
Discussion
----------
[PropertyAccess] Improve message of unitialized property in php 7.4
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | Fix#36277
| License | MIT
Improve message of unitialized property in php 7.4 ;
Before
You should either initialize it or make it nullable using "?string" instead.
After
You should either initialize it or make it nullable using "?string $var = null" instead.
Commits
-------
3c8bf2d [PropertyAccess] Improve message of unitialized property in php 7.4
Symfony version(s) affected: >= 3.4
Description
When PHP 7.4 typed property is accessed in form before initialization Symfony throws an exception with a message
The property "App\Form\Model\ContactFormModel::$firstName" is not readable because it is typed "string". You should either initialize it or make it nullable using "?string" instead.
which is entirely not true.If I have this in my model:
And will make it this according to the message:
The error is still there since I need to make it this
How to reproduce
Create a model with below code, use it in a form, render the form and try to fix the error by the exception message instructions.
Possible Solution
Improve the error message, I will provide the PR. What do you think about
The property "App\Form\Model\ContactFormModel::$firstName" is not readable because it is typed "string". You should either initialize it or make it nullable using "?string" **and initialize it to null** instead.
?The text was updated successfully, but these errors were encountered: