xref: /PHP-5.3/ext/reflection/tests/bug40431.phpt (revision 30a8d14f)
1--TEST--
2Bug #40431 (dynamic properties may cause crash in ReflectionProperty methods)
3--FILE--
4<?php
5
6echo "=== 1st test ===\n";
7
8$Obj->value = 'value';
9$RefObj = new ReflectionObject($Obj);
10
11$props = $RefObj->getProperties();
12
13var_dump($props);
14var_dump($props[0]->isStatic());
15var_dump($props[0]->isPrivate());
16var_dump($props[0]->isPublic());
17var_dump($props[0]->isProtected());
18
19echo "=== 2nd test ===\n";
20
21class test1 {
22}
23
24class test2 extends test1{
25}
26
27$Obj = new test2;
28$Obj->value = 'value';
29$RefObj = new ReflectionObject($Obj);
30
31$props = $RefObj->getProperties();
32
33var_dump($props);
34var_dump($props[0]->isStatic());
35var_dump($props[0]->isPrivate());
36var_dump($props[0]->isPublic());
37var_dump($props[0]->isProtected());
38
39echo "=== 3rd test ===\n";
40
41class test3 {
42}
43
44$Obj = new test3;
45$Obj->value = 'value';
46$RefObj = new ReflectionObject($Obj);
47
48$props = $RefObj->getProperties();
49
50var_dump($props);
51var_dump($props[0]->isStatic());
52var_dump($props[0]->isPrivate());
53var_dump($props[0]->isPublic());
54var_dump($props[0]->isProtected());
55
56echo "=== 4th test ===\n";
57
58class test5 {
59	private $value = 1;
60}
61
62class test4 extends test5{
63}
64
65$Obj = new test4;
66$Obj->value = 'value';
67$RefObj = new ReflectionObject($Obj);
68
69$props = $RefObj->getProperties();
70
71var_dump($props);
72var_dump($props[0]->isStatic());
73var_dump($props[0]->isPrivate());
74var_dump($props[0]->isPublic());
75var_dump($props[0]->isProtected());
76
77echo "Done\n";
78?>
79--EXPECTF--
80=== 1st test ===
81
82Strict Standards: Creating default object from empty value in %s on line %d
83array(1) {
84  [0]=>
85  &object(ReflectionProperty)#%d (2) {
86    ["name"]=>
87    string(5) "value"
88    ["class"]=>
89    string(8) "stdClass"
90  }
91}
92bool(false)
93bool(false)
94bool(true)
95bool(false)
96=== 2nd test ===
97array(1) {
98  [0]=>
99  &object(ReflectionProperty)#%d (2) {
100    ["name"]=>
101    string(5) "value"
102    ["class"]=>
103    string(5) "test2"
104  }
105}
106bool(false)
107bool(false)
108bool(true)
109bool(false)
110=== 3rd test ===
111array(1) {
112  [0]=>
113  &object(ReflectionProperty)#%d (2) {
114    ["name"]=>
115    string(5) "value"
116    ["class"]=>
117    string(5) "test3"
118  }
119}
120bool(false)
121bool(false)
122bool(true)
123bool(false)
124=== 4th test ===
125array(1) {
126  [0]=>
127  &object(ReflectionProperty)#%d (2) {
128    ["name"]=>
129    string(5) "value"
130    ["class"]=>
131    string(5) "test4"
132  }
133}
134bool(false)
135bool(false)
136bool(true)
137bool(false)
138Done
139