@@ -39,6 +39,7 @@ PHPAPI zend_class_entry     *spl_ce_SplObjectStorage;
3939PHPAPI  zend_class_entry      * spl_ce_MultipleIterator ;
4040
4141static  zend_object_handlers  spl_handler_SplObjectStorage ;
42+ static  zend_object_handlers  spl_handler_MultipleIterator ;
4243
4344/* Bit flags for marking internal functionality overridden by SplObjectStorage subclasses. */ 
4445#define  SOS_OVERRIDDEN_READ_DIMENSION   1
@@ -488,6 +489,20 @@ static void spl_object_storage_write_dimension(zend_object *object, zval *offset
488489	spl_object_storage_attach_handle (intern , Z_OBJ_P (offset ), inf );
489490}
490491
492+ static  void  spl_multiple_iterator_write_dimension (zend_object  * object , zval  * offset , zval  * inf )
493+ {
494+ 	spl_SplObjectStorage  * intern  =  spl_object_storage_from_obj (object );
495+ 	if  (UNEXPECTED (offset  ==  NULL  ||  Z_TYPE_P (offset ) !=  IS_OBJECT  ||  (intern -> flags  &  SOS_OVERRIDDEN_WRITE_DIMENSION ))) {
496+ 		zend_std_write_dimension (object , offset , inf );
497+ 		return ;
498+ 	}
499+ 	if  (UNEXPECTED (!Z_OBJCE_P (offset )-> iterator_funcs_ptr  ||  !Z_OBJCE_P (offset )-> iterator_funcs_ptr -> zf_valid )) {
500+ 		zend_type_error ("Can only attach objects that implement the Iterator interface" );
501+ 		return ;
502+ 	}
503+ 	spl_object_storage_attach_handle (intern , Z_OBJ_P (offset ), inf );
504+ }
505+ 
491506static  void  spl_object_storage_unset_dimension (zend_object  * object , zval  * offset )
492507{
493508	spl_SplObjectStorage  * intern  =  spl_object_storage_from_obj (object );
@@ -1390,9 +1405,13 @@ PHP_MINIT_FUNCTION(spl_observer)
13901405	spl_handler_SplObjectStorage .has_dimension    =  spl_object_storage_has_dimension ;
13911406	spl_handler_SplObjectStorage .unset_dimension  =  spl_object_storage_unset_dimension ;
13921407
1408+ 	memcpy (& spl_handler_MultipleIterator , & spl_handler_SplObjectStorage , sizeof (zend_object_handlers ));
1409+ 
1410+ 	spl_handler_MultipleIterator .write_dimension  =  spl_multiple_iterator_write_dimension ;
1411+ 
13931412	spl_ce_MultipleIterator  =  register_class_MultipleIterator (zend_ce_iterator );
13941413	spl_ce_MultipleIterator -> create_object  =  spl_SplObjectStorage_new ;
1395- 	spl_ce_MultipleIterator -> default_object_handlers  =  & spl_handler_SplObjectStorage ;
1414+ 	spl_ce_MultipleIterator -> default_object_handlers  =  & spl_handler_MultipleIterator ;
13961415
13971416	return  SUCCESS ;
13981417}
0 commit comments