-
Notifications
You must be signed in to change notification settings - Fork 8k
Add zend_argument_type_error_ex, zend_argument_error_ex #21829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -374,7 +374,9 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_unexpected_extra_named_error(void) | |||||||||||||||||
| ); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_error_variadic(zend_class_entry *error_ce, uint32_t arg_num, const char *format, va_list va) /* {{{ */ | ||||||||||||||||||
| ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_error_variadic( | ||||||||||||||||||
| const zend_function *function, uint32_t arg_num, | ||||||||||||||||||
| zend_class_entry *error_ce, const char *format, va_list va) | ||||||||||||||||||
|
Comment on lines
+377
to
+379
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| { | ||||||||||||||||||
| zend_string *func_name; | ||||||||||||||||||
| const char *arg_name; | ||||||||||||||||||
|
|
@@ -383,8 +385,8 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_error_variadic(zend_class_en | |||||||||||||||||
| return; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| func_name = get_active_function_or_method_name(); | ||||||||||||||||||
| arg_name = get_active_function_arg_name(arg_num); | ||||||||||||||||||
| func_name = get_function_or_method_name(function); | ||||||||||||||||||
| arg_name = get_function_arg_name(function, arg_num); | ||||||||||||||||||
|
|
||||||||||||||||||
| zend_vspprintf(&message, 0, format, va); | ||||||||||||||||||
| zend_throw_error(error_ce, "%s(): Argument #%d%s%s%s %s", | ||||||||||||||||||
|
|
@@ -394,34 +396,57 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_error_variadic(zend_class_en | |||||||||||||||||
| efree(message); | ||||||||||||||||||
| zend_string_release(func_name); | ||||||||||||||||||
| } | ||||||||||||||||||
| /* }}} */ | ||||||||||||||||||
|
|
||||||||||||||||||
| ZEND_API ZEND_COLD void zend_argument_error_ex(const zend_function *function, | ||||||||||||||||||
| uint32_t arg_num, zend_class_entry *error_ce, const char *format, ...) | ||||||||||||||||||
|
Comment on lines
+400
to
+401
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm only noticing now that
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you explain why? Is it to match the order of the non-
Looking at other format-and-throw functions, extra args tend to be grouped in between zend_object *zend_throw_exception(zend_class_entry *exception_ce, const char *message, zend_long code);
zend_object *zend_throw_exception_ex(zend_class_entry *exception_ce, zend_long code, const char *format, ...);void ZEND_FASTCALL zend_argument_error_variadic(zend_class_entry *error_ce, uint32_t arg_num, const char *format, va_list va);
void zend_argument_error(zend_class_entry *error_ce, uint32_t arg_num, const char *format, ...);What do you think of this?
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, my motivation was making this consistent with the existing non- |
||||||||||||||||||
| { | ||||||||||||||||||
| va_list va; | ||||||||||||||||||
|
|
||||||||||||||||||
| va_start(va, format); | ||||||||||||||||||
| zend_argument_error_variadic(function, arg_num, error_ce, format, va); | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| va_end(va); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| ZEND_API ZEND_COLD void zend_argument_error(zend_class_entry *error_ce, uint32_t arg_num, const char *format, ...) /* {{{ */ | ||||||||||||||||||
| { | ||||||||||||||||||
| va_list va; | ||||||||||||||||||
| const zend_function *function = zend_active_function(); | ||||||||||||||||||
|
|
||||||||||||||||||
| va_start(va, format); | ||||||||||||||||||
| zend_argument_error_variadic(error_ce, arg_num, format, va); | ||||||||||||||||||
| zend_argument_error_variadic(function, arg_num, error_ce, format, va); | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| va_end(va); | ||||||||||||||||||
| } | ||||||||||||||||||
| /* }}} */ | ||||||||||||||||||
|
|
||||||||||||||||||
| ZEND_API ZEND_COLD void zend_argument_type_error_ex( | ||||||||||||||||||
| const zend_function *function, uint32_t arg_num, | ||||||||||||||||||
| const char *format, ...) | ||||||||||||||||||
| { | ||||||||||||||||||
| va_list va; | ||||||||||||||||||
|
|
||||||||||||||||||
| va_start(va, format); | ||||||||||||||||||
| zend_argument_error_variadic(function, arg_num, zend_ce_type_error, format, va); | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| va_end(va); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| ZEND_API ZEND_COLD void zend_argument_type_error(uint32_t arg_num, const char *format, ...) /* {{{ */ | ||||||||||||||||||
| { | ||||||||||||||||||
| va_list va; | ||||||||||||||||||
| const zend_function *function = zend_active_function(); | ||||||||||||||||||
|
|
||||||||||||||||||
| va_start(va, format); | ||||||||||||||||||
| zend_argument_error_variadic(zend_ce_type_error, arg_num, format, va); | ||||||||||||||||||
| zend_argument_error_variadic(function, arg_num, zend_ce_type_error, format, va); | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| va_end(va); | ||||||||||||||||||
| } | ||||||||||||||||||
| /* }}} */ | ||||||||||||||||||
|
|
||||||||||||||||||
| ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *format, ...) /* {{{ */ | ||||||||||||||||||
| { | ||||||||||||||||||
| va_list va; | ||||||||||||||||||
| const zend_function *function = zend_active_function(); | ||||||||||||||||||
|
|
||||||||||||||||||
| va_start(va, format); | ||||||||||||||||||
| zend_argument_error_variadic(zend_ce_value_error, arg_num, format, va); | ||||||||||||||||||
| zend_argument_error_variadic(function, arg_num, zend_ce_value_error, format, va); | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| va_end(va); | ||||||||||||||||||
| } | ||||||||||||||||||
| /* }}} */ | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1564,9 +1564,16 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_string_or_nu | |||||||||||||||||||||||||||||||||||||||||
| ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(uint32_t num, char *error); | ||||||||||||||||||||||||||||||||||||||||||
| ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_or_null_error(uint32_t num, char *error); | ||||||||||||||||||||||||||||||||||||||||||
| ZEND_API ZEND_COLD void ZEND_FASTCALL zend_unexpected_extra_named_error(void); | ||||||||||||||||||||||||||||||||||||||||||
| ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_error_variadic(zend_class_entry *error_ce, uint32_t arg_num, const char *format, va_list va); | ||||||||||||||||||||||||||||||||||||||||||
| ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_error_variadic( | ||||||||||||||||||||||||||||||||||||||||||
| const zend_function *function, uint32_t arg_num, | ||||||||||||||||||||||||||||||||||||||||||
| zend_class_entry *error_ce, const char *format, va_list va); | ||||||||||||||||||||||||||||||||||||||||||
| ZEND_API ZEND_COLD void zend_argument_error(zend_class_entry *error_ce, uint32_t arg_num, const char *format, ...); | ||||||||||||||||||||||||||||||||||||||||||
| ZEND_API ZEND_COLD void zend_argument_error_ex(const zend_function *function, | ||||||||||||||||||||||||||||||||||||||||||
| uint32_t arg_num, zend_class_entry *error_ce, const char *format, ...); | ||||||||||||||||||||||||||||||||||||||||||
| ZEND_API ZEND_COLD void zend_argument_type_error(uint32_t arg_num, const char *format, ...); | ||||||||||||||||||||||||||||||||||||||||||
| ZEND_API ZEND_COLD void zend_argument_type_error_ex( | ||||||||||||||||||||||||||||||||||||||||||
| const zend_function *function, uint32_t arg_num, | ||||||||||||||||||||||||||||||||||||||||||
| const char *format, ...); | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1567
to
+1576
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
| ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *format, ...); | ||||||||||||||||||||||||||||||||||||||||||
| ZEND_API ZEND_COLD void zend_argument_must_not_be_empty_error(uint32_t arg_num); | ||||||||||||||||||||||||||||||||||||||||||
| ZEND_API ZEND_COLD void zend_class_redeclaration_error(int type, const zend_class_entry *old_ce); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -566,7 +566,7 @@ static void php_openssl_check_path_error(uint32_t arg_num, int type, const char | |||||
| va_start(va, format); | ||||||
|
|
||||||
| if (type == E_ERROR) { | ||||||
| zend_argument_error_variadic(zend_ce_value_error, arg_num, format, va); | ||||||
| zend_argument_error_variadic(zend_active_function(), arg_num, zend_ce_value_error, format, va); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| } else { | ||||||
| arg_name = get_active_function_arg_name(arg_num); | ||||||
| php_verror(NULL, arg_name, type, format, va); | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.