From a9086188a44ff087fc525f37fde06133f8ef70d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 12 Oct 2025 17:08:44 +0200 Subject: [PATCH 1/9] Migrate to new PHPUnit schema --- phpunit.xml.dist | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9374ffb..d15bf62 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,7 +3,6 @@ xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" colors="true" beStrictAboutOutputDuringTests="true" - beStrictAboutTodoAnnotatedTests="true" bootstrap="vendor/autoload.php" > @@ -12,9 +11,9 @@ - + - ./src + ./src/ - + From 92f09c013bd96563c9f4fa7bb6055658a73bae3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 12 Oct 2025 17:09:06 +0200 Subject: [PATCH 2/9] Configure PHPUnit to display D for deprecations --- phpunit.xml.dist | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d15bf62..b58ed43 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -11,7 +11,11 @@ - + + + + + ./src/ From 22cfffb0c4c7d81754309e60f2ebbd8fdcc5bc4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 12 Oct 2025 17:13:08 +0200 Subject: [PATCH 3/9] Allow PHPUnit 12 It will make it easier to address deprecations because it comes with an argument for --stop-on-deprecations that allows to show the stack trace. --- composer.json | 2 +- phpunit.xml.dist | 1 - .../Executor/ORMExecutorSharedFixtureTest.php | 3 +++ .../Executor/PHPCRExecutorTest.php | 23 ++++++++----------- .../ProxyReferenceRepositoryTest.php | 7 +++++- .../DataFixtures/ReferenceRepositoryTest.php | 3 ++- .../Sorter/TopologicalSorterTest.php | 4 ++-- .../Common/DataFixtures/Sorter/VertexTest.php | 3 ++- 8 files changed, 26 insertions(+), 20 deletions(-) diff --git a/composer.json b/composer.json index 1116994..bdda291 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "doctrine/orm": "^2.14 || ^3", "fig/log-test": "^1", "phpstan/phpstan": "2.1.30", - "phpunit/phpunit": "^9.6.13 || 10.5.45", + "phpunit/phpunit": "^9.6.13 || ^12.4", "psr/log": "^1.1 || ^2 || ^3", "symfony/cache": "^5.4 || ^6.3 || ^7", "symfony/var-exporter": "^5.4 || ^6.3 || ^7" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b58ed43..ba1cf67 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,7 +3,6 @@ xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" colors="true" beStrictAboutOutputDuringTests="true" - bootstrap="vendor/autoload.php" > diff --git a/tests/Common/DataFixtures/Executor/ORMExecutorSharedFixtureTest.php b/tests/Common/DataFixtures/Executor/ORMExecutorSharedFixtureTest.php index 1553e05..4cc32ac 100644 --- a/tests/Common/DataFixtures/Executor/ORMExecutorSharedFixtureTest.php +++ b/tests/Common/DataFixtures/Executor/ORMExecutorSharedFixtureTest.php @@ -10,6 +10,7 @@ use Doctrine\Common\DataFixtures\SharedFixtureInterface; use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Tests\Common\DataFixtures\TestEntity\Role; use Doctrine\Tests\Common\DataFixtures\TestEntity\User; +use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\MockObject\MockObject; /** @@ -20,6 +21,7 @@ class ORMExecutorSharedFixtureTest extends BaseTestCase public const TEST_ENTITY_ROLE = Role::class; public const TEST_ENTITY_USER = User::class; + #[IgnoreDeprecations] public function testFixtureExecution(): void { $em = $this->getMockSqliteEntityManager(); @@ -39,6 +41,7 @@ class ORMExecutorSharedFixtureTest extends BaseTestCase $executor->execute([$fixture], true); } + #[IgnoreDeprecations] public function testSharedFixtures(): void { $em = $this->getMockSqliteEntityManager(); diff --git a/tests/Common/DataFixtures/Executor/PHPCRExecutorTest.php b/tests/Common/DataFixtures/Executor/PHPCRExecutorTest.php index 2f1642b..c65e641 100644 --- a/tests/Common/DataFixtures/Executor/PHPCRExecutorTest.php +++ b/tests/Common/DataFixtures/Executor/PHPCRExecutorTest.php @@ -11,16 +11,13 @@ use Doctrine\ODM\PHPCR\DocumentManager; use Doctrine\Tests\Common\DataFixtures\BaseTestCase; use Doctrine\Tests\Mock\PHPCRDocumentManager; use Exception; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\MockObject\MockObject; use Throwable; use function class_exists; -/** - * Tests for {@see \Doctrine\Common\DataFixtures\Executor\PHPCRExecutor} - * - * @covers \Doctrine\Common\DataFixtures\Executor\PHPCRExecutor - */ +#[CoversClass(PHPCRExecutor::class)] class PHPCRExecutorTest extends BaseTestCase { public function testExecuteSingleFixtureWithNoPurge(): void @@ -34,9 +31,9 @@ class PHPCRExecutorTest extends BaseTestCase ->expects($this->once()) ->method('transactional') ->with($this->isType('callable')) - ->will($this->returnCallback(static function ($callback) use ($dm) { + ->willReturnCallback(static function ($callback) use ($dm) { return $callback($dm); - })); + }); $executor->execute([$fixture], true); } @@ -54,9 +51,9 @@ class PHPCRExecutorTest extends BaseTestCase ->expects($this->once()) ->method('transactional') ->with($this->isType('callable')) - ->will($this->returnCallback(static function ($callback) use ($dm) { + ->willReturnCallback(static function ($callback) use ($dm) { return $callback($dm); - })); + }); $executor->execute([$fixture1, $fixture2], true); } @@ -73,9 +70,9 @@ class PHPCRExecutorTest extends BaseTestCase ->expects($this->once()) ->method('transactional') ->with($this->isType('callable')) - ->will($this->returnCallback(static function ($callback) use ($dm) { + ->willReturnCallback(static function ($callback) use ($dm) { return $callback($dm); - })); + }); $purger->expects($this->once())->method('purge'); $executor->execute([$fixture], false); @@ -93,9 +90,9 @@ class PHPCRExecutorTest extends BaseTestCase ->expects($this->once()) ->method('transactional') ->with($this->isType('callable')) - ->will($this->returnCallback(static function ($callback) use ($dm) { + ->willReturnCallback(static function ($callback) use ($dm) { return $callback($dm); - })); + }); $purger->expects($this->never())->method('purge'); $executor->execute([$fixture], true); diff --git a/tests/Common/DataFixtures/ProxyReferenceRepositoryTest.php b/tests/Common/DataFixtures/ProxyReferenceRepositoryTest.php index a4ae20b..5c33d3a 100644 --- a/tests/Common/DataFixtures/ProxyReferenceRepositoryTest.php +++ b/tests/Common/DataFixtures/ProxyReferenceRepositoryTest.php @@ -13,6 +13,7 @@ use Doctrine\Tests\Common\DataFixtures\TestEntity\Link; use Doctrine\Tests\Common\DataFixtures\TestEntity\Role; use Doctrine\Tests\Common\DataFixtures\TestTypes\UuidType; use Doctrine\Tests\Common\DataFixtures\TestValueObjects\Uuid; +use PHPUnit\Framework\Attributes\IgnoreDeprecations; /** * Test ProxyReferenceRepository. @@ -33,12 +34,15 @@ class ProxyReferenceRepositoryTest extends BaseTestCase Type::addType('uuid', UuidType::class); } + #[IgnoreDeprecations] public function testReferenceEntry(): void { $em = $this->getMockSqliteEntityManager(); $role = new TestEntity\Role(); $role->setName('admin'); $meta = $em->getClassMetadata(self::TEST_ENTITY_ROLE); + + // getPropertyAccessor() is not available with ORM < 3.4 $meta->getReflectionProperty('id')->setValue($role, 1); $referenceRepo = new ProxyReferenceRepository($em); @@ -91,7 +95,7 @@ class ProxyReferenceRepositoryTest extends BaseTestCase $referenceRepository->expects($this->once()) ->method('getReferenceNames') - ->will($this->returnValue(['admin-role'])); + ->willReturn(['admin-role']); $referenceRepository->expects($this->once()) ->method('setReferenceIdentity') @@ -150,6 +154,7 @@ class ProxyReferenceRepositoryTest extends BaseTestCase $this->assertInstanceOf(Proxy::class, $ref); } + #[IgnoreDeprecations] public function testReconstructionOfCustomTypedId(): void { $em = $this->getMockSqliteEntityManager(); diff --git a/tests/Common/DataFixtures/ReferenceRepositoryTest.php b/tests/Common/DataFixtures/ReferenceRepositoryTest.php index 1843ce6..cc45293 100644 --- a/tests/Common/DataFixtures/ReferenceRepositoryTest.php +++ b/tests/Common/DataFixtures/ReferenceRepositoryTest.php @@ -14,6 +14,7 @@ use Doctrine\Persistence\Proxy; use Doctrine\Tests\Common\DataFixtures\TestEntity\Role; use Doctrine\Tests\Mock\ForwardCompatibleEntityManager; use OutOfBoundsException; +use PHPUnit\Framework\Attributes\IgnoreDeprecations; use function sprintf; @@ -152,7 +153,7 @@ class ReferenceRepositoryTest extends BaseTestCase $referenceRepository->getReference('foo', Role::class); } - /** @group legacy */ + #[IgnoreDeprecations] public function testLegacyUndefinedReference(): void { $referenceRepository = new ReferenceRepository($this->getMockSqliteEntityManager()); diff --git a/tests/Common/DataFixtures/Sorter/TopologicalSorterTest.php b/tests/Common/DataFixtures/Sorter/TopologicalSorterTest.php index 1a1f8c2..9e73acc 100644 --- a/tests/Common/DataFixtures/Sorter/TopologicalSorterTest.php +++ b/tests/Common/DataFixtures/Sorter/TopologicalSorterTest.php @@ -8,6 +8,7 @@ use Doctrine\Common\DataFixtures\Exception\CircularReferenceException; use Doctrine\Common\DataFixtures\Sorter\TopologicalSorter; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Tests\Common\DataFixtures\BaseTestCase; +use PHPUnit\Framework\Attributes\CoversClass; use RuntimeException; /** @@ -16,9 +17,8 @@ use RuntimeException; * Note: When writing tests here consider that a lot of graph * constellations can have many valid orderings, so you may want to * build a graph that has only 1 valid order to simplify your tests - * - * @covers \Doctrine\Common\DataFixtures\Sorter\TopologicalSorter */ +#[CoversClass(TopologicalSorter::class)] class TopologicalSorterTest extends BaseTestCase { public function testSuccessSortLinearDependency(): void diff --git a/tests/Common/DataFixtures/Sorter/VertexTest.php b/tests/Common/DataFixtures/Sorter/VertexTest.php index 1f85652..82f8c21 100644 --- a/tests/Common/DataFixtures/Sorter/VertexTest.php +++ b/tests/Common/DataFixtures/Sorter/VertexTest.php @@ -7,8 +7,9 @@ namespace Doctrine\Test\DataFixtures\Sorter; use Doctrine\Common\DataFixtures\Sorter\Vertex; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Tests\Common\DataFixtures\BaseTestCase; +use PHPUnit\Framework\Attributes\CoversClass; -/** @covers \Doctrine\Common\DataFixtures\Sorter\Vertex */ +#[CoversClass(Vertex::class)] class VertexTest extends BaseTestCase { public function testNode(): void From 425ccd28a0200f47a8281d3295bea2e36160449a Mon Sep 17 00:00:00 2001 From: Artem Lopata Date: Thu, 11 Sep 2025 09:55:25 +0200 Subject: [PATCH 4/9] Remove usage of deprecated method. \Doctrine\DBAL\Schema\AbstractAsset::getQuotedName Is deprecated from doctrine/dbal 4.3.0. --- src/Purger/ORMPurger.php | 10 +++++++++- tests/Common/DataFixtures/Purger/ORMPurgerTest.php | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Purger/ORMPurger.php b/src/Purger/ORMPurger.php index f9fbdb5..b0948ee 100644 --- a/src/Purger/ORMPurger.php +++ b/src/Purger/ORMPurger.php @@ -6,6 +6,7 @@ namespace Doctrine\Common\DataFixtures\Purger; use Doctrine\Common\DataFixtures\Sorter\TopologicalSorter; use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Schema\AbstractNamedObject; use Doctrine\DBAL\Schema\Identifier; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; @@ -13,6 +14,7 @@ use Doctrine\ORM\Mapping\ManyToManyOwningSideMapping; use function array_map; use function array_reverse; +use function class_exists; use function count; use function in_array; @@ -268,6 +270,12 @@ class ORMPurger implements PurgerInterface, ORMPurgerInterface { $tableIdentifier = new Identifier($tableName); - return 'DELETE FROM ' . $tableIdentifier->getQuotedName($platform); + if (class_exists(AbstractNamedObject::class)) { + $identifier = $tableIdentifier->getObjectName()->toSQL($platform); + } else { + $identifier = $tableIdentifier->getQuotedName($platform); + } + + return 'DELETE FROM ' . $identifier; } } diff --git a/tests/Common/DataFixtures/Purger/ORMPurgerTest.php b/tests/Common/DataFixtures/Purger/ORMPurgerTest.php index 442948f..8334710 100644 --- a/tests/Common/DataFixtures/Purger/ORMPurgerTest.php +++ b/tests/Common/DataFixtures/Purger/ORMPurgerTest.php @@ -5,8 +5,11 @@ declare(strict_types=1); namespace Doctrine\Tests\Common\DataFixtures; use Doctrine\Common\DataFixtures\Purger\ORMPurger; +use Doctrine\DBAL\Schema\AbstractNamedObject; use ReflectionClass; +use function class_exists; + /** * Doctrine\Tests\Common\DataFixtures\ORMPurgerTest */ @@ -86,6 +89,11 @@ class ORMPurgerTest extends BaseTestCase $method = $class->getMethod('getDeleteFromTableSQL'); $method->setAccessible(true); $sql = $method->invokeArgs($purger, [$tableName, $platform]); - $this->assertEquals('DELETE FROM test_schema."group"', $sql); + + if (class_exists(AbstractNamedObject::class)) { + $this->assertEquals('DELETE FROM "test_schema"."group"', $sql); + } else { + $this->assertEquals('DELETE FROM test_schema."group"', $sql); + } } } From d6537fbc4f40fd17a7c5a2a83723e20d1a30b5f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 12 Oct 2025 17:25:58 +0200 Subject: [PATCH 5/9] Migrate from @group legacy to #[IgnoreDeprecations] @group legacy is intended for symfony/phpunit-bridge, which we don't use here. --- .../DataFixtures/Executor/ORMExecutorSharedFixtureTest.php | 2 +- tests/Common/DataFixtures/ProxyReferenceRepositoryTest.php | 2 +- tests/Common/DataFixtures/ReferenceRepositoryTest.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Common/DataFixtures/Executor/ORMExecutorSharedFixtureTest.php b/tests/Common/DataFixtures/Executor/ORMExecutorSharedFixtureTest.php index 4cc32ac..b94c4c2 100644 --- a/tests/Common/DataFixtures/Executor/ORMExecutorSharedFixtureTest.php +++ b/tests/Common/DataFixtures/Executor/ORMExecutorSharedFixtureTest.php @@ -72,7 +72,7 @@ class ORMExecutorSharedFixtureTest extends BaseTestCase $this->assertEquals('admin@example.com', $userReference->getEmail()); } - /** @group legacy */ + #[IgnoreDeprecations] public function testLegacySharedFixtures(): void { $em = $this->getMockSqliteEntityManager(); diff --git a/tests/Common/DataFixtures/ProxyReferenceRepositoryTest.php b/tests/Common/DataFixtures/ProxyReferenceRepositoryTest.php index 5c33d3a..b731035 100644 --- a/tests/Common/DataFixtures/ProxyReferenceRepositoryTest.php +++ b/tests/Common/DataFixtures/ProxyReferenceRepositoryTest.php @@ -57,7 +57,7 @@ class ProxyReferenceRepositoryTest extends BaseTestCase $this->assertInstanceOf(self::TEST_ENTITY_ROLE, $referencesByClass[Role::class]['test']); } - /** @group legacy */ + #[IgnoreDeprecations] public function testLegacyReferenceEntry(): void { $em = $this->getMockSqliteEntityManager(); diff --git a/tests/Common/DataFixtures/ReferenceRepositoryTest.php b/tests/Common/DataFixtures/ReferenceRepositoryTest.php index cc45293..781edb3 100644 --- a/tests/Common/DataFixtures/ReferenceRepositoryTest.php +++ b/tests/Common/DataFixtures/ReferenceRepositoryTest.php @@ -43,7 +43,7 @@ class ReferenceRepositoryTest extends BaseTestCase $this->assertInstanceOf(Role::class, $referencesByClass[Role::class]['test']); } - /** @group legacy */ + #[IgnoreDeprecations] public function testLegacyReferenceEntry(): void { $em = $this->getMockSqliteEntityManager(); @@ -200,7 +200,7 @@ class ReferenceRepositoryTest extends BaseTestCase $this->assertEquals(['entity' => 1], $referenceRepository->getIdentitiesByClass()[Role::class] ?? []); } - /** @group legacy */ + #[IgnoreDeprecations] public function testLegacyHasIdentityCheck(): void { $role = new Role(); From b87f46448635607dc48028c0bce94e200481e541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 12 Oct 2025 17:28:24 +0200 Subject: [PATCH 6/9] Add missing #[IgnoreDeprecations] attribute --- tests/Common/DataFixtures/Executor/AbstractExecutorTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Common/DataFixtures/Executor/AbstractExecutorTest.php b/tests/Common/DataFixtures/Executor/AbstractExecutorTest.php index 1160ede..d389ebc 100644 --- a/tests/Common/DataFixtures/Executor/AbstractExecutorTest.php +++ b/tests/Common/DataFixtures/Executor/AbstractExecutorTest.php @@ -10,6 +10,7 @@ use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\Purger\PurgerInterface; use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\Persistence\ObjectManager; +use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\TestCase; use Psr\Log\Test\TestLogger; @@ -48,6 +49,7 @@ final class AbstractExecutorTest extends TestCase self::assertTrue($logger->hasDebugThatContains('purging database')); } + #[IgnoreDeprecations] public function testDeprecatedLoggerUsage(): void { $executor = $this->bootstrapExecutor(); From b60845a3ff2a1c6d4ce2c67e8e90dcb8e4a7aebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 12 Oct 2025 17:36:30 +0200 Subject: [PATCH 7/9] Address deprecation about createAttributeMetadataConfiguration I spotted this deprecation in https://github.com/doctrine/data-fixtures/pull/573, and I do not understand why it does not surface earlier. --- phpstan-baseline.neon | 18 ++++++++ phpstan.neon.dist | 2 +- tests/Common/DataFixtures/BaseTestCase.php | 5 ++- .../ProxyReferenceRepositoryTest.php | 42 ++++++++++++++++--- .../DataFixtures/ReferenceRepositoryTest.php | 38 +++++++++++++++-- 5 files changed, 93 insertions(+), 12 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 682fa95..a62cdd0 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -306,6 +306,12 @@ parameters: count: 1 path: src/Sorter/Vertex.php + - + message: '#^Call to function method_exists\(\) with ''Doctrine\\\\ORM\\\\ORMSetup'' and ''createAttributeMeta…'' will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: tests/Common/DataFixtures/BaseTestCase.php + - message: '#^Method Doctrine\\Tests\\Common\\DataFixtures\\FixtureWithUnexistentDependency\:\:getDependencies\(\) should return array\\> but returns array\\.$#' identifier: return.type @@ -318,6 +324,12 @@ parameters: count: 5 path: tests/Common/DataFixtures/Executor/PHPCRExecutorTest.php + - + message: '#^Call to function method_exists\(\) with ''Doctrine\\\\ORM\\\\ORMSetup'' and ''createAttributeMeta…'' will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 2 + path: tests/Common/DataFixtures/ProxyReferenceRepositoryTest.php + - message: '#^Call to an undefined method Doctrine\\ODM\\MongoDB\\DocumentManager\:\:getConnection\(\)\.$#' identifier: method.notFound @@ -330,6 +342,12 @@ parameters: count: 1 path: tests/Common/DataFixtures/Purger/MongoDBPurgerTest.php + - + message: '#^Call to function method_exists\(\) with ''Doctrine\\\\ORM\\\\ORMSetup'' and ''createAttributeMeta…'' will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 2 + path: tests/Common/DataFixtures/ReferenceRepositoryTest.php + - message: '#^Parameter \#1 \$name of class Doctrine\\ORM\\Mapping\\ClassMetadata constructor expects class\-string\<1\>, string given\.$#' identifier: argument.type diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 6eb2611..0a7ab0a 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,5 +1,5 @@ parameters: - phpVersion: 80200 + phpVersion: 80400 level: 7 paths: - src diff --git a/tests/Common/DataFixtures/BaseTestCase.php b/tests/Common/DataFixtures/BaseTestCase.php index d9a8869..8565a02 100644 --- a/tests/Common/DataFixtures/BaseTestCase.php +++ b/tests/Common/DataFixtures/BaseTestCase.php @@ -26,7 +26,10 @@ abstract class BaseTestCase extends TestCase protected function getMockSqliteEntityManager(string $fixtureSet = 'TestEntity'): EntityManager { $dbParams = ['driver' => 'sqlite3', 'memory' => true]; - if (PHP_VERSION_ID >= 80100) { + if (PHP_VERSION_ID >= 80400 && method_exists(ORMSetup::class, 'createAttributeMetadataConfig')) { + $config = ORMSetup::createAttributeMetadataConfig([__DIR__ . '/' . $fixtureSet], true); + $config->enableNativeLazyObjects(true); + } elseif (PHP_VERSION_ID >= 80100) { $config = ORMSetup::createAttributeMetadataConfiguration([__DIR__ . '/' . $fixtureSet], true); $config->setLazyGhostObjectEnabled(true); } else { diff --git a/tests/Common/DataFixtures/ProxyReferenceRepositoryTest.php b/tests/Common/DataFixtures/ProxyReferenceRepositoryTest.php index b731035..3e16de9 100644 --- a/tests/Common/DataFixtures/ProxyReferenceRepositoryTest.php +++ b/tests/Common/DataFixtures/ProxyReferenceRepositoryTest.php @@ -7,6 +7,7 @@ namespace Doctrine\Tests\Common\DataFixtures; use Doctrine\Common\DataFixtures\Event\Listener\ORMReferenceListener; use Doctrine\Common\DataFixtures\ProxyReferenceRepository; use Doctrine\DBAL\Types\Type; +use Doctrine\ORM\ORMSetup; use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Persistence\Proxy; use Doctrine\Tests\Common\DataFixtures\TestEntity\Link; @@ -14,6 +15,11 @@ use Doctrine\Tests\Common\DataFixtures\TestEntity\Role; use Doctrine\Tests\Common\DataFixtures\TestTypes\UuidType; use Doctrine\Tests\Common\DataFixtures\TestValueObjects\Uuid; use PHPUnit\Framework\Attributes\IgnoreDeprecations; +use ReflectionClass; + +use function method_exists; + +use const PHP_VERSION_ID; /** * Test ProxyReferenceRepository. @@ -123,7 +129,7 @@ class ProxyReferenceRepositoryTest extends BaseTestCase // first test against managed state $ref = $referenceRepository->getReference('admin-role', Role::class); - $this->assertNotInstanceOf(Proxy::class, $ref); + $this->assertNotProxy($ref); // test reference reconstruction from serialized data (was managed) $serializedData = $referenceRepository->serialize(); @@ -134,14 +140,14 @@ class ProxyReferenceRepositoryTest extends BaseTestCase $ref = $proxyReferenceRepository->getReference('admin-role', Role::class); // before clearing, the reference is not yet a proxy - $this->assertNotInstanceOf(Proxy::class, $ref); + $this->assertNotProxy($ref); $this->assertInstanceOf(self::TEST_ENTITY_ROLE, $ref); // now test reference reconstruction from identity $em->clear(); $ref = $referenceRepository->getReference('admin-role', Role::class); - $this->assertInstanceOf(Proxy::class, $ref); + $this->assertProxy($ref); // test reference reconstruction from serialized data (was identity) $serializedData = $referenceRepository->serialize(); @@ -151,7 +157,7 @@ class ProxyReferenceRepositoryTest extends BaseTestCase $ref = $proxyReferenceRepository->getReference('admin-role', Role::class); - $this->assertInstanceOf(Proxy::class, $ref); + $this->assertProxy($ref); } #[IgnoreDeprecations] @@ -201,7 +207,31 @@ class ProxyReferenceRepositoryTest extends BaseTestCase $em->flush(); $em->clear(); - $this->assertInstanceOf(Proxy::class, $referenceRepository->getReference('admin', Role::class)); - $this->assertInstanceOf(Proxy::class, $referenceRepository->getReference('duplicate', Role::class)); + $this->assertProxy($referenceRepository->getReference('admin', Role::class)); + $this->assertProxy($referenceRepository->getReference('duplicate', Role::class)); + } + + private function assertProxy(object $object): void + { + if (PHP_VERSION_ID < 80400 || ! method_exists(ORMSetup::class, 'createAttributeMetadataConfig')) { + $this->assertInstanceOf(Proxy::class, $object); + + return; + } + + $reflector = new ReflectionClass($object); + $this->assertTrue($reflector->isUninitializedLazyObject($object)); + } + + private function assertNotProxy(object $object): void + { + if (PHP_VERSION_ID < 80400 || ! method_exists(ORMSetup::class, 'createAttributeMetadataConfig')) { + $this->assertNotInstanceOf(Proxy::class, $object); + + return; + } + + $reflector = new ReflectionClass($object); + $this->assertFalse($reflector->isUninitializedLazyObject($object)); } } diff --git a/tests/Common/DataFixtures/ReferenceRepositoryTest.php b/tests/Common/DataFixtures/ReferenceRepositoryTest.php index 781edb3..3c89771 100644 --- a/tests/Common/DataFixtures/ReferenceRepositoryTest.php +++ b/tests/Common/DataFixtures/ReferenceRepositoryTest.php @@ -8,6 +8,7 @@ use BadMethodCallException; use Doctrine\Common\DataFixtures\Event\Listener\ORMReferenceListener; use Doctrine\Common\DataFixtures\ReferenceRepository; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\ORMSetup; use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\UnitOfWork; use Doctrine\Persistence\Proxy; @@ -15,11 +16,16 @@ use Doctrine\Tests\Common\DataFixtures\TestEntity\Role; use Doctrine\Tests\Mock\ForwardCompatibleEntityManager; use OutOfBoundsException; use PHPUnit\Framework\Attributes\IgnoreDeprecations; +use ReflectionClass; +use function method_exists; use function sprintf; +use const PHP_VERSION_ID; + class ReferenceRepositoryTest extends BaseTestCase { + #[IgnoreDeprecations] public function testReferenceEntry(): void { $em = $this->getMockSqliteEntityManager(); @@ -113,13 +119,13 @@ class ReferenceRepositoryTest extends BaseTestCase // first test against managed state $ref = $referenceRepository->getReference('admin-role', Role::class); - $this->assertNotInstanceOf(Proxy::class, $ref); + $this->assertNotProxy($ref); // now test reference reconstruction from identity $em->clear(); $ref = $referenceRepository->getReference('admin-role', Role::class); - $this->assertInstanceOf(Proxy::class, $ref); + $this->assertProxy($ref); } public function testReferenceMultipleEntries(): void @@ -139,8 +145,8 @@ class ReferenceRepositoryTest extends BaseTestCase $em->flush(); $em->clear(); - $this->assertInstanceOf(Proxy::class, $referenceRepository->getReference('admin', Role::class)); - $this->assertInstanceOf(Proxy::class, $referenceRepository->getReference('duplicate', Role::class)); + $this->assertProxy($referenceRepository->getReference('admin', Role::class)); + $this->assertProxy($referenceRepository->getReference('duplicate', Role::class)); } public function testUndefinedReference(): void @@ -290,4 +296,28 @@ class ReferenceRepositoryTest extends BaseTestCase $this->assertCount(1, $names); $this->assertSame('1', $names[0]); } + + private function assertProxy(object $object): void + { + if (PHP_VERSION_ID < 80400 || ! method_exists(ORMSetup::class, 'createAttributeMetadataConfig')) { + $this->assertInstanceOf(Proxy::class, $object); + + return; + } + + $reflector = new ReflectionClass($object); + $this->assertTrue($reflector->isUninitializedLazyObject($object)); + } + + private function assertNotProxy(object $object): void + { + if (PHP_VERSION_ID < 80400 || ! method_exists(ORMSetup::class, 'createAttributeMetadataConfig')) { + $this->assertNotInstanceOf(Proxy::class, $object); + + return; + } + + $reflector = new ReflectionClass($object); + $this->assertFalse($reflector->isUninitializedLazyObject($object)); + } } From 90b61641b22edf953688f5d18922bf4c79a1c093 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Oct 2025 07:31:49 +0000 Subject: [PATCH 8/9] Bump doctrine/.github from 8.0.0 to 10.1.0 Bumps [doctrine/.github](https://github.com/doctrine/.github) from 8.0.0 to 10.1.0. - [Release notes](https://github.com/doctrine/.github/releases) - [Commits](https://github.com/doctrine/.github/compare/8.0.0...10.1.0) --- updated-dependencies: - dependency-name: doctrine/.github dependency-version: 10.1.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/coding-standards.yml | 2 +- .github/workflows/documentation.yml | 2 +- .github/workflows/release-on-milestone-closed.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 0b44242..265d106 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -11,4 +11,4 @@ on: jobs: coding-standards: name: "Coding Standards" - uses: "doctrine/.github/.github/workflows/coding-standards.yml@8.0.0" + uses: "doctrine/.github/.github/workflows/coding-standards.yml@10.1.0" diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 0e9a2ab..9734c20 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -17,4 +17,4 @@ on: jobs: documentation: name: "Documentation" - uses: "doctrine/.github/.github/workflows/documentation.yml@8.0.0" + uses: "doctrine/.github/.github/workflows/documentation.yml@10.1.0" diff --git a/.github/workflows/release-on-milestone-closed.yml b/.github/workflows/release-on-milestone-closed.yml index 29770e2..f660801 100644 --- a/.github/workflows/release-on-milestone-closed.yml +++ b/.github/workflows/release-on-milestone-closed.yml @@ -8,7 +8,7 @@ on: jobs: release: name: "Git tag, release & create merge-up PR" - uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@8.0.0" + uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@10.1.0" secrets: GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }} GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 7914fdc..bf93f48 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -11,4 +11,4 @@ on: jobs: static-analysis: name: "Static Analysis" - uses: "doctrine/.github/.github/workflows/phpstan.yml@8.0.0" + uses: "doctrine/.github/.github/workflows/phpstan.yml@10.1.0" From 7cb69cd2724b55aaea0a970507beee6b8f99e047 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Oct 2025 12:04:46 +0000 Subject: [PATCH 9/9] Update phpstan/phpstan requirement from 2.1.30 to 2.1.31 --- updated-dependencies: - dependency-name: phpstan/phpstan dependency-version: 2.1.31 dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bdda291..6546b0c 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "doctrine/mongodb-odm": "^1.3.0 || ^2.0.0", "doctrine/orm": "^2.14 || ^3", "fig/log-test": "^1", - "phpstan/phpstan": "2.1.30", + "phpstan/phpstan": "2.1.31", "phpunit/phpunit": "^9.6.13 || ^12.4", "psr/log": "^1.1 || ^2 || ^3", "symfony/cache": "^5.4 || ^6.3 || ^7",