1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
--TEST--
Test that ReflectionProperty::setAccessible() has no effects
--FILE--
<?php
class A {
protected $protected = 'a';
protected static $protectedStatic = 'b';
private $private = 'c';
private static $privateStatic = 'd';
}
class B extends A {}
$a = new A;
$protected = new ReflectionProperty($a, 'protected');
$protectedStatic = new ReflectionProperty('A', 'protectedStatic');
$private = new ReflectionProperty($a, 'private');
$privateStatic = new ReflectionProperty('A', 'privateStatic');
var_dump($protected->getValue($a));
var_dump($protectedStatic->getValue());
var_dump($private->getValue($a));
var_dump($privateStatic->getValue());
$protected->setValue($a, 'e');
$protectedStatic->setValue(null, 'f');
$private->setValue($a, 'g');
$privateStatic->setValue(null, 'h');
var_dump($protected->getValue($a));
var_dump($protectedStatic->getValue());
var_dump($private->getValue($a));
var_dump($privateStatic->getValue());
$protected->setAccessible(FALSE);
$protectedStatic->setAccessible(FALSE);
$private->setAccessible(FALSE);
$privateStatic->setAccessible(FALSE);
var_dump($protected->getValue($a));
var_dump($protectedStatic->getValue());
var_dump($private->getValue($a));
var_dump($privateStatic->getValue());
$protected->setValue($a, 'i');
$protectedStatic->setValue('j');
$private->setValue($a, 'k');
$privateStatic->setValue(null, 'l');
var_dump($protected->getValue($a));
var_dump($protectedStatic->getValue());
var_dump($private->getValue($a));
var_dump($privateStatic->getValue());
$a = new A;
$b = new B;
$protected = new ReflectionProperty($b, 'protected');
$protectedStatic = new ReflectionProperty('B', 'protectedStatic');
$private = new ReflectionProperty($a, 'private');
var_dump($protected->getValue($b));
var_dump($protectedStatic->getValue());
var_dump($private->getValue($b));
$protected->setValue($b, 'e');
$protectedStatic->setValue(null, 'f');
$private->setValue($b, 'g');
var_dump($protected->getValue($b));
var_dump($protectedStatic->getValue());
var_dump($private->getValue($b));
$protected->setAccessible(FALSE);
$protectedStatic->setAccessible(FALSE);
$private->setAccessible(FALSE);
var_dump($protected->getValue($b));
var_dump($protectedStatic->getValue());
var_dump($private->getValue($b));
$protected->setValue($b, 'h');
$protectedStatic->setValue(null, 'i');
$private->setValue($b, 'j');
var_dump($protected->getValue($b));
var_dump($protectedStatic->getValue());
var_dump($private->getValue($b));
?>
--EXPECTF--
string(1) "a"
string(1) "b"
string(1) "c"
string(1) "d"
string(1) "e"
string(1) "f"
string(1) "g"
string(1) "h"
string(1) "e"
string(1) "f"
string(1) "g"
string(1) "h"
Deprecated: Calling ReflectionProperty::setValue() with a single argument is deprecated in %s on line %d
string(1) "i"
string(1) "j"
string(1) "k"
string(1) "l"
string(1) "a"
string(1) "j"
string(1) "c"
string(1) "e"
string(1) "f"
string(1) "g"
string(1) "e"
string(1) "f"
string(1) "g"
string(1) "h"
string(1) "i"
string(1) "j"
|