diff --git a/src/EntityManager.php b/src/EntityManager.php index bb9e2ad2ced..8045ac2f5e3 100644 --- a/src/EntityManager.php +++ b/src/EntityManager.php @@ -63,27 +63,27 @@ class EntityManager implements EntityManagerInterface /** * The metadata factory, used to retrieve the ORM metadata of entity classes. */ - private readonly ClassMetadataFactory $metadataFactory; + private ClassMetadataFactory $metadataFactory; /** * The UnitOfWork used to coordinate object-level transactions. */ - private readonly UnitOfWork $unitOfWork; + private UnitOfWork $unitOfWork; /** * The event manager that is the central point of the event system. */ - private readonly EventManager $eventManager; + private EventManager $eventManager; /** * The proxy factory used to create dynamic proxies. */ - private readonly ProxyFactory $proxyFactory; + private ProxyFactory $proxyFactory; /** * The repository factory used to create dynamic repositories. */ - private readonly RepositoryFactory $repositoryFactory; + private RepositoryFactory $repositoryFactory; /** * The expression builder instance used to generate query expressions. @@ -112,8 +112,8 @@ class EntityManager implements EntityManagerInterface * @param Connection $conn The database connection used by the EntityManager. */ public function __construct( - private readonly Connection $conn, - private readonly Configuration $config, + private Connection $conn, + private Configuration $config, EventManager|null $eventManager = null, ) { if (! $config->getMetadataDriverImpl()) { diff --git a/tests/Tests/EntityManagerTest.php b/tests/Tests/EntityManagerTest.php new file mode 100644 index 00000000000..96d43795e8e --- /dev/null +++ b/tests/Tests/EntityManagerTest.php @@ -0,0 +1,45 @@ +setValue($em, new class () extends UnitOfWork { + public function __construct() + { + } + + public function clear(): void + { + } + }); + }); + + $this->assertTrue($em->isOpen()); + $em->close(); + $this->assertFalse($em->isOpen()); + + $em->resetLazyObject(); + $this->assertTrue($em->isOpen()); + } +}