summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2021-02-24 19:12:32 +0300
committerDmitry Stogov <dmitry@zend.com>2021-02-24 19:12:32 +0300
commit99d0f502dcde51b0a5e96d8f4267d60ed78b8e2b (patch)
tree106af3bde884daa7e69995a7fcc6cade3bced8de /Zend
parent23afc62080588f612fa6c5d0ea217564930dab3d (diff)
downloadphp-git-99d0f502dcde51b0a5e96d8f4267d60ed78b8e2b.tar.gz
Fixed error message
Diffstat (limited to 'Zend')
-rw-r--r--Zend/tests/bug70895.phpt6
-rw-r--r--Zend/tests/bug70898.phpt2
-rw-r--r--Zend/tests/type_declarations/internal_function_strict_mode.phpt2
-rw-r--r--Zend/zend_API.c14
-rw-r--r--Zend/zend_API.h4
5 files changed, 22 insertions, 6 deletions
diff --git a/Zend/tests/bug70895.phpt b/Zend/tests/bug70895.phpt
index 1a28d9ef5c..afbea1c91d 100644
--- a/Zend/tests/bug70895.phpt
+++ b/Zend/tests/bug70895.phpt
@@ -20,6 +20,6 @@ try {
}
?>
--EXPECT--
-array_map(): Argument #1 ($callback) must be a valid callback, function "%n" not found or invalid function name
-array_map(): Argument #1 ($callback) must be a valid callback, function "%n %i" not found or invalid function name
-array_map(): Argument #1 ($callback) must be a valid callback, function "%n %i aoeu %f aoeu %p" not found or invalid function name
+array_map(): Argument #1 ($callback) must be a valid callback or null, function "%n" not found or invalid function name
+array_map(): Argument #1 ($callback) must be a valid callback or null, function "%n %i" not found or invalid function name
+array_map(): Argument #1 ($callback) must be a valid callback or null, function "%n %i aoeu %f aoeu %p" not found or invalid function name
diff --git a/Zend/tests/bug70898.phpt b/Zend/tests/bug70898.phpt
index 2aff5109d8..d3d2cf79a9 100644
--- a/Zend/tests/bug70898.phpt
+++ b/Zend/tests/bug70898.phpt
@@ -13,4 +13,4 @@ try {
}
?>
--EXPECT--
-array_map(): Argument #1 ($callback) must be a valid callback, function "0000000000000000000000000000000000" not found or invalid function name
+array_map(): Argument #1 ($callback) must be a valid callback or null, function "0000000000000000000000000000000000" not found or invalid function name
diff --git a/Zend/tests/type_declarations/internal_function_strict_mode.phpt b/Zend/tests/type_declarations/internal_function_strict_mode.phpt
index 04c59ae341..455164f327 100644
--- a/Zend/tests/type_declarations/internal_function_strict_mode.phpt
+++ b/Zend/tests/type_declarations/internal_function_strict_mode.phpt
@@ -30,6 +30,6 @@ try {
*** Trying Ord With Integer
*** Caught ord(): Argument #1 ($character) must be of type string, int given
*** Trying Array Map With Invalid Callback
-*** Caught array_map(): Argument #1 ($callback) must be a valid callback, first array member is not a valid class name or object
+*** Caught array_map(): Argument #1 ($callback) must be a valid callback or null, first array member is not a valid class name or object
*** Trying Strlen With Float
*** Caught strlen(): Argument #1 ($str) must be of type string, float given
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 6aa9a043ff..e532e9754a 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -215,6 +215,9 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_error(int error_code,
case ZPP_ERROR_WRONG_CALLBACK:
zend_wrong_callback_error(num, name);
break;
+ case ZPP_ERROR_WRONG_CALLBACK_OR_NULL:
+ zend_wrong_callback_or_null_error(num, name);
+ break;
case ZPP_ERROR_WRONG_CLASS:
zend_wrong_parameter_class_error(num, name, arg);
break;
@@ -337,6 +340,17 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(uint32_t num, ch
}
/* }}} */
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_or_null_error(uint32_t num, char *error) /* {{{ */
+{
+ if (EG(exception)) {
+ return;
+ }
+
+ zend_argument_type_error(num, "must be a valid callback or null, %s", error);
+ efree(error);
+}
+/* }}} */
+
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_unexpected_extra_named_error(void)
{
const char *space;
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
index a811d9c533..8072befb03 100644
--- a/Zend/zend_API.h
+++ b/Zend/zend_API.h
@@ -1306,6 +1306,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_long_or_null
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_string_error(uint32_t num, const char *name, zval *arg);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_string_or_null_error(uint32_t num, const char *name, zval *arg);
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_argument_error(zend_class_entry *error_ce, uint32_t arg_num, const char *format, ...);
ZEND_API ZEND_COLD void zend_argument_type_error(uint32_t arg_num, const char *format, ...);
@@ -1323,6 +1324,7 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
#define ZPP_ERROR_WRONG_ARG 9
#define ZPP_ERROR_WRONG_COUNT 10
#define ZPP_ERROR_UNEXPECTED_EXTRA_NAMED 11
+#define ZPP_ERROR_WRONG_CALLBACK_OR_NULL 12
#define ZEND_PARSE_PARAMETERS_START_EX(flags, min_num_args, max_num_args) do { \
const int _flags = (flags); \
@@ -1547,7 +1549,7 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
_expected_type = check_null ? Z_EXPECTED_FUNC_OR_NULL : Z_EXPECTED_FUNC; \
_error_code = ZPP_ERROR_WRONG_ARG; \
} else { \
- _error_code = ZPP_ERROR_WRONG_CALLBACK; \
+ _error_code = check_null ? ZPP_ERROR_WRONG_CALLBACK_OR_NULL : ZPP_ERROR_WRONG_CALLBACK; \
} \
break; \
} \