@@ -43,6 +43,7 @@ PHPAPI zend_class_entry *spl_ce_SplObjectStorage;
43
43
PHPAPI zend_class_entry * spl_ce_MultipleIterator ;
44
44
45
45
PHPAPI zend_object_handlers spl_handler_SplObjectStorage ;
46
+ static zend_object_handlers spl_handler_MultipleIterator ; /* TODO: make public ? */
46
47
47
48
/* Bit flags for marking internal functionality overridden by SplObjectStorage subclasses. */
48
49
#define SOS_OVERRIDDEN_READ_DIMENSION 1
@@ -493,6 +494,20 @@ static void spl_object_storage_write_dimension(zend_object *object, zval *offset
493
494
spl_object_storage_attach_handle (intern , Z_OBJ_P (offset ), inf );
494
495
}
495
496
497
+ static void spl_multiple_iterator_write_dimension (zend_object * object , zval * offset , zval * inf )
498
+ {
499
+ spl_SplObjectStorage * intern = spl_object_storage_from_obj (object );
500
+ if (UNEXPECTED (offset == NULL || Z_TYPE_P (offset ) != IS_OBJECT || (intern -> flags & SOS_OVERRIDDEN_WRITE_DIMENSION ))) {
501
+ zend_std_write_dimension (object , offset , inf );
502
+ return ;
503
+ }
504
+ if (UNEXPECTED (!Z_OBJCE_P (offset )-> iterator_funcs_ptr || !Z_OBJCE_P (offset )-> iterator_funcs_ptr -> zf_valid )) {
505
+ zend_type_error ("Can only attach objects that implement the Iterator interface" );
506
+ return ;
507
+ }
508
+ spl_object_storage_attach_handle (intern , Z_OBJ_P (offset ), inf );
509
+ }
510
+
496
511
static void spl_object_storage_unset_dimension (zend_object * object , zval * offset )
497
512
{
498
513
spl_SplObjectStorage * intern = spl_object_storage_from_obj (object );
@@ -1352,9 +1367,13 @@ PHP_MINIT_FUNCTION(spl_observer)
1352
1367
spl_handler_SplObjectStorage .has_dimension = spl_object_storage_has_dimension ;
1353
1368
spl_handler_SplObjectStorage .unset_dimension = spl_object_storage_unset_dimension ;
1354
1369
1370
+ memcpy (& spl_handler_MultipleIterator , & spl_handler_SplObjectStorage , sizeof (zend_object_handlers ));
1371
+
1372
+ spl_handler_MultipleIterator .write_dimension = spl_multiple_iterator_write_dimension ;
1373
+
1355
1374
spl_ce_MultipleIterator = register_class_MultipleIterator (zend_ce_iterator );
1356
1375
spl_ce_MultipleIterator -> create_object = spl_SplObjectStorage_new ;
1357
- spl_ce_MultipleIterator -> default_object_handlers = & spl_handler_SplObjectStorage ;
1376
+ spl_ce_MultipleIterator -> default_object_handlers = & spl_handler_MultipleIterator ;
1358
1377
1359
1378
return SUCCESS ;
1360
1379
}
0 commit comments