1--TEST--
2Test usage of ReflectionProperty methods __toString(), getName(), isPublic(), isPrivate(), isProtected(), isStatic(), getValue() and setValue().
3--FILE--
4<?php
5
6function reflectProperty($class, $property) {
7    $propInfo = new ReflectionProperty($class, $property);
8    echo "**********************************\n";
9    echo "Reflecting on property $class::$property\n\n";
10    echo "__toString():\n";
11    var_dump($propInfo->__toString());
12    echo "getName():\n";
13    var_dump($propInfo->getName());
14    echo "isPublic():\n";
15    var_dump($propInfo->isPublic());
16    echo "isPrivate():\n";
17    var_dump($propInfo->isPrivate());
18    echo "isProtected():\n";
19    var_dump($propInfo->isProtected());
20    echo "isStatic():\n";
21    var_dump($propInfo->isStatic());
22    $instance = new $class();
23    if ($propInfo->isPublic()) {
24        echo "getValue():\n";
25        var_dump($propInfo->getValue($instance));
26        $propInfo->setValue($instance, "NewValue");
27        echo "getValue() after a setValue():\n";
28        var_dump($propInfo->getValue($instance));
29    }
30    echo "\n**********************************\n";
31}
32
33class TestClass {
34    public $pub;
35    static public $stat = "static property";
36    protected $prot = 4;
37    private $priv = "keepOut";
38}
39
40reflectProperty("TestClass", "pub");
41reflectProperty("TestClass", "stat");
42reflectProperty("TestClass", "prot");
43reflectProperty("TestClass", "priv");
44
45?>
46--EXPECT--
47**********************************
48Reflecting on property TestClass::pub
49
50__toString():
51string(32) "Property [ public $pub = NULL ]
52"
53getName():
54string(3) "pub"
55isPublic():
56bool(true)
57isPrivate():
58bool(false)
59isProtected():
60bool(false)
61isStatic():
62bool(false)
63getValue():
64NULL
65getValue() after a setValue():
66string(8) "NewValue"
67
68**********************************
69**********************************
70Reflecting on property TestClass::stat
71
72__toString():
73string(53) "Property [ public static $stat = 'static property' ]
74"
75getName():
76string(4) "stat"
77isPublic():
78bool(true)
79isPrivate():
80bool(false)
81isProtected():
82bool(false)
83isStatic():
84bool(true)
85getValue():
86string(15) "static property"
87getValue() after a setValue():
88string(8) "NewValue"
89
90**********************************
91**********************************
92Reflecting on property TestClass::prot
93
94__toString():
95string(33) "Property [ protected $prot = 4 ]
96"
97getName():
98string(4) "prot"
99isPublic():
100bool(false)
101isPrivate():
102bool(false)
103isProtected():
104bool(true)
105isStatic():
106bool(false)
107
108**********************************
109**********************************
110Reflecting on property TestClass::priv
111
112__toString():
113string(39) "Property [ private $priv = 'keepOut' ]
114"
115getName():
116string(4) "priv"
117isPublic():
118bool(false)
119isPrivate():
120bool(true)
121isProtected():
122bool(false)
123isStatic():
124bool(false)
125
126**********************************
127