title: Why I am suddenly getting a "Typed property must not be accessed before initialization" error when introducing properties type hints?
body: <p>I have updated my class definitions to make use of the newly introduced property type hints, like this:</p>
  
  <pre class="lang-php prettyprint-override"><code>class Foo {
  
      private int $id;
      private ?string $val;
      private DateTimeInterface $createdAt;
      private ?DateTimeInterface $updatedAt;
  
      public function __construct(int $id) {
          $this-&gt;id = $id;
      }
  
  
      public function getId(): int { return $this-&gt;id; }
      public function getVal(): ?string { return $this-&gt;val; }
      public function getCreatedAt(): ?DateTimeInterface { return $this-&gt;createdAt; }
      public function getUpdatedAt(): ?DateTimeInterface { return $this-&gt;updatedAt; }
  
      public function setVal(?string $val) { $this-&gt;val = $val; }
      public function setCreatedAt(DateTimeInterface $date) { $this-&gt;createdAt = $date; }
      public function setUpdatedAt(DateTimeInterface $date) { $this-&gt;updatedAt = $date; }
  }
  </code></pre>
  
  <p>But when trying to save my entity on Doctrine I am getting an error saying:</p>
  
  <blockquote>
    <p>Typed property must not be accessed before initialization </p>
  </blockquote>
  
  <p>This not only happens with <code>$id</code> or <code>$createdAt</code>, but also happen with <code>$value</code> or <code>$updatedAt</code>, which are nullable properties.</p>