]> granicus.if.org Git - php/commitdiff
Make zpp failures always throw, independent of strict_types
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 5 Feb 2019 09:07:07 +0000 (10:07 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 11 Mar 2019 10:32:20 +0000 (11:32 +0100)
Previously zend_parse_parameters (and FastZPP) would handle invalid
arguments depending on strict_types: With strict_types=1, a TypeError
is thrown, with strict_types=0 a warning is thrown and (usually) NULL
is returned. Additionally, some functions (constructors always and
other methods sometimes) opt-it to throwing regardless of strict_types.

This commit changes zpp to always generate a TypeError exception in
PHP 8.

22 files changed:
Zend/tests/004.phpt
Zend/tests/005.phpt
Zend/tests/006.phpt
Zend/tests/008.phpt
Zend/zend.c
Zend/zend.h
Zend/zend_API.c
Zend/zend_API.h
Zend/zend_execute.c
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
ext/date/php_date.c
ext/fileinfo/fileinfo.c
ext/intl/calendar/gregoriancalendar_methods.cpp
ext/intl/collator/collator_create.c
ext/intl/dateformat/dateformat_create.cpp
ext/intl/formatter/formatter_main.c
ext/intl/msgformat/msgformat.c
ext/intl/resourcebundle/resourcebundle_class.c
ext/pdo/pdo_dbh.c
ext/standard/random.c
ext/standard/streamsfuncs.c

index 179684d076737029266229a494967d17534edda6..2f733f1bd886ba361cd9c3d034e3a2da7f83c2ff 100644 (file)
@@ -3,7 +3,6 @@ strncmp() tests
 --FILE--
 <?php
 
-var_dump(strncmp("", ""));
 var_dump(strncmp("", "", 100));
 var_dump(strncmp("aef", "dfsgbdf", -1));
 var_dump(strncmp("fghjkl", "qwer", 0));
@@ -13,8 +12,6 @@ var_dump(strncmp("qwerty", "qwerty123", 7));
 echo "Done\n";
 ?>
 --EXPECTF--
-Warning: strncmp() expects exactly 3 parameters, 2 given in %s on line %d
-NULL
 int(0)
 
 Warning: Length must be greater than or equal to 0 in %s on line %d
index 6ad1b0f63d250209f1667ea68fda039b5fb0a03e..f4abfb6c51ef813718b3e8bcf46cfaad7b67711a 100644 (file)
@@ -3,7 +3,6 @@ strcasecmp() tests
 --FILE--
 <?php
 
-var_dump(strcasecmp(""));
 var_dump(strcasecmp("", ""));
 var_dump(strcasecmp("aef", "dfsgbdf"));
 var_dump(strcasecmp("qwe", "qwer"));
@@ -15,8 +14,6 @@ var_dump(strcasecmp("01", "01"));
 echo "Done\n";
 ?>
 --EXPECTF--
-Warning: strcasecmp() expects exactly 2 parameters, 1 given in %s on line %d
-NULL
 int(0)
 int(-3)
 int(-1)
index 64c74ff1344429d5d7a12d4e50898746a226c7c1..12907fd36eea84aa6e2a31473052d1bcb3de41d4 100644 (file)
@@ -3,7 +3,6 @@ strncasecmp() tests
 --FILE--
 <?php
 
-var_dump(strncasecmp(""));
 var_dump(strncasecmp("", "", -1));
 var_dump(strncasecmp("aef", "dfsgbdf", 0));
 var_dump(strncasecmp("aef", "dfsgbdf", 10));
@@ -16,9 +15,6 @@ var_dump(strncasecmp("01", "01", 1000));
 echo "Done\n";
 ?>
 --EXPECTF--
-Warning: strncasecmp() expects exactly 3 parameters, 1 given in %s on line %d
-NULL
-
 Warning: Length must be greater than or equal to 0 in %s on line %d
 bool(false)
 int(0)
index cacba06370e9db9dd9051ce5133a28bf5e7f79b7..6f885c0dc58d54361370dc7a09f5bad7fb6e84cf 100644 (file)
@@ -3,12 +3,13 @@ define() tests
 --FILE--
 <?php
 
-var_dump(define());
-var_dump(define("TRUE"));
-var_dump(define("TRUE", 1));
-var_dump(define("TRUE", 1, array(1)));
+try {
+    var_dump(define(array(1,2,3,4,5), 1));
+} catch (TypeError $e) {
+    echo "TypeError: ", $e->getMessage(), "\n";
+}
 
-var_dump(define(array(1,2,3,4,5), 1));
+var_dump(define("TRUE", 1));
 var_dump(define(" ", 1));
 var_dump(define("[[[", 2));
 var_dump(define("test const", 3));
@@ -24,20 +25,10 @@ var_dump(constant("test const"));
 echo "Done\n";
 ?>
 --EXPECTF--
-Warning: define() expects at least 2 parameters, 0 given in %s on line %d
-NULL
-
-Warning: define() expects at least 2 parameters, 1 given in %s on line %d
-NULL
+TypeError: define() expects parameter 1 to be string, array given
 
 Notice: Constant TRUE already defined in %s on line %d
 bool(false)
-
-Warning: define() expects parameter 3 to be bool, array given in %s on line %d
-NULL
-
-Warning: define() expects parameter 1 to be string, array given in %s on line %d
-NULL
 bool(true)
 bool(true)
 bool(true)
index 22c9db203a5a1afb0c19ab948cfad04e5d29fff3..1ad1e8cfc66cc57a59546c53f9eb3b3e8a47ca72 100644 (file)
@@ -1528,35 +1528,14 @@ ZEND_API ZEND_COLD void zend_type_error(const char *format, ...) /* {{{ */
        va_end(va);
 } /* }}} */
 
