]> granicus.if.org Git - php/commitdiff
Support ZEND_PARSE_PARAMS_THROW in new ZPP API
authorSara Golemon <pollita@php.net>
Wed, 28 Dec 2016 19:14:43 +0000 (11:14 -0800)
committerSara Golemon <pollita@php.net>
Fri, 30 Dec 2016 02:26:19 +0000 (18:26 -0800)
Zend/zend_API.c
Zend/zend_API.h

index 5e81c42e186a910f54cf25142889c6a7a135571c..01a107f07443ef262d81875a6516248fcf3f8331 100644 (file)
@@ -202,13 +202,13 @@ ZEND_API char *zend_zval_type_name(const zval *arg) /* {{{ */
 }
 /* }}} */
 
-ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(int num_args, int min_num_args, int max_num_args) /* {{{ */
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(zend_bool throw_, int num_args, int min_num_args, int max_num_args) /* {{{ */
 {
        zend_function *active_function = EG(current_execute_data)->func;
        const char *class_name = active_function->common.scope ? ZSTR_VAL(active_function->common.scope->name) : "";
 
        zend_internal_argument_count_error(
-                               ZEND_ARG_USES_STRICT_TYPES(), 
+                               throw_ || ZEND_ARG_USES_STRICT_TYPES(),
                                "%s%s%s() expects %s %d parameter%s, %d given", 
                                class_name, \
                                class_name[0] ? "::" : "", \
@@ -220,7 +220,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(int num_
 }
 /* }}} */
 
-ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(int num, zend_expected_type expected_type, zval *arg) /* {{{ */
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(zend_bool throw_, int num, zend_expected_type expected_type, zval *arg) /* {{{ */
 {
        const char *space;
        const char *class_name = get_active_class_name(&space);
@@ -229,28 +229,28 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(int num, z
                NULL
        };
 
-       zend_internal_type_error(ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects parameter %d to be %s, %s given",
+       zend_internal_type_error(throw_ || ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects parameter %d to be %s, %s given",
                class_name, space, get_active_function_name(), num, expected_error[expected_type], zend_zval_type_name(arg));
 }
 /* }}} */
 
-ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(int num, char *name, zval *arg) /* {{{ */
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(zend_bool throw_, int num, char *name, zval *arg) /* {{{ */
 {
        const char *space;
        const char *class_name = get_active_class_name(&space);
 
-       zend_internal_type_error(ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects parameter %d to be %s, %s given",
+       zend_internal_type_error(throw_ || ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects parameter %d to be %s, %s given",
                class_name, space, get_active_function_name(), num, name, zend_zval_type_name(arg));
 }
 /* }}} */
 
-ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity, int num, char *error) /* {{{ */
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(zend_bool throw_, int severity, int num, char *error) /* {{{ */
 {
        const char *space;
        const char *class_name = get_active_class_name(&space);
 
        if (severity == E_WARNING) {
-               zend_internal_type_error(ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects parameter %d to be a valid callback, %s",
+               zend_internal_type_error(throw_ || ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects parameter %d to be a valid callback, %s",
                        class_name, space, get_active_function_name(), num, error);
        } else if (severity == E_ERROR) {
                zend_throw_error(zend_ce_type_error, "%s%s%s() expects parameter %d to be a valid callback, %s",
index 0e56025d51681384c29c294249ba21c30849fbd6..072729425d9a4d85f59fe7fafdf250c350a61e8c 100644 (file)
@@ -701,10 +701,10 @@ typedef enum _zend_expected_type {
        Z_EXPECTED_LAST
 } zend_expected_type;
 
-ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(int num_args, int min_num_args, int max_num_args);
-ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(int num, zend_expected_type expected_type, zval *arg);
-ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(int num, char *name, zval *arg);
-ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity, int num, char *error);
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(zend_bool throw_, int num_args, int min_num_args, int max_num_args);
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(zend_bool throw_, int num, zend_expected_type expected_type, zval *arg);
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(zend_bool throw_, int num, char *name, zval *arg);
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(zend_bool throw_, int severity, int num, char *error);
 
 #define ZPP_ERROR_OK             0
 #define ZPP_ERROR_FAILURE        1
@@ -738,7 +738,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity, in
                            (UNEXPECTED(_num_args > _max_num_args) && \
                             EXPECTED(_max_num_args >= 0))) { \
                                if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
-                                       zend_wrong_parameters_count_error(_num_args, _min_num_args, _max_num_args); \
+                                       zend_wrong_parameters_count_error(_flags & ZEND_PARSE_PARAMS_THROW, _num_args, _min_num_args, _max_num_args); \
                                } \
                                error_code = ZPP_ERROR_FAILURE; \
                                break; \
@@ -754,11 +754,11 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity, in
                if (UNEXPECTED(error_code != ZPP_ERROR_OK)) { \
                        if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
                                if (error_code == ZPP_ERROR_WRONG_CALLBACK) { \
-                                       zend_wrong_callback_error(E_WARNING, _i, _error); \
+                                       zend_wrong_callback_error(_flags & ZEND_PARSE_PARAMS_THROW, E_WARNING, _i, _error); \
                                } else if (error_code == ZPP_ERROR_WRONG_CLASS) { \
-                                       zend_wrong_parameter_class_error(_i, _error, _arg); \
+                                       zend_wrong_parameter_class_error(_flags & ZEND_PARSE_PARAMS_THROW, _i, _error, _arg); \
                                } else if (error_code == ZPP_ERROR_WRONG_ARG) { \
-                                       zend_wrong_parameter_type_error(_i, _expected_type, _arg); \
+                                       zend_wrong_parameter_type_error(_flags & ZEND_PARSE_PARAMS_THROW, _i, _expected_type, _arg); \
                                } \
                        } \
                        failure; \
@@ -858,7 +858,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity, in
                                break; \
                        } \
                } else if (UNEXPECTED(_error != NULL)) { \
-                       zend_wrong_callback_error(E_DEPRECATED, _i, _error); \
+                       zend_wrong_callback_error(_flags & ZEND_PARSE_PARAMS_THROW, E_DEPRECATED, _i, _error); \
                }
 
 #define Z_PARAM_FUNC(dest_fci, dest_fcc) \