From 8c629a03104582d9838708e0627acab97525ae2c Mon Sep 17 00:00:00 2001 From: Andy Postnikov Date: Fri, 7 Nov 2025 20:41:50 +0100 Subject: [PATCH] Fix PHP 8.5 deprecation - Reflection*::setAccessible() ref https://wiki.php.net/rfc/deprecations_php_8_5#extreflection_deprecations related to https://github.com/drush-ops/drush/issues/6349 --- src/AnnotatedCommand.php | 2 +- tests/AnnotatedCommandFactoryTest.php | 2 +- tests/FullStackTest.php | 2 +- tests/FullyQualifiedClassCacheTest.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AnnotatedCommand.php b/src/AnnotatedCommand.php index bdf0cb7..2408c8b 100644 --- a/src/AnnotatedCommand.php +++ b/src/AnnotatedCommand.php @@ -259,7 +259,7 @@ private function addInputOption($inputOption, $description = null) // Alas, Symfony provides no accessor. $class = new \ReflectionClass($inputOption); $property = $class->getProperty('suggestedValues'); - $property->setAccessible(true); + (\PHP_VERSION_ID < 80100) and $property->setAccessible(true); $suggestedValues = $property->getValue($inputOption); } $this->addOption( diff --git a/tests/AnnotatedCommandFactoryTest.php b/tests/AnnotatedCommandFactoryTest.php index 6cd7ba9..abb11c3 100644 --- a/tests/AnnotatedCommandFactoryTest.php +++ b/tests/AnnotatedCommandFactoryTest.php @@ -1216,7 +1216,7 @@ function ($output, $message) { function callProtected($object, $method, $args = []) { $r = new \ReflectionMethod($object, $method); - $r->setAccessible(true); + (\PHP_VERSION_ID < 80100) and $r->setAccessible(true); return $r->invokeArgs($object, $args); } diff --git a/tests/FullStackTest.php b/tests/FullStackTest.php index 3be8567..6287e71 100644 --- a/tests/FullStackTest.php +++ b/tests/FullStackTest.php @@ -512,7 +512,7 @@ function simplifyWhitespace($data) function callProtected($object, $method, $args = []) { $r = new \ReflectionMethod($object, $method); - $r->setAccessible(true); + (\PHP_VERSION_ID < 80100) and $r->setAccessible(true); return $r->invokeArgs($object, $args); } diff --git a/tests/FullyQualifiedClassCacheTest.php b/tests/FullyQualifiedClassCacheTest.php index c366649..ca24a6d 100644 --- a/tests/FullyQualifiedClassCacheTest.php +++ b/tests/FullyQualifiedClassCacheTest.php @@ -40,7 +40,7 @@ function testFqcn() function callProtected($object, $method, $args = []) { $r = new \ReflectionMethod($object, $method); - $r->setAccessible(true); + (\PHP_VERSION_ID < 80100) and $r->setAccessible(true); return $r->invokeArgs($object, $args); } }