-ZEND_API ZEND_COLD void zend_internal_type_error(zend_bool throw_exception, const char *format, ...) /* {{{ */
+ZEND_API ZEND_COLD void zend_argument_count_error(const char *format, ...) /* {{{ */
 {
        va_list va;
        char *message = NULL;
 
        va_start(va, format);
        zend_vspprintf(&message, 0, format, va);
-       if (throw_exception) {
-               zend_throw_exception(zend_ce_type_error, message, 0);
-       } else {
-               zend_error(E_WARNING, "%s", message);
-       }
-       efree(message);
-
-       va_end(va);
-} /* }}} */
-
-ZEND_API ZEND_COLD void zend_internal_argument_count_error(zend_bool throw_exception, const char *format, ...) /* {{{ */
-{
-       va_list va;
-       char *message = NULL;
-
-       va_start(va, format);
-       zend_vspprintf(&message, 0, format, va);
-       if (throw_exception) {
-               zend_throw_exception(zend_ce_argument_count_error, message, 0);
-       } else {
-               zend_error(E_WARNING, "%s", message);
-       }
+       zend_throw_exception(zend_ce_argument_count_error, message, 0);
        efree(message);
 
        va_end(va);
index 7313579e6517388fc0f759aa3c1a866f18dbc9b2..a55d45903e5689b9a53e9736911c6f048938ff88 100644 (file)
@@ -303,8 +303,7 @@ extern ZEND_API void (*zend_post_shutdown_cb)(void);
 ZEND_API ZEND_COLD void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
 ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
 ZEND_API ZEND_COLD void zend_type_error(const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2);
-ZEND_API ZEND_COLD void zend_internal_type_error(zend_bool throw_exception, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
-ZEND_API ZEND_COLD void zend_internal_argument_count_error(zend_bool throw_exception, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
+ZEND_API ZEND_COLD void zend_argument_count_error(const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2);
 
 ZEND_COLD void zenderror(const char *error);
 
index 68863889535cb8cb3b90ebadca525c193b35c4cc..4a31914e1a552c7aee77227385d8be21eee210af 100644 (file)
@@ -90,7 +90,7 @@ ZEND_API ZEND_COLD void zend_wrong_param_count(void) /* {{{ */
        const char *space;
        const char *class_name = get_active_class_name(&space);
 
-       zend_internal_argument_count_error(ZEND_ARG_USES_STRICT_TYPES(), "Wrong parameter count for %s%s%s()", class_name, space, get_active_function_name());
+       zend_argument_count_error("Wrong parameter count for %s%s%s()", class_name, space, get_active_function_name());
 }
 /* }}} */
 
@@ -173,28 +173,7 @@ ZEND_API ZEND_COLD int ZEND_FASTCALL zend_wrong_parameters_none_error(void) /* {
        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(),
-                               "%s%s%s() expects %s %d parameter%s, %d given",
-                               class_name, \
-                               class_name[0] ? "::" : "", \
-                               ZSTR_VAL(active_function->common.function_name),
-                               "exactly",
-                               0,
-                               "s",
-                               num_args);
-       return FAILURE;
-}
-/* }}} */
-
-ZEND_API ZEND_COLD int ZEND_FASTCALL zend_wrong_parameters_none_exception(void) /* {{{ */
-{
-       int num_args = ZEND_CALL_NUM_ARGS(EG(current_execute_data));
-       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(
-                               1,
+       zend_argument_count_error(
                                "%s%s%s() expects %s %d parameter%s, %d given",
                                class_name, \
                                class_name[0] ? "::" : "", \
@@ -213,27 +192,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(int min_
        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(),
-                               "%s%s%s() expects %s %d parameter%s, %d given",
-                               class_name, \
-                               class_name[0] ? "::" : "", \
-                               ZSTR_VAL(active_function->common.function_name),
-                               min_num_args == max_num_args ? "exactly" : num_args < min_num_args ? "at least" : "at most",
-                               num_args < min_num_args ? min_num_args : max_num_args,
-                               (num_args < min_num_args ? min_num_args : max_num_args) == 1 ? "" : "s",
-                               num_args);
-}
-/* }}} */
-
-ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_exception(int min_num_args, int max_num_args) /* {{{ */
-{
-       int num_args = ZEND_CALL_NUM_ARGS(EG(current_execute_data));
-       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(
-                               1,
+       zend_argument_count_error(
                                "%s%s%s() expects %s %d parameter%s, %d given",
                                class_name, \
                                class_name[0] ? "::" : "", \
@@ -254,21 +213,7 @@ 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",
-               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_type_exception(int num, zend_expected_type expected_type, zval *arg) /* {{{ */
-{
-       const char *space;
-       const char *class_name = get_active_class_name(&space);
-       static const char * const expected_error[] = {
-               Z_EXPECTED_TYPES(Z_EXPECTED_TYPE_STR)
-               NULL
-       };
-
-       zend_internal_type_error(1, "%s%s%s() expects parameter %d to be %s, %s given",
+       zend_type_error("%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));
 }
 /* }}} */
@@ -278,17 +223,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(int num,
        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",
-               class_name, space, get_active_function_name(), num, name, zend_zval_type_name(arg));
-}
-/* }}} */
-
-ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_exception(int num, char *name, zval *arg) /* {{{ */
-{
-       const char *space;
-       const char *class_name = get_active_class_name(&space);
-
-       zend_internal_type_error(1, "%s%s%s() expects parameter %d to be %s, %s given",
+       zend_type_error("%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));
 }
 /* }}} */
@@ -298,18 +233,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int num, char *e
        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 a valid callback, %s",
-               class_name, space, get_active_function_name(), num, error);
-       efree(error);
-}
-/* }}} */
-
-ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_exception(int num, char *error) /* {{{ */
-{
-       const char *space;
-       const char *class_name = get_active_class_name(&space);
-
-       zend_internal_type_error(1, "%s%s%s() expects parameter %d to be a valid callback, %s",
+       zend_type_error("%s%s%s() expects parameter %d to be a valid callback, %s",
                class_name, space, get_active_function_name(), num, error);
        efree(error);
 }
@@ -330,7 +254,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pc
                        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 a class name derived from %s, '%s' given",
+                       zend_type_error("%s%s%s() expects parameter %d to be a class name derived from %s, '%s' given",
                                class_name, space, get_active_function_name(), num,
                                ZSTR_VAL(ce_base->name), Z_STRVAL_P(arg));
                        *pce = NULL;
@@ -341,7 +265,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pc
                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 a valid class name, '%s' given",
+               zend_type_error("%s%s%s() expects parameter %d to be a valid class name, '%s' given",
                        class_name, space, get_active_function_name(), num,
                        Z_STRVAL_P(arg));
                return 0;
@@ -803,16 +727,13 @@ static int zend_parse_arg(int arg_num, zval *arg, va_list *va, const char **spec
                if (!(flags & ZEND_PARSE_PARAMS_QUIET) && (*expected_type || error)) {
                        const char *space;
                        const char *class_name = get_active_class_name(&space);
-                       zend_bool throw_exception =
-                               ZEND_ARG_USES_STRICT_TYPES() || (flags & ZEND_PARSE_PARAMS_THROW);
 
                        if (error) {
-                               zend_internal_type_error(throw_exception, "%s%s%s() expects parameter %d %s",
+                               zend_type_error("%s%s%s() expects parameter %d %s",
                                                class_name, space, get_active_function_name(), arg_num, error);
                                efree(error);
                        } else {
-                               zend_internal_type_error(throw_exception,
-                                               "%s%s%s() expects parameter %d to be %s, %s given",
+                               zend_type_error("%s%s%s() expects parameter %d to be %s, %s given",
                                                class_name, space, get_active_function_name(), arg_num, expected_type,
                                                zend_zval_type_name(arg));
                        }
@@ -919,8 +840,7 @@ static int zend_parse_va_args(int num_args, const char *type_spec, va_list *va,
                if (!(flags & ZEND_PARSE_PARAMS_QUIET)) {
                        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_bool throw_exception = ZEND_ARG_USES_STRICT_TYPES() || (flags & ZEND_PARSE_PARAMS_THROW);
-                       zend_internal_argument_count_error(throw_exception, "%s%s%s() expects %s %d parameter%s, %d given",
+                       zend_argument_count_error("%s%s%s() expects %s %d parameter%s, %d given",
                                        class_name,
                                        class_name[0] ? "::" : "",
                                        ZSTR_VAL(active_function->common.function_name),
@@ -1013,7 +933,7 @@ ZEND_API int zend_parse_parameters_throw(int num_args, const char *type_spec, ..
 {
        va_list va;
        int retval;
-       int flags = ZEND_PARSE_PARAMS_THROW;
+       int flags = 0;
 
        va_start(va, type_spec);
        retval = zend_parse_va_args(num_args, type_spec, &va, flags);
index dc8b2dc956968335e30357ae7ae62e133b868433..04cd0fbf3c536f7d5553a1a422a29e92089ad4d4 100644 (file)
@@ -248,12 +248,12 @@ ZEND_API int zend_copy_parameters_array(int param_count, zval *argument_array);
 #define zend_parse_parameters_none() \
        (EXPECTED(ZEND_NUM_ARGS() == 0) ? SUCCESS : zend_wrong_parameters_none_error())
 #define zend_parse_parameters_none_throw() \
-       (EXPECTED(ZEND_NUM_ARGS() == 0) ? SUCCESS : zend_wrong_parameters_none_exception())
+       zend_parse_parameters_none()
 
 /* Parameter parsing API -- andrei */
 
+#define ZEND_PARSE_PARAMS_THROW 0 /* No longer used, zpp always uses exceptions */
 #define ZEND_PARSE_PARAMS_QUIET (1<<1)
-#define ZEND_PARSE_PARAMS_THROW (1<<2)
 ZEND_API int zend_parse_parameters(int num_args, const char *type_spec, ...);
 ZEND_API int zend_parse_parameters_ex(int flags, int num_args, const char *type_spec, ...);
 ZEND_API int zend_parse_parameters_throw(int num_args, const char *type_spec, ...);
@@ -957,15 +957,10 @@ typedef enum _zend_expected_type {
 } zend_expected_type;
 
 ZEND_API ZEND_COLD int  ZEND_FASTCALL zend_wrong_parameters_none_error(void);
-ZEND_API ZEND_COLD int  ZEND_FASTCALL zend_wrong_parameters_none_exception(void);
 ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(int min_num_args, int max_num_args);
-ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_exception(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_type_exception(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_parameter_class_exception(int num, char *name, zval *arg);
 ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int num, char *error);
-ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_exception(int num, char *error);
 
 #define ZPP_ERROR_OK             0
 #define ZPP_ERROR_FAILURE        1
@@ -999,11 +994,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_exception(int num, cha
                            (UNEXPECTED(_num_args > _max_num_args) && \
                             EXPECTED(_max_num_args >= 0))) { \
                                if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
-                                       if (_flags & ZEND_PARSE_PARAMS_THROW) { \
-                                               zend_wrong_parameters_count_exception(_min_num_args, _max_num_args); \
-                                       } else { \
-                                               zend_wrong_parameters_count_error(_min_num_args, _max_num_args); \
-                                       } \
+                                       zend_wrong_parameters_count_error(_min_num_args, _max_num_args); \
                                } \
                                _error_code = ZPP_ERROR_FAILURE; \
                                break; \
@@ -1026,23 +1017,11 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_exception(int num, cha
                if (UNEXPECTED(_error_code != ZPP_ERROR_OK)) { \
                        if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
                                if (_error_code == ZPP_ERROR_WRONG_CALLBACK) { \
-                                       if (_flags & ZEND_PARSE_PARAMS_THROW) { \
-                                               zend_wrong_callback_exception(_i, _error); \
-                                       } else { \
-                                               zend_wrong_callback_error(_i, _error); \
-                                       } \
+                                       zend_wrong_callback_error(_i, _error); \
                                } else if (_error_code == ZPP_ERROR_WRONG_CLASS) { \
-                                       if (_flags & ZEND_PARSE_PARAMS_THROW) { \
-                                               zend_wrong_parameter_class_exception(_i, _error, _arg); \
-                                       } else { \
-                                               zend_wrong_parameter_class_error(_i, _error, _arg); \
-                                       } \
+                                       zend_wrong_parameter_class_error(_i, _error, _arg); \
                                } else if (_error_code == ZPP_ERROR_WRONG_ARG) { \
-                                       if (_flags & ZEND_PARSE_PARAMS_THROW) { \
-                                               zend_wrong_parameter_type_exception(_i, _expected_type, _arg); \
-                                       } else { \
-                                               zend_wrong_parameter_type_error(_i, _expected_type, _arg); \
-                                       } \
+                                       zend_wrong_parameter_type_error(_i, _expected_type, _arg); \
                                } \
                        } \
                        failure; \
index 1dc9fe97fbe63f4fff3f121649966bd20885b385..fb19a1ac9134cf61688d479d020cd2068922343c 100644 (file)
@@ -2535,7 +2535,7 @@ static zend_never_inline uint32_t ZEND_FASTCALL zend_array_key_exists_slow(zval
                if (UNEXPECTED(Z_TYPE_INFO_P(subject) == IS_UNDEF)) {
                        ZVAL_UNDEFINED_OP2();
                }
-               zend_internal_type_error(EX_USES_STRICT_TYPES(), "array_key_exists() expects parameter 2 to be array, %s given", zend_get_type_by_const(Z_TYPE_P(subject)));
+               zend_type_error("array_key_exists() expects parameter 2 to be array, %s given", zend_get_type_by_const(Z_TYPE_P(subject)));
                return IS_NULL;
        }
 }
index 59bf5c1e2e33c6856a11d96ac0b5349da53fef8a..6cf53691863ac2c74779a2b1d52f856266c60283 100644 (file)
@@ -3744,15 +3744,10 @@ ZEND_VM_HANDLER(118, ZEND_INIT_USER_CALL, CONST, CONST|TMPVAR|CV, NUM)
                        init_func_run_time_cache(&func->op_array);
                }
        } else {
-               zend_internal_type_error(EX_USES_STRICT_TYPES(), "%s() expects parameter 1 to be a valid callback, %s", Z_STRVAL_P(RT_CONSTANT(opline, opline->op1)), error);
+               zend_type_error("%s() expects parameter 1 to be a valid callback, %s", Z_STRVAL_P(RT_CONSTANT(opline, opline->op1)), error);
                efree(error);
                FREE_OP2();
-               if (UNEXPECTED(EG(exception))) {
-                       HANDLE_EXCEPTION();
-               }
-               func = (zend_function*)&zend_pass_function;
-               called_scope = NULL;
-               object = NULL;
+               HANDLE_EXCEPTION();
        }
 
        call = zend_vm_stack_push_call_frame(call_info,
@@ -4919,17 +4914,16 @@ ZEND_VM_HANDLER(119, ZEND_SEND_ARRAY, ANY, ANY, NUM)
                                ZEND_VM_C_GOTO(send_array);
                        }
                }
-               zend_internal_type_error(EX_USES_STRICT_TYPES(), "call_user_func_array() expects parameter 2 to be array, %s given", zend_get_type_by_const(Z_TYPE_P(args)));
+               zend_type_error("call_user_func_array() expects parameter 2 to be array, %s given", zend_get_type_by_const(Z_TYPE_P(args)));
                if (ZEND_CALL_INFO(EX(call)) & ZEND_CALL_CLOSURE) {
                        OBJ_RELEASE(ZEND_CLOSURE_OBJECT(EX(call)->func));
                }
                if (Z_TYPE(EX(call)->This) == IS_OBJECT) {
                        OBJ_RELEASE(Z_OBJ(EX(call)->This));
                }
-               EX(call)->func = (zend_function*)&zend_pass_function;
-               Z_OBJ(EX(call)->This) = NULL;
-               ZEND_SET_CALL_INFO(EX(call), 0, ZEND_CALL_INFO(EX(call)) & ~ZEND_CALL_RELEASE_THIS);
                FREE_UNFETCHED_OP2();
+               FREE_OP1();
+               HANDLE_EXCEPTION();
        } else {
                uint32_t arg_num;
                HashTable *ht;
@@ -7797,8 +7791,8 @@ ZEND_VM_COLD_CONST_HANDLER(121, ZEND_STRLEN, CONST|TMPVAR|CV, ANY)
                                }
                                zval_ptr_dtor(&tmp);
                        }
-                       zend_internal_type_error(strict, "strlen() expects parameter 1 to be string, %s given", zend_get_type_by_const(Z_TYPE_P(value)));
-                       ZVAL_NULL(EX_VAR(opline->result.var));
+                       zend_type_error("strlen() expects parameter 1 to be string, %s given", zend_get_type_by_const(Z_TYPE_P(value)));
+                       ZVAL_UNDEF(EX_VAR(opline->result.var));
                } while (0);
        }
        FREE_OP1();
index 576872d18b924ccfc8a743aaa288d6f6b873b52d..9306a1b58f8e62a069bcc498e17dab9c3b61b6b3 100644 (file)
@@ -1673,17 +1673,16 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_O
                                goto send_array;
                        }
                }
-               zend_internal_type_error(EX_USES_STRICT_TYPES(), "call_user_func_array() expects parameter 2 to be array, %s given", zend_get_type_by_const(Z_TYPE_P(args)));
+               zend_type_error("call_user_func_array() expects parameter 2 to be array, %s given", zend_get_type_by_const(Z_TYPE_P(args)));
                if (ZEND_CALL_INFO(EX(call)) & ZEND_CALL_CLOSURE) {
                        OBJ_RELEASE(ZEND_CLOSURE_OBJECT(EX(call)->func));
                }
                if (Z_TYPE(EX(call)->This) == IS_OBJECT) {
                        OBJ_RELEASE(Z_OBJ(EX(call)->This));
                }
-               EX(call)->func = (zend_function*)&zend_pass_function;
-               Z_OBJ(EX(call)->This) = NULL;
-               ZEND_SET_CALL_INFO(EX(call), 0, ZEND_CALL_INFO(EX(call)) & ~ZEND_CALL_RELEASE_THIS);
                FREE_UNFETCHED_OP(opline->op2_type, opline->op2.var);
+               FREE_OP(free_op1);
+               HANDLE_EXCEPTION();
        } else {
                uint32_t arg_num;
                HashTable *ht;
@@ -3971,8 +3970,8 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_STRLEN_SPEC_CONST
                                }
                                zval_ptr_dtor(&tmp);
                        }
-                       zend_internal_type_error(strict, "strlen() expects parameter 1 to be string, %s given", zend_get_type_by_const(Z_TYPE_P(value)));
-                       ZVAL_NULL(EX_VAR(opline->result.var));
+                       zend_type_error("strlen() expects parameter 1 to be string, %s given", zend_get_type_by_const(Z_TYPE_P(value)));
+                       ZVAL_UNDEF(EX_VAR(opline->result.var));
                } while (0);
        }
 
@@ -5597,15 +5596,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_CONS
                        init_func_run_time_cache(&func->op_array);
                }
        } else {
-               zend_internal_type_error(EX_USES_STRICT_TYPES(), "%s() expects parameter 1 to be a valid callback, %s", Z_STRVAL_P(RT_CONSTANT(opline, opline->op1)), error);
+               zend_type_error("%s() expects parameter 1 to be a valid callback, %s", Z_STRVAL_P(RT_CONSTANT(opline, opline->op1)), error);
                efree(error);
 
-               if (UNEXPECTED(EG(exception))) {
-                       HANDLE_EXCEPTION();
-               }
-               func = (zend_function*)&zend_pass_function;
-               called_scope = NULL;
-               object = NULL;
+               HANDLE_EXCEPTION();
        }
 
        call = zend_vm_stack_push_call_frame(call_info,
@@ -7827,15 +7821,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_TMPV
                        init_func_run_time_cache(&func->op_array);
                }
        } else {
-               zend_internal_type_error(EX_USES_STRICT_TYPES(), "%s() expects parameter 1 to be a valid callback, %s", Z_STRVAL_P(RT_CONSTANT(opline, opline->op1)), error);
+               zend_type_error("%s() expects parameter 1 to be a valid callback, %s", Z_STRVAL_P(RT_CONSTANT(opline, opline->op1)), error);
                efree(error);
                zval_ptr_dtor_nogc(free_op2);
-               if (UNEXPECTED(EG(exception))) {
-                       HANDLE_EXCEPTION();
-               }
-               func = (zend_function*)&zend_pass_function;
-               called_scope = NULL;
-               object = NULL;
+               HANDLE_EXCEPTION();
        }
 
        call = zend_vm_stack_push_call_frame(call_info,
@@ -10750,15 +10739,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_CV_H
                        init_func_run_time_cache(&func->op_array);
                }
        } else {
-               zend_internal_type_error(EX_USES_STRICT_TYPES(), "%s() expects parameter 1 to be a valid callback, %s", Z_STRVAL_P(RT_CONSTANT(opline, opline->op1)), error);
+               zend_type_error("%s() expects parameter 1 to be a valid callback, %s", Z_STRVAL_P(RT_CONSTANT(opline, opline->op1)), error);
                efree(error);
 
-               if (UNEXPECTED(EG(exception))) {
-                       HANDLE_EXCEPTION();
-               }
-               func = (zend_function*)&zend_pass_function;
-               called_scope = NULL;
-               object = NULL;
+               HANDLE_EXCEPTION();
        }
 
        call = zend_vm_stack_push_call_frame(call_info,
@@ -12998,8 +12982,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_STRLEN_SPEC_TMPVAR_HANDLER(ZEN
                                }
                                zval_ptr_dtor(&tmp);
                        }
-                       zend_internal_type_error(strict, "strlen() expects parameter 1 to be string, %s given", zend_get_type_by_const(Z_TYPE_P(value)));
-                       ZVAL_NULL(EX_VAR(opline->result.var));
+                       zend_type_error("strlen() expects parameter 1 to be string, %s given", zend_get_type_by_const(Z_TYPE_P(value)));
+                       ZVAL_UNDEF(EX_VAR(opline->result.var));
                } while (0);
        }
        zval_ptr_dtor_nogc(free_op1);
@@ -40871,8 +40855,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_STRLEN_SPEC_CV_HANDLER(ZEND_OP
                                }
                                zval_ptr_dtor(&tmp);
                        }
