title: Symfony: Form issue using Return type hinting in Doctrine Entity methods
body: <p>I was being exceptionally diligent today and decided to return-type hint all of my symfony entity methods. So:</p>
  
  <pre><code>&lt;?php
  
  Class User {
      private string $username;
      public method getUsername(): string {}
  }
  </code></pre>
  
  <p>all good and well, until I made a form to create a new user:</p>
  
  <pre><code>$user = new User();
  $this-&gt;createForm(SignupType::class, $user);
  </code></pre>
  
  <p>when the form is displayed, Symfony automatically gets the properties of this new instance of <code>User $user</code>. But since it is a new instantiation, its <code>username</code> property is of course still <code>null</code>, which is an incorrect return type as it needs to be <code>string</code>.</p>
  
  <p>Should I either:</p>
  
  <ol>
  <li>have no return-type hinting in Symfony entities (meh);</li>
  <li>set <code>$username = ''</code> (but hat kind of defeats the purpose of not allowing blanks and I can see all sorts of errors evolving); or</li>
  <li>unmap the field on the symfony form</li>
  <li>other possible solutions...</li>
  </ol>