-
Improvement
-
Resolution: Fixed
-
Minor
-
4.1
-
MOODLE_401_STABLE
-
MOODLE_404_STABLE
-
Starting with PHP 8.1, the setAccessible() methods in Reflection classes are not needed any more because all properties and methods are accesible by default.
ReflectionProperty::setAccessible() and ReflectionMethod::setAccessible()
no longer have an effect. Properties and methods are always considered
accessible through reflection.
RFC: https://wiki.php.net/rfc/make-reflection-setaccessible-no-op
In PHP 8.1 (and hopefully some more versions, still don't know if PHP 8.2 changes this), those setAccessible() are simply ignored, without emitting any notice/warning/deprecation.
Once PHP 8.1 is the minimum required for Moodle (say for example Moodle 4.5, though that could be wrong, has not been decided yet) we'll be able to safely remove all uses from core.
Note that this may need another solution if suddenly, for example in PHP 8.2/8.3 they decide the methods to start emitting notice/warning/deprecation.
Ciao