File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #40794 (ReflectionObject::getValues() may crash when used with dynamic properties)
3
+ --SKIPIF--
4
+ <?php
5
+ if (!extension_loaded ("reflection " )) {
6
+ die ("skip " );
7
+ }
8
+ ?>
9
+ --FILE--
10
+ <?php
11
+
12
+ $ obj = new stdClass ();
13
+ $ obj ->prop1 = '1 ' ;
14
+ $ obj ->prop2 = '2 ' ;
15
+ $ obj ->prop3 = '3 ' ;
16
+
17
+ $ reflect = new ReflectionObject ($ obj );
18
+
19
+ $ array = array ();
20
+ foreach ($ reflect ->getProperties () as $ prop )
21
+ {
22
+ $ array [$ prop ->getName ()] = $ prop ->getValue ($ obj );
23
+ }
24
+
25
+ var_dump ($ array );
26
+
27
+ echo "Done \n" ;
28
+ ?>
29
+ --EXPECTF--
30
+ array(3) {
31
+ ["prop1"]=>
32
+ string(1) "1"
33
+ ["prop2"]=>
34
+ string(1) "2"
35
+ ["prop3"]=>
36
+ string(1) "3"
37
+ }
38
+ Done
39
+ --UEXPECTF--
40
+ array(3) {
41
+ [u"prop1"]=>
42
+ unicode(1) "1"
43
+ [u"prop2"]=>
44
+ unicode(1) "2"
45
+ [u"prop3"]=>
46
+ unicode(1) "3"
47
+ }
48
+ Done
You can’t perform that action at this time.
0 commit comments