From 26288e584d65df75c681570f6ab88976a39fdba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 23 Jun 2024 20:35:54 +0200 Subject: [PATCH] Remove StaticReflectionService Additionally, implementations of ReflectionService may no longer return null for calls to getClass(). --- UPGRADE.md | 10 +++ src/Persistence/Mapping/ReflectionService.php | 4 +- .../Mapping/StaticReflectionService.php | 67 ------------------- .../Mapping/StaticReflectionServiceTest.php | 51 -------------- 4 files changed, 12 insertions(+), 120 deletions(-) delete mode 100644 src/Persistence/Mapping/StaticReflectionService.php delete mode 100644 tests/Persistence/Mapping/StaticReflectionServiceTest.php diff --git a/UPGRADE.md b/UPGRADE.md index 8e2430a3..5bf1ef0a 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -8,6 +8,16 @@ awareness about deprecated code. # Upgrade to 4.0 +## BC Break: Removed `StaticReflectionService` + +The class `Doctrine\Persistence\Mapping\StaticReflectionService` is removed +without replacement. + +## BC Break: Narrowed `ReflectionService::getClass()` return type + +The return type of `ReflectionService::getClass()` has been narrowed so that +`null` is no longer a valid return value. + ## BC Break: Added `ObjectManager::isUninitializedObject()` Classes implementing `Doctrine\Persistence\ObjectManager` must implement this diff --git a/src/Persistence/Mapping/ReflectionService.php b/src/Persistence/Mapping/ReflectionService.php index 03c5c875..95572141 100644 --- a/src/Persistence/Mapping/ReflectionService.php +++ b/src/Persistence/Mapping/ReflectionService.php @@ -42,11 +42,11 @@ public function getClassNamespace(string $class): string; * * @psalm-param class-string $class * - * @psalm-return ReflectionClass|null + * @psalm-return ReflectionClass * * @template T of object */ - public function getClass(string $class): ReflectionClass|null; + public function getClass(string $class): ReflectionClass; /** * Returns an accessible property (setAccessible(true)) or null. diff --git a/src/Persistence/Mapping/StaticReflectionService.php b/src/Persistence/Mapping/StaticReflectionService.php deleted file mode 100644 index 979a83e1..00000000 --- a/src/Persistence/Mapping/StaticReflectionService.php +++ /dev/null @@ -1,67 +0,0 @@ -reflectionService = new StaticReflectionService(); - } - - public function testShortname(): void - { - self::assertSame('StaticReflectionServiceTest', $this->reflectionService->getClassShortName(self::class)); - } - - public function testClassNamespaceName(): void - { - self::assertSame('', $this->reflectionService->getClassNamespace(stdClass::class)); - self::assertSame(__NAMESPACE__, $this->reflectionService->getClassNamespace(self::class)); - } - - public function testGetParentClasses(): void - { - $classes = $this->reflectionService->getParentClasses(self::class); - self::assertTrue(count($classes) === 0, 'The test class ' . self::class . ' should have no parents according to static reflection.'); - } - - public function testGetMethods(): void - { - self::assertTrue($this->reflectionService->hasPublicMethod(self::class, 'testGetMethods')); - self::assertTrue($this->reflectionService->hasPublicMethod(self::class, 'testGetMethods2')); - } - - public function testGetAccessibleProperty(): void - { - $reflProp = $this->reflectionService->getAccessibleProperty(self::class, 'reflectionService'); - self::assertNull($reflProp); - } -}