Skip to content

Commit 275afd6

Browse files
authored
Merge pull request #427 from W0rma/reflection-set-accessible
Remove Reflection*::setAccessible() calls
2 parents 4975d43 + d600ba1 commit 275afd6

File tree

5 files changed

+1
-7
lines changed

5 files changed

+1
-7
lines changed

src/Persistence/Mapping/ReflectionService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function getClassNamespace(string $class): string;
4949
public function getClass(string $class): ReflectionClass;
5050

5151
/**
52-
* Returns an accessible property (setAccessible(true)) or null.
52+
* Returns an accessible property or null.
5353
*
5454
* @phpstan-param class-string $class
5555
*/

src/Persistence/Mapping/RuntimeReflectionService.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ public function getAccessibleProperty(string $class, string $property): RuntimeR
7979
$reflectionProperty = new TypedNoDefaultReflectionProperty($class, $property);
8080
}
8181

82-
$reflectionProperty->setAccessible(true);
83-
8482
return $reflectionProperty;
8583
}
8684

tests/Persistence/Mapping/ClassMetadataFactoryTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ public function testWillNotCacheFallbackMetadata(): void
187187
private static function getCache(AbstractClassMetadataFactory $classMetadataFactory): CacheItemPoolInterface|null
188188
{
189189
$method = new ReflectionMethod($classMetadataFactory, 'getCache');
190-
$method->setAccessible(true);
191190

192191
return $method->invoke($classMetadataFactory);
193192
}

tests/Persistence/Reflection/TypedNoDefaultReflectionPropertyTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public function testGetValue(): void
2929
public function testSetValueNull(): void
3030
{
3131
$reflection = new TypedNoDefaultReflectionProperty(TypedFoo::class, 'id');
32-
$reflection->setAccessible(true);
3332

3433
$object = new TypedFoo();
3534
$object->setId(1);
@@ -45,7 +44,6 @@ public function testSetValueNull(): void
4544
public function testSetValueNullOnNullableProperty(): void
4645
{
4746
$reflection = new TypedNoDefaultReflectionProperty(TypedNullableFoo::class, 'value');
48-
$reflection->setAccessible(true);
4947

5048
$object = new TypedNullableFoo();
5149

tests/Persistence/RuntimeReflectionPropertyTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public function testGetSetValue(string $name, string $value): void
3434

3535
self::assertSame($value, $reflProperty->getValue($object));
3636

37-
$reflProperty->setAccessible(true);
3837
$reflProperty->setValue($object, 'changedValue');
3938

4039
self::assertSame('changedValue', $reflProperty->getValue($object));

0 commit comments

Comments
 (0)