-                       zend_internal_type_error(strict, "strlen() expects parameter 1 to be string, %s given", zend_get_type_by_const(Z_TYPE_P(value)));
-                       ZVAL_NULL(EX_VAR(opline->result.var));
+                       zend_type_error("strlen() expects parameter 1 to be string, %s given", zend_get_type_by_const(Z_TYPE_P(value)));
+                       ZVAL_UNDEF(EX_VAR(opline->result.var));
                } while (0);
        }
 
index 0a8ccb574be71a1d4e35fe6fa443562babe6228b..d0267695f2f66e0ceb8a58b8887770e466a46a31 100644 (file)
@@ -2802,7 +2802,7 @@ PHP_METHOD(DateTime, __construct)
        size_t time_str_len = 0;
        zend_error_handling error_handling;
 
-       ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 0, 2)
+       ZEND_PARSE_PARAMETERS_START(0, 2)
                Z_PARAM_OPTIONAL
                Z_PARAM_STRING(time_str, time_str_len)
                Z_PARAM_OBJECT_OF_CLASS_EX(timezone_object, date_ce_timezone, 1, 0)
@@ -2824,7 +2824,7 @@ PHP_METHOD(DateTimeImmutable, __construct)
        size_t time_str_len = 0;
        zend_error_handling error_handling;
 
