From 2ddb319d8654da7e5b8e5d2a78fb4e45897a5b33 Mon Sep 17 00:00:00 2001 From: Thomas Deletraz <208691218+ThomasSimplis@users.noreply.github.com> Date: Thu, 3 Dec 2026 12:08:39 +0100 Subject: [PATCH] fix: remove setAccessible() calls deprecated in PHP 8.5 ReflectionProperty::setAccessible() and ReflectionMethod::setAccessible() have had no effect since PHP 8.1 and are deprecated since PHP 8.5. The bundle requires PHP >= 8.1, so the calls can be dropped. Co-Authored-By: Claude Opus 5.5 --- src/Validator/Mapping/ObjectMetadata.php | 2 -- src/Validator/Mapping/PropertyMetadata.php | 5 +---- 2 files changed, 1 insertion(+), 6 deletions(-) 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]