File tree 3 files changed +26
-1
lines changed
3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-18268: array_walk() on object with added property hooks
3
+ --FILE--
4
+ <?php
5
+
6
+ class A {
7
+ public $ prop = 42 ;
8
+ }
9
+
10
+ class B extends A {
11
+ public $ prop = 42 {
12
+ set {}
13
+ }
14
+ }
15
+
16
+ $ b = new B ;
17
+ array_walk ($ b , function (&$ item ) {
18
+ var_dump ($ item );
19
+ });
20
+
21
+ ?>
22
+ --EXPECT--
23
+ int(42)
Original file line number Diff line number Diff line change @@ -467,6 +467,8 @@ typedef struct _zend_property_info {
467
467
((uint32_t)(XtOffsetOf(zend_object, properties_table) + sizeof(zval) * (num)))
468
468
#define OBJ_PROP_TO_NUM (offset ) \
469
469
(((offset) - OBJ_PROP_TO_OFFSET(0)) / sizeof(zval))
470
+ #define OBJ_PROP_SLOT_TO_OFFSET (obj , slot ) \
471
+ ((uintptr_t)(slot) - (uintptr_t)(obj))
470
472
471
473
typedef struct _zend_class_constant {
472
474
zval value ; /* flags are stored in u2 */
Original file line number Diff line number Diff line change @@ -203,7 +203,7 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_del(zend_object *object) /* {{{ *
203
203
204
204
ZEND_API ZEND_COLD zend_property_info * zend_get_property_info_for_slot_slow (zend_object * obj , zval * slot )
205
205
{
206
- uintptr_t offset = ( uintptr_t ) slot - ( uintptr_t ) obj -> properties_table ;
206
+ uintptr_t offset = OBJ_PROP_SLOT_TO_OFFSET ( obj , slot ) ;
207
207
zend_property_info * prop_info ;
208
208
ZEND_HASH_MAP_FOREACH_PTR (& obj -> ce -> properties_info , prop_info ) {
209
209
if (prop_info -> offset == offset ) {
You can’t perform that action at this time.
0 commit comments