-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
Labels
Description
Bug report
I have Doctrine entities with an $id properties that are never initialized in my code. I made PHPStan aware of it with a ReadWritePropertiesExtension and it works perfectly.
But if I add the new readonly keyword on my property, PHPStan give me this error
Class MyEntity has an uninitialized readonly property $id. Assign it in the constructor.
Code snippet that reproduces the problem
#[ORM\Entity]
class MyEntity
{
#[ORM\Column, ORM\Id, ORM\GeneratedValue]
private readonly int $id;
#[ORM\Column]
private string $name;
public function __construct(string $name)
{
$this->name = $name;
}
}Expected output
I expect no error from PHPStan, since the extension tell it that the property is always initialized
eerison and botris