mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
6e16e1daa9
With this patch, it is no longer required to call `ReflectionProperty#setAccessible()` or `ReflectionMethod#setAccessible()` with `true`. If a userland consumer already got to the point of accessing object/class information via reflection, it makes little sense for `ext/reflection` to disallow accessing `private`/`protected` symbols by default. After this patch, calling `ReflectionProperty#setAccessible(true)` or `ReflectionMethod#setAccessible(true)` on newly instantiated `ReflectionProperty` or `ReflectionMethod` respectively will have no effect. RFC: https://wiki.php.net/rfc/make-reflection-setaccessible-no-op Closes GH-5412.
36 lines
895 B
PHP
36 lines
895 B
PHP
--TEST--
|
|
Bug #78921: When Reflection triggers class load, property visibility is incorrect
|
|
--FILE--
|
|
<?php
|
|
|
|
spl_autoload_register(function($className) {
|
|
if ($className == 'PrivateStatic') {
|
|
class PrivateStatic
|
|
{
|
|
const SOME_CONST = 13;
|
|
private static $privateStaticVarArray = ['a', 'b', 'c'];
|
|
private static $otherStatic;
|
|
public static function init()
|
|
{
|
|
self::$otherStatic = self::$privateStaticVarArray;
|
|
}
|
|
}
|
|
PrivateStatic::init();
|
|
}
|
|
});
|
|
|
|
class OtherClass
|
|
{
|
|
const MY_CONST = PrivateStatic::SOME_CONST;
|
|
public static $prop = 'my property';
|
|
}
|
|
|
|
$reflectionClass = new ReflectionClass('OtherClass');
|
|
$reflectionProperty = $reflectionClass->getProperty('prop');
|
|
$value = $reflectionProperty->getValue();
|
|
echo "Value is $value\n";
|
|
|
|
?>
|
|
--EXPECT--
|
|
Value is my property
|