@@ -39,6 +39,7 @@ PHPAPI zend_class_entry *spl_ce_SplObjectStorage;
39
39
PHPAPI zend_class_entry * spl_ce_MultipleIterator ;
40
40
41
41
static zend_object_handlers spl_handler_SplObjectStorage ;
42
+ static zend_object_handlers spl_handler_MultipleIterator ;
42
43
43
44
/* Bit flags for marking internal functionality overridden by SplObjectStorage subclasses. */
44
45
#define SOS_OVERRIDDEN_READ_DIMENSION 1
@@ -487,6 +488,20 @@ static void spl_object_storage_write_dimension(zend_object *object, zval *offset
487
488
spl_object_storage_attach_handle (intern , Z_OBJ_P (offset ), inf );
488
489
}
489
490
491
+ static void spl_multiple_iterator_write_dimension (zend_object * object , zval * offset , zval * inf )
492
+ {
493
+ spl_SplObjectStorage * intern = spl_object_storage_from_obj (object );
494
+ if (UNEXPECTED (offset == NULL || Z_TYPE_P (offset ) != IS_OBJECT || (intern -> flags & SOS_OVERRIDDEN_WRITE_DIMENSION ))) {
495
+ zend_std_write_dimension (object , offset , inf );
496
+ return ;
497
+ }
498
+ if (UNEXPECTED (!Z_OBJCE_P (offset )-> iterator_funcs_ptr || !Z_OBJCE_P (offset )-> iterator_funcs_ptr -> zf_valid )) {
499
+ zend_type_error ("Can only attach objects that implement the Iterator interface" );
500
+ return ;
501
+ }
502
+ spl_object_storage_attach_handle (intern , Z_OBJ_P (offset ), inf );
503
+ }
504
+
490
505
static void spl_object_storage_unset_dimension (zend_object * object , zval * offset )
491
506
{
492
507
spl_SplObjectStorage * intern = spl_object_storage_from_obj (object );
@@ -1389,9 +1404,13 @@ PHP_MINIT_FUNCTION(spl_observer)
1389
1404
spl_handler_SplObjectStorage .has_dimension = spl_object_storage_has_dimension ;
1390
1405
spl_handler_SplObjectStorage .unset_dimension = spl_object_storage_unset_dimension ;
1391
1406
1407
+ memcpy (& spl_handler_MultipleIterator , & spl_handler_SplObjectStorage , sizeof (zend_object_handlers ));
1408
+
1409
+ spl_handler_MultipleIterator .write_dimension = spl_multiple_iterator_write_dimension ;
1410
+
1392
1411
spl_ce_MultipleIterator = register_class_MultipleIterator (zend_ce_iterator );
1393
1412
spl_ce_MultipleIterator -> create_object = spl_SplObjectStorage_new ;
1394
- spl_ce_MultipleIterator -> default_object_handlers = & spl_handler_SplObjectStorage ;
1413
+ spl_ce_MultipleIterator -> default_object_handlers = & spl_handler_MultipleIterator ;
1395
1414
1396
1415
return SUCCESS ;
1397
1416
}
0 commit comments