@@ -761,13 +761,16 @@ static int zend_parse_arg(int arg_num, zval *arg, va_list *va, const char **spec
761
761
if (!(flags & ZEND_PARSE_PARAMS_QUIET ) && (* expected_type || error )) {
762
762
const char * space ;
763
763
const char * class_name = get_active_class_name (& space );
764
+ zend_bool throw_exception =
765
+ ZEND_ARG_USES_STRICT_TYPES () || (flags & ZEND_PARSE_PARAMS_THROW );
764
766
765
767
if (error ) {
766
- zend_internal_type_error (ZEND_ARG_USES_STRICT_TYPES () , "%s%s%s() expects parameter %d %s" ,
767
- class_name , space , get_active_function_name (), arg_num , error );
768
+ zend_internal_type_error (throw_exception , "%s%s%s() expects parameter %d %s" ,
769
+ class_name , space , get_active_function_name (), arg_num , error );
768
770
efree (error );
769
771
} else {
770
- zend_internal_type_error (ZEND_ARG_USES_STRICT_TYPES (), "%s%s%s() expects parameter %d to be %s, %s given" ,
772
+ zend_internal_type_error (throw_exception ,
773
+ "%s%s%s() expects parameter %d to be %s, %s given" ,
771
774
class_name , space , get_active_function_name (), arg_num , expected_type ,
772
775
zend_zval_type_name (arg ));
773
776
}
@@ -876,7 +879,9 @@ static int zend_parse_va_args(int num_args, const char *type_spec, va_list *va,
876
879
if (!(flags & ZEND_PARSE_PARAMS_QUIET )) {
877
880
zend_function * active_function = EG (current_execute_data )-> func ;
878
881
const char * class_name = active_function -> common .scope ? active_function -> common .scope -> name -> val : "" ;
879
- zend_internal_type_error (ZEND_ARG_USES_STRICT_TYPES (), "%s%s%s() expects %s %d parameter%s, %d given" ,
882
+ zend_bool throw_exception =
883
+ ZEND_ARG_USES_STRICT_TYPES () || (flags & ZEND_PARSE_PARAMS_THROW );
884
+ zend_internal_type_error (throw_exception , "%s%s%s() expects %s %d parameter%s, %d given" ,
880
885
class_name ,
881
886
class_name [0 ] ? "::" : "" ,
882
887
active_function -> common .function_name -> val ,
@@ -938,18 +943,19 @@ static int zend_parse_va_args(int num_args, const char *type_spec, va_list *va,
938
943
}
939
944
/* }}} */
940
945
941
- #define RETURN_IF_ZERO_ARGS (num_args , type_spec , flags ) { \
946
+ #define RETURN_IF_ZERO_ARGS (num_args , type_spec , flags ) do { \
942
947
int __num_args = (num_args); \
943
- \
944
948
if (0 == (type_spec)[0] && 0 != __num_args && !(flags & ZEND_PARSE_PARAMS_QUIET)) { \
945
949
const char *__space; \
946
950
const char * __class_name = get_active_class_name(&__space); \
947
- zend_internal_type_error(ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects exactly 0 parameters, %d given", \
948
- __class_name, __space, \
949
- get_active_function_name(), __num_args); \
951
+ zend_bool throw_exception = \
952
+ ZEND_ARG_USES_STRICT_TYPES() || (flags & ZEND_PARSE_PARAMS_THROW); \
953
+ zend_internal_type_error(throw_exception, \
954
+ "%s%s%s() expects exactly 0 parameters, %d given", \
955
+ __class_name, __space, get_active_function_name(), __num_args); \
950
956
return FAILURE; \
951
- }\
952
- }
957
+ } \
958
+ } while(0)
953
959
954
960
ZEND_API int zend_parse_parameters_ex (int flags , int num_args , const char * type_spec , ...) /* {{{ */
955
961
{
@@ -982,6 +988,22 @@ ZEND_API int zend_parse_parameters(int num_args, const char *type_spec, ...) /*
982
988
}
983
989
/* }}} */
984
990
991
+ ZEND_API int zend_parse_parameters_throw (int num_args , const char * type_spec , ...) /* {{{ */
992
+ {
993
+ va_list va ;
994
+ int retval ;
995
+ int flags = ZEND_PARSE_PARAMS_THROW ;
996
+
997
+ RETURN_IF_ZERO_ARGS (num_args , type_spec , flags );
998
+
999
+ va_start (va , type_spec );
1000
+ retval = zend_parse_va_args (num_args , type_spec , & va , flags );
1001
+ va_end (va );
1002
+
1003
+ return retval ;
1004
+ }
1005
+ /* }}} */
1006
+
985
1007
ZEND_API int zend_parse_method_parameters (int num_args , zval * this_ptr , const char * type_spec , ...) /* {{{ */
986
1008
{
987
1009
va_list va ;
0 commit comments