-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
phpstan/phpstan-doctrine
#339Labels
Description
Bug report
Class App\Entity\User has an uninitialized readonly property $id. Assign it in the constructor.
Code snippet that reproduces the problem
I use Symfony 6.1.0 and PHP 8.1.6.My user entity has this code:
...
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private readonly int $id;
...
I install phpstan/phpstan and phpstan/phpstan-doctrine and phpstan/phpstan-symfony packages.
When analyze with PHPStan ( php vendor/bin/phpstan analyse src ), display this error:
------ -------------------------------------------------------------------------------------------------
Line Entity\User.php
------ -------------------------------------------------------------------------------------------------
17 Class App\Entity\User has an uninitialized readonly property $id. Assign it in the constructor.
------ -------------------------------------------------------------------------------------------------
Line 17 is : private readonly int $id;
Expected output
private readonly int $id; is correct and should not display an error.