diff --git a/src/Persistence/Mapping/ReflectionService.php b/src/Persistence/Mapping/ReflectionService.php index 3648657a..f839d533 100644 --- a/src/Persistence/Mapping/ReflectionService.php +++ b/src/Persistence/Mapping/ReflectionService.php @@ -49,7 +49,7 @@ public function getClassNamespace(string $class): string; public function getClass(string $class): ReflectionClass; /** - * Returns an accessible property (setAccessible(true)) or null. + * Returns an accessible property or null. * * @phpstan-param class-string $class */ diff --git a/src/Persistence/Mapping/RuntimeReflectionService.php b/src/Persistence/Mapping/RuntimeReflectionService.php index ac840dcf..1b439359 100644 --- a/src/Persistence/Mapping/RuntimeReflectionService.php +++ b/src/Persistence/Mapping/RuntimeReflectionService.php @@ -79,8 +79,6 @@ public function getAccessibleProperty(string $class, string $property): RuntimeR $reflectionProperty = new TypedNoDefaultReflectionProperty($class, $property); } - $reflectionProperty->setAccessible(true); - return $reflectionProperty; } diff --git a/tests/Persistence/Mapping/ClassMetadataFactoryTest.php b/tests/Persistence/Mapping/ClassMetadataFactoryTest.php index 2574eca7..5992bf96 100644 --- a/tests/Persistence/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Persistence/Mapping/ClassMetadataFactoryTest.php @@ -187,7 +187,6 @@ public function testWillNotCacheFallbackMetadata(): void private static function getCache(AbstractClassMetadataFactory $classMetadataFactory): CacheItemPoolInterface|null { $method = new ReflectionMethod($classMetadataFactory, 'getCache'); - $method->setAccessible(true); return $method->invoke($classMetadataFactory); } diff --git a/tests/Persistence/Reflection/TypedNoDefaultReflectionPropertyTest.php b/tests/Persistence/Reflection/TypedNoDefaultReflectionPropertyTest.php index 8b18eb00..3b3f41ee 100644 --- a/tests/Persistence/Reflection/TypedNoDefaultReflectionPropertyTest.php +++ b/tests/Persistence/Reflection/TypedNoDefaultReflectionPropertyTest.php @@ -29,7 +29,6 @@ public function testGetValue(): void public function testSetValueNull(): void { $reflection = new TypedNoDefaultReflectionProperty(TypedFoo::class, 'id'); - $reflection->setAccessible(true); $object = new TypedFoo(); $object->setId(1); @@ -45,7 +44,6 @@ public function testSetValueNull(): void public function testSetValueNullOnNullableProperty(): void { $reflection = new TypedNoDefaultReflectionProperty(TypedNullableFoo::class, 'value'); - $reflection->setAccessible(true); $object = new TypedNullableFoo(); diff --git a/tests/Persistence/RuntimeReflectionPropertyTest.php b/tests/Persistence/RuntimeReflectionPropertyTest.php index 930cace2..c44dd1ff 100644 --- a/tests/Persistence/RuntimeReflectionPropertyTest.php +++ b/tests/Persistence/RuntimeReflectionPropertyTest.php @@ -34,7 +34,6 @@ public function testGetSetValue(string $name, string $value): void self::assertSame($value, $reflProperty->getValue($object)); - $reflProperty->setAccessible(true); $reflProperty->setValue($object, 'changedValue'); self::assertSame('changedValue', $reflProperty->getValue($object));