-       ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 0, 2)
+       ZEND_PARSE_PARAMETERS_START(0, 2)
                Z_PARAM_OPTIONAL
                Z_PARAM_STRING(time_str, time_str_len)
                Z_PARAM_OBJECT_OF_CLASS_EX(timezone_object, date_ce_timezone, 1, 0)
@@ -3829,7 +3829,7 @@ PHP_METHOD(DateTimeZone, __construct)
        php_timezone_obj *tzobj;
        zend_error_handling error_handling;
 
-       ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 1, 1)
+       ZEND_PARSE_PARAMETERS_START(1, 1)
                Z_PARAM_STR(tz)
        ZEND_PARSE_PARAMETERS_END();
 
@@ -4245,7 +4245,7 @@ PHP_METHOD(DateInterval, __construct)
        timelib_rel_time *reltime;
        zend_error_handling error_handling;
 
-       ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 1, 1)
+       ZEND_PARSE_PARAMETERS_START(1, 1)
                Z_PARAM_STR(interval_string)
        ZEND_PARSE_PARAMETERS_END();
 
index 57963146afe47c75b15c332f03824d5058d61365..6343b48aa9d4b145e0b34e80391b7f246b8eab7f 100644 (file)
@@ -292,9 +292,8 @@ PHP_FUNCTION(finfo_open)
        FILEINFO_DECLARE_INIT_OBJECT(object)
        char resolved_path[MAXPATHLEN];
        zend_error_handling zeh;
