Remove useless calls to `->setAccessible()` for Reflection
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 31 May 2022 10:47:21 +0000 (12:47 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 31 May 2022 10:47:21 +0000 (12:47 +0200)
These are no longer required as of PHP 8.1.

wcfsetup/install.php
wcfsetup/install/files/lib/core.functions.php
wcfsetup/install/files/lib/data/user/notification/event/UserNotificationEventAction.class.php
wcfsetup/install/files/lib/system/user/notification/TestableUserNotificationEventHandler.class.php
wcfsetup/install/files/lib/system/user/notification/event/TTestablePageUserNotificationEvent.class.php

index 9cdd3802aead26bab9a71b0cdeebdb0a8053d54e..a22e16fd45fc75f91cbf36dc64bd92715c85eae3 100644 (file)
@@ -397,7 +397,6 @@ function printException($e) {
 
                                                                $reflection = new \ReflectionClass($e);
                                                                $property = $reflection->getProperty('information');
-                                                               $property->setAccessible(true);
                                                                if ($property->getValue($e)) {
                                                                        throw new \Exception("Using the 'information' property of SystemException is not supported any more.");
                                                                }
index ffdc1923794029b32fa2781524e92f450eb25e9b..ed81b6d393a23a65f9f44fb4e9239d01390ee502 100644 (file)
@@ -605,7 +605,6 @@ EXPLANATION;
 
                                                                $reflection = new \ReflectionClass($e);
                                                                $property = $reflection->getProperty('information');
-                                                               $property->setAccessible(true);
                                                                if ($property->getValue($e)) {
                                                                        throw new \Exception("Using the 'information' property of SystemException is not supported any more.");
                                                                }
index 80748ac78d6f76bee1d1c12907f36aa82be9563a..90b900e8996c13c943360aabf5aef196ae391e57 100644 (file)
@@ -101,7 +101,6 @@ class UserNotificationEventAction extends AbstractDatabaseObjectAction
         // avoid issues with links
         $reflectionClass = new \ReflectionClass(RequestHandler::class);
         $reflectionProperty = $reflectionClass->getProperty('isACPRequest');
-        $reflectionProperty->setAccessible(true);
         $reflectionProperty->setValue(RequestHandler::getInstance(), false);
 
         /**
index 2998dcbf08114a3486a4bea1c20253991d5cb0eb..8ed0a14d7bd8f188ce19f7cb4e68b1ca0e12d5e8 100644 (file)
@@ -311,7 +311,6 @@ class TestableUserNotificationEventHandler extends SingletonFactory
     {
         $reflectionClass = new \ReflectionClass(\get_class($cacheBuilder));
         $reflectionProperty = $reflectionClass->getProperty('cache');
-        $reflectionProperty->setAccessible(true);
         $reflectionProperty->setValue($cacheBuilder, []);
     }
 }
index 1c5d2989c49158d7cd92588033c871fdddeca1fa..f2e0e7d1d0a9040c625dedcce5e33ca2ea3b86bc 100644 (file)
@@ -74,13 +74,11 @@ trait TTestablePageUserNotificationEvent
         // reset page cache
         $reflectionClass = new \ReflectionClass(PageCache::class);
         $reflectionProperty = $reflectionClass->getProperty('cache');
-        $reflectionProperty->setAccessible(true);
         $reflectionProperty->setValue(PageCache::getInstance(), PageCacheBuilder::getInstance()->getData());
 
         // reset controller map
         $reflectionClass = new \ReflectionClass(ControllerMap::class);
         $reflectionMethod = $reflectionClass->getMethod('init');
-        $reflectionMethod->setAccessible(true);
         $reflectionMethod->invoke(ControllerMap::getInstance());
     }
 }