From d259d4023929f41988d785e6630725f3cfeade58 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 23 May 2024 10:24:49 +0200 Subject: [PATCH] Remove readonly modifier from EntityManager --- src/EntityManager.php | 14 +++++----- tests/Tests/EntityManagerTest.php | 45 +++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 tests/Tests/EntityManagerTest.php 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..d51a685a3fe --- /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()); + } +} \ No newline at end of file