mirror of
https://github.com/yiisoft/yii2.git
synced 2025-10-29 01:17:13 +08:00
Fix #20482: Fix deprecation of ReflectionMethod::setAccessible() in PHP 8.5
This commit is contained in:
@ -70,7 +70,13 @@ class FileCacheTest extends CacheTestCase
|
||||
$refClass = new \ReflectionClass($cache);
|
||||
|
||||
$refMethodGetCacheFile = $refClass->getMethod('getCacheFile');
|
||||
$refMethodGetCacheFile->setAccessible(true);
|
||||
|
||||
// @link https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_reflectionsetaccessible
|
||||
// @link https://wiki.php.net/rfc/make-reflection-setaccessible-no-op
|
||||
if (PHP_VERSION_ID < 80100) {
|
||||
$refMethodGetCacheFile->setAccessible(true);
|
||||
}
|
||||
|
||||
$refMethodGet = $refClass->getMethod('get');
|
||||
$refMethodSet = $refClass->getMethod('set');
|
||||
|
||||
@ -91,7 +97,13 @@ class FileCacheTest extends CacheTestCase
|
||||
$normalizeKey = $cache->buildKey(__FUNCTION__);
|
||||
$refClass = new \ReflectionClass($cache);
|
||||
$refMethodGetCacheFile = $refClass->getMethod('getCacheFile');
|
||||
$refMethodGetCacheFile->setAccessible(true);
|
||||
|
||||
// @link https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_reflectionsetaccessible
|
||||
// @link https://wiki.php.net/rfc/make-reflection-setaccessible-no-op
|
||||
if (PHP_VERSION_ID < 80100) {
|
||||
$refMethodGetCacheFile->setAccessible(true);
|
||||
}
|
||||
|
||||
$cacheFile = $refMethodGetCacheFile->invoke($cache, $normalizeKey);
|
||||
|
||||
// simulate cache expire 10 seconds ago
|
||||
|
||||
Reference in New Issue
Block a user