-       int flags = object ? ZEND_PARSE_PARAMS_THROW : 0;
 
-       if (zend_parse_parameters_ex(flags, ZEND_NUM_ARGS(), "|lp", &options, &file, &file_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lp", &options, &file, &file_len) == FAILURE) {
                RETURN_FALSE;
        }
 
index d96fffda6f7415883c01656ff1b8425f767c0aeb..ce70aaacd7d0f31b667c5a8c6ca112a328684eff 100644 (file)
@@ -56,7 +56,6 @@ static void _php_intlgregcal_constructor_body(
        zend_long               largs[6];
        UErrorCode      status          = U_ZERO_ERROR;
        int                     variant;
-  int zpp_flags = is_constructor ? ZEND_PARSE_PARAMS_THROW : 0;
        intl_error_reset(NULL);
 
        // parameter number validation / variant determination
@@ -86,7 +85,7 @@ static void _php_intlgregcal_constructor_body(
 
        // argument parsing
        if (variant <= 2) {
-               if (zend_parse_parameters_ex(zpp_flags, MIN(ZEND_NUM_ARGS(), 2),
+               if (zend_parse_parameters(MIN(ZEND_NUM_ARGS(), 2),
                                "|z!s!", &tz_object, &locale, &locale_len) == FAILURE) {
                        intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
                                "intlgregcal_create_instance: bad arguments", 0);
@@ -97,7 +96,7 @@ static void _php_intlgregcal_constructor_body(
                        return;
                }
        }
-       if (variant > 2 && zend_parse_parameters_ex(zpp_flags, ZEND_NUM_ARGS(),
+       if (variant > 2 && zend_parse_parameters(ZEND_NUM_ARGS(),
                        "lll|lll", &largs[0], &largs[1], &largs[2], &largs[3], &largs[4],
                        &largs[5]) == FAILURE) {
                intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
index cb2ff183e22fc578b37e66780152fed3ae0bd5bf..e674e90f89f4aa02682bb334b0e3499479c26ae4 100644 (file)
@@ -31,12 +31,11 @@ static int collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
        size_t           locale_len = 0;
        zval*            object;
        Collator_object* co;
-       int zpp_flags = is_constructor ? ZEND_PARSE_PARAMS_THROW : 0;
 
        intl_error_reset( NULL );
        object = return_value;
        /* Parse parameters. */
-       if( zend_parse_parameters_ex( zpp_flags, ZEND_NUM_ARGS(), "s",
+       if( zend_parse_parameters( ZEND_NUM_ARGS(), "s",
                &locale, &locale_len ) == FAILURE )
        {
                intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
index 9268b9ddf5d3ddda650c11ccc59a667ea3f6190d..7406ca38ea019667654d0dfb5eedecf700e5da8e 100644 (file)
@@ -65,12 +65,11 @@ static int datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
        UChar*      svalue              = NULL;         /* UTF-16 pattern_str */
        int32_t     slength             = 0;
        IntlDateFormatter_object* dfo;
-       int zpp_flags = is_constructor ? ZEND_PARSE_PARAMS_THROW : 0;
 
        intl_error_reset(NULL);
        object = return_value;
        /* Parse parameters. */
-       if (zend_parse_parameters_ex(zpp_flags, ZEND_NUM_ARGS(), "sll|zzs",
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "sll|zzs",
                        &locale_str, &locale_len, &date_type, &time_type, &timezone_zv,
                        &calendar_zv, &pattern_str, &pattern_str_len) == FAILURE) {
                intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: "
index a4671c093ae7b4c676038d6147e04e62cee06474..561d68addf9131e98e502ad0d751caec5bb40aae 100644 (file)
@@ -33,11 +33,10 @@ static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
        zend_long   style;
        UChar*      spattern     = NULL;
        int32_t     spattern_len = 0;
-       int         zpp_flags = is_constructor ? ZEND_PARSE_PARAMS_THROW : 0;
        FORMATTER_METHOD_INIT_VARS;
 
        /* Parse parameters. */
-       if( zend_parse_parameters_ex( zpp_flags, ZEND_NUM_ARGS(), "sl|s",
+       if( zend_parse_parameters( ZEND_NUM_ARGS(), "sl|s",
                &locale, &locale_len, &style, &pattern, &pattern_len ) == FAILURE )
        {
                intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
index 2439b5855a63c47724ac198d1152d00b087e09e2..f9e30f861673432f258fb331dd3e699612b7e07f 100644 (file)
@@ -36,12 +36,11 @@ static int msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
        int         spattern_len = 0;
        zval*       object;
        MessageFormatter_object* mfo;
-       int zpp_flags = is_constructor ? ZEND_PARSE_PARAMS_THROW : 0;
        intl_error_reset( NULL );
 
        object = return_value;
        /* Parse parameters. */
-       if( zend_parse_parameters_ex( zpp_flags, ZEND_NUM_ARGS(), "ss",
+       if( zend_parse_parameters( ZEND_NUM_ARGS(), "ss",
                &locale, &locale_len, &pattern, &pattern_len ) == FAILURE )
        {
                intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
index 9b9cb9f9a62de9f64ef84c1d2d31a5702732205e..2b7d3d8e133d8e57a6b3c3a7ac46c1eeada871cf 100644 (file)
@@ -82,14 +82,13 @@ static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constr
        const char *locale;
        size_t          locale_len = 0;
        zend_bool       fallback = 1;
-       int         zpp_flags = is_constructor ? ZEND_PARSE_PARAMS_THROW : 0;
 
        zval                  *object = return_value;
        ResourceBundle_object *rb = Z_INTL_RESOURCEBUNDLE_P( object );
 
        intl_error_reset( NULL );
 
-       if( zend_parse_parameters_ex( zpp_flags, ZEND_NUM_ARGS(), "s!s!|b",
+       if( zend_parse_parameters( ZEND_NUM_ARGS(), "s!s!|b",
                &locale, &locale_len, &bundlename, &bundlename_len, &fallback ) == FAILURE )
        {
                intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
index 5805a0568650012f3f428623702003df89401b9c..41d7df817dae707ea8a2798c28897ea3b159e482 100644 (file)
@@ -209,7 +209,7 @@ static PHP_METHOD(PDO, dbh_constructor)
        int call_factory = 1;
        zend_error_handling zeh;
 
-       ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 1, 4)
+       ZEND_PARSE_PARAMETERS_START(1, 4)
                Z_PARAM_STRING(data_source, data_source_len)
                Z_PARAM_OPTIONAL
                Z_PARAM_STRING_EX(username, usernamelen, 1, 0)
index f6568a658fd8e244a3e8bcf54a0cee28934baa37..01d99a5eefcef33257d10ac218ddb5a8cd02a279 100644 (file)
@@ -194,7 +194,7 @@ PHP_FUNCTION(random_bytes)
        zend_long size;
        zend_string *bytes;
 
-       ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 1, 1)
+       ZEND_PARSE_PARAMETERS_START(1, 1)
                Z_PARAM_LONG(size)
        ZEND_PARSE_PARAMETERS_END();
 
@@ -268,7 +268,7 @@ PHP_FUNCTION(random_int)
        zend_long max;
        zend_long result;
 
-       ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 2, 2)
+       ZEND_PARSE_PARAMETERS_START(2, 2)
                Z_PARAM_LONG(min)
                Z_PARAM_LONG(max)
        ZEND_PARSE_PARAMETERS_END();
index 9b6e05de657492b42ec64e73318922c74648159b..8fe7b2d2253b84c9217d266c5ebc11fac664e5a9 100644 (file)
@@ -1671,8 +1671,7 @@ PHP_FUNCTION(sapi_windows_vt100_support)
                php_stream_cast(stream, PHP_STREAM_AS_FD, (void*)&fileno, 0);
        }
        else {
-               zend_internal_type_error(
-                       ZEND_ARG_USES_STRICT_TYPES(),
+               zend_type_error(
                        "%s() was not able to analyze the specified stream",
                        get_active_function_name()
                );