@@ -548,6 +548,61 @@ static ZEND_FUNCTION(zend_call_method_if_exists)
548548 }
549549}
550550
551+ static ZEND_FUNCTION (zend_test_call_with_consumed_args )
552+ {
553+ zend_fcall_info fci = empty_fcall_info ;
554+ zend_fcall_info_cache fcc = empty_fcall_info_cache ;
555+ zval * args ;
556+ zend_long consumed_args ;
557+ zval retval ;
558+ uint32_t actual_consumed_args = 0 ;
559+ uint32_t i ;
560+ zend_result call_result ;
561+
562+ ZEND_PARSE_PARAMETERS_START (3 , 3 )
563+ Z_PARAM_FUNC (fci , fcc )
564+ Z_PARAM_ARRAY (args )
565+ Z_PARAM_LONG (consumed_args )
566+ ZEND_PARSE_PARAMETERS_END ();
567+
568+ if (UNEXPECTED (consumed_args < 0 || consumed_args > UINT32_MAX )) {
569+ zend_argument_value_error (3 , "must be between 0 and 4294967295" );
570+ RETURN_THROWS ();
571+ }
572+
573+ zend_fcall_info_args (& fci , args );
574+
575+ ZVAL_UNDEF (& retval );
576+ fci .retval = & retval ;
577+ fci .consumed_args = (uint32_t ) consumed_args ;
578+
579+ call_result = zend_call_function (& fci , & fcc );
580+
581+ for (i = 0 ; i < fci .param_count && i < 32 ; i ++ ) {
582+ if (Z_ISUNDEF (fci .params [i ])) {
583+ actual_consumed_args |= (1u << i );
584+ }
585+ }
586+
587+ zend_fcall_info_args_clear (& fci , true);
588+
589+ if (call_result == FAILURE || EG (exception )) {
590+ if (!Z_ISUNDEF (retval )) {
591+ zval_ptr_dtor (& retval );
592+ }
593+ RETURN_THROWS ();
594+ }
595+
596+ array_init (return_value );
597+ add_assoc_long (return_value , "consumed_args" , actual_consumed_args );
598+
599+ if (Z_ISUNDEF (retval )) {
600+ add_assoc_null (return_value , "retval" );
601+ } else {
602+ add_assoc_zval (return_value , "retval" , & retval );
603+ }
604+ }
605+
551606static ZEND_FUNCTION (zend_get_unit_enum )
552607{
553608 ZEND_PARSE_PARAMETERS_NONE ();
0 commit comments