diff --git a/src/Validator/Mapping/ObjectMetadata.php b/src/Validator/Mapping/ObjectMetadata.php index de2aa49f5..b64784f0a 100644 --- a/src/Validator/Mapping/ObjectMetadata.php +++ b/src/Validator/Mapping/ObjectMetadata.php @@ -21,7 +21,6 @@ public function addPropertyConstraint(string $property, Constraint $constraint): { // Use reflection to access private properties $propertiesReflection = new ReflectionProperty(ClassMetadata::class, 'properties'); - $propertiesReflection->setAccessible(true); $properties = $propertiesReflection->getValue($this); if (!isset($properties[$property])) { @@ -32,7 +31,6 @@ public function addPropertyConstraint(string $property, Constraint $constraint): // Use reflection to call private addPropertyMetadata method $addPropertyMetadataReflection = new ReflectionMethod(ClassMetadata::class, 'addPropertyMetadata'); - $addPropertyMetadataReflection->setAccessible(true); $addPropertyMetadataReflection->invoke($this, $propertyMetadata); // Refresh properties array after addPropertyMetadata call diff --git a/src/Validator/Mapping/PropertyMetadata.php b/src/Validator/Mapping/PropertyMetadata.php index ff321711a..f2b6d6808 100644 --- a/src/Validator/Mapping/PropertyMetadata.php +++ b/src/Validator/Mapping/PropertyMetadata.php @@ -23,10 +23,7 @@ public function __construct(string $name) */ protected function newReflectionMember($objectOrClassName): ReflectionProperty { - $member = new ReflectionProperty($objectOrClassName, $this->getName()); - $member->setAccessible(true); - - return $member; + return new ReflectionProperty($objectOrClassName, $this->getName()); } #[ReturnTypeWillChange]