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