File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug GH-8655 (zval reference is not released when targetting a declared property)
3
+ --FILE--
4
+ <?php
5
+ class Foo
6
+ {
7
+ public $ foo ;
8
+ }
9
+
10
+ function hydrate ($ properties , $ object ) {
11
+ foreach ($ properties as $ name => &$ value ) {
12
+ $ object ->$ name = &$ value ;
13
+ }
14
+ };
15
+
16
+ $ object = new Foo ;
17
+
18
+ hydrate (['foo ' => 123 ], $ object );
19
+
20
+ $ arrayCast = (array ) $ object ;
21
+
22
+ $ object ->foo = 234 ;
23
+ var_dump (ReflectionReference::fromArrayElement ($ arrayCast , 'foo ' ));
24
+ echo $ arrayCast ['foo ' ];
25
+ ?>
26
+ --EXPECT--
27
+ NULL
28
+ 123
Original file line number Diff line number Diff line change @@ -111,6 +111,10 @@ ZEND_API HashTable *zend_std_build_object_properties_array(zend_object *zobj) /*
111
111
continue ;
112
112
}
113
113
114
+ if (Z_ISREF_P (prop ) && Z_REFCOUNT_P (prop ) == 1 ) {
115
+ prop = Z_REFVAL_P (prop );
116
+ }
117
+
114
118
Z_TRY_ADDREF_P (prop );
115
119
_zend_hash_append (ht , prop_info -> name , prop );
116
120
}
You can’t perform that action at this time.
0 commit comments