Closed
Description
(I'm sorry if this is wrong place to report that issue, please transfer me to the proper one if this is the case)
We encountered this problem on the Behat testing phase with generated entity proxies. There is fatal error:
Typed property Proxies_CG_\App\Entity\EntityName::$ must not be accessed before initialization (in __sleep)
This happened when we upgraded PHP to 7.4.2 (everything was ok on 7.4.1). We used typed properties before the upgrade as well. After playing with the entity for a bit we discovered that now every typed object property must be initialized immediately (previously they were initialized in the constructor) like:
private ?DateTimeInterface $property = null;
public function __construct()
{
$this->property = new DateTime();
}
because this doesn't work anymore:
private DateTimeInterface $property;
public function __construct()
{
$this->property = new DateTime();
}
This is was already reported in Symfony symfony/symfony#35574 but closed.
Installed Doctrine package | Version |
---|---|
doctrine/annotations | v1.8.0 |
doctrine/cache | 1.10.0 |
doctrine/collections | 1.6.4 |
doctrine/common | 2.12.0 |
doctrine/data-fixtures | 1.4.2 |
doctrine/dbal | v2.10.1 |
doctrine/doctrine-bundle | 2.0.7 |
doctrine/doctrine-migrations-bundle | 2.1.2 |
doctrine/event-manager | 1.1.0 |
doctrine/inflector | 1.3.1 |
doctrine/instantiator | 1.3.0 |
doctrine/lexer | 1.2.0 |
doctrine/migrations | 2.2.1 |
doctrine/mongodb-odm | 2.0.5 |
doctrine/mongodb-odm-bundle | 4.1.0 |
doctrine/orm | v2.7.1 |
doctrine/persistence | 1.3.6 |
doctrine/reflection | v1.1.0 |