Skip to content

Commit

Permalink
Remove readonly modifier from EntityManager
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed May 23, 2024
1 parent dbfe47b commit d259d40
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/EntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()) {
Expand Down
45 changes: 45 additions & 0 deletions tests/Tests/EntityManagerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

namespace Doctrine\Tests;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\UnitOfWork;
use PHPUnit\Framework\TestCase;
use ReflectionProperty;
use Symfony\Component\VarExporter\LazyGhostTrait;

class EntityManagerTest extends TestCase
{
public function testLazyGhostEntityManager(): void
{
$em = new class() extends EntityManager {

Check failure on line 17 in tests/Tests/EntityManagerTest.php

View workflow job for this annotation

GitHub Actions / coding-standards / Coding Standards (8.3)

Expected 1 space after class keyword; 0 found
use LazyGhostTrait;

public function __construct()
{
}
};

$em = $em::createLazyGhost(static function ($em) {

Check failure on line 25 in tests/Tests/EntityManagerTest.php

View workflow job for this annotation

GitHub Actions / coding-standards / Coding Standards (8.3)

Closure does not have void return type hint.
$r = new ReflectionProperty(EntityManager::class, 'unitOfWork');
$r->setValue($em, new class() extends UnitOfWork {

Check failure on line 27 in tests/Tests/EntityManagerTest.php

View workflow job for this annotation

GitHub Actions / coding-standards / Coding Standards (8.3)

Expected 1 space after class keyword; 0 found
public function __construct()
{
}

public function clear(): void
{
}
});
});

$this->assertTrue($em->isOpen());
$em->close();
$this->assertFalse($em->isOpen());

$em->resetLazyObject();
$this->assertTrue($em->isOpen());
}
}

Check failure on line 45 in tests/Tests/EntityManagerTest.php

View workflow job for this annotation

GitHub Actions / coding-standards / Coding Standards (8.3)

Expected 1 newline at end of file; 0 found

0 comments on commit d259d40

Please sign in to comment.