diff --git a/CHANGELOG.md b/CHANGELOG.md index 23041a04b..22e50b159 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Yii Framework 2 debug extension Change Log - Bug #541: Silence fetch errors (Karkbauer) - Enh #546: Applying Yii2 coding standards (@s1lver) - Enh #546: Raise min version to PHP 7.4 (@s1lver) +- Bug #548: Fix `Deprecated ArrayObject::__construct()` and Method `ReflectionMethod::setAccessible()` in PHP 8.5 (@terabytesoftw) - Bug #549: Enhance documentation and add scripts for `composer.json` (@terabytesoftw) 2.1.27 June 08, 2025 diff --git a/src/FlattenException.php b/src/FlattenException.php index ef3e48392..398acbe7d 100644 --- a/src/FlattenException.php +++ b/src/FlattenException.php @@ -292,8 +292,8 @@ private function flattenArgs($args, $level = 0, &$count = 0) */ private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value) { - $array = new \ArrayObject($value); + $array = \get_object_vars($value); - return $array['__PHP_Incomplete_Class_Name']; + return (string) ($array['__PHP_Incomplete_Class_Name'] ?? ''); } } diff --git a/src/models/router/RouterRules.php b/src/models/router/RouterRules.php index a9ffb242c..e7359709a 100644 --- a/src/models/router/RouterRules.php +++ b/src/models/router/RouterRules.php @@ -143,7 +143,11 @@ protected function scanRestRule($restRule) { $reflectionClass = new \ReflectionClass($restRule); $reflectionProperty = $reflectionClass->getProperty('rules'); - $reflectionProperty->setAccessible(true); + + if (PHP_VERSION_ID < 80100) { + $reflectionProperty->setAccessible(true); + } + $rulesGroups = $reflectionProperty->getValue($restRule); foreach ($rulesGroups as $rules) { diff --git a/tests/TestCase.php b/tests/TestCase.php index f9ba2e69b..d58d95cfe 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -73,9 +73,17 @@ protected function invoke($object, $method, array $args = []) { $classReflection = new \ReflectionClass(get_class($object)); $methodReflection = $classReflection->getMethod($method); - $methodReflection->setAccessible(true); + + if (PHP_VERSION_ID < 80100) { + $methodReflection->setAccessible(true); + } + $result = $methodReflection->invokeArgs($object, $args); - $methodReflection->setAccessible(false); + + if (PHP_VERSION_ID < 80100) { + $methodReflection->setAccessible(false); + } + return $result; } }