Skip to content

Commit 99d0f50

Browse files
committed
Fixed error message
1 parent 23afc62 commit 99d0f50

18 files changed

+77
-61
lines changed

Zend/tests/bug70895.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ try {
2020
}
2121
?>
2222
--EXPECT--
23-
array_map(): Argument #1 ($callback) must be a valid callback, function "%n" not found or invalid function name
24-
array_map(): Argument #1 ($callback) must be a valid callback, function "%n %i" not found or invalid function name
25-
array_map(): Argument #1 ($callback) must be a valid callback, function "%n %i aoeu %f aoeu %p" not found or invalid function name
23+
array_map(): Argument #1 ($callback) must be a valid callback or null, function "%n" not found or invalid function name
24+
array_map(): Argument #1 ($callback) must be a valid callback or null, function "%n %i" not found or invalid function name
25+
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

Zend/tests/bug70898.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ try {
1313
}
1414
?>
1515
--EXPECT--
16-
array_map(): Argument #1 ($callback) must be a valid callback, function "0000000000000000000000000000000000" not found or invalid function name
16+
array_map(): Argument #1 ($callback) must be a valid callback or null, function "0000000000000000000000000000000000" not found or invalid function name

Zend/tests/type_declarations/internal_function_strict_mode.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ try {
3030
*** Trying Ord With Integer
3131
*** Caught ord(): Argument #1 ($character) must be of type string, int given
3232
*** Trying Array Map With Invalid Callback
33-
*** Caught array_map(): Argument #1 ($callback) must be a valid callback, first array member is not a valid class name or object
33+
*** Caught array_map(): Argument #1 ($callback) must be a valid callback or null, first array member is not a valid class name or object
3434
*** Trying Strlen With Float
3535
*** Caught strlen(): Argument #1 ($str) must be of type string, float given

Zend/zend_API.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_error(int error_code,
215215
case ZPP_ERROR_WRONG_CALLBACK:
216216
zend_wrong_callback_error(num, name);
217217
break;
218+
case ZPP_ERROR_WRONG_CALLBACK_OR_NULL:
219+
zend_wrong_callback_or_null_error(num, name);
220+
break;
218221
case ZPP_ERROR_WRONG_CLASS:
219222
zend_wrong_parameter_class_error(num, name, arg);
220223
break;
@@ -337,6 +340,17 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(uint32_t num, ch
337340
}
338341
/* }}} */
339342

343+
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_or_null_error(uint32_t num, char *error) /* {{{ */
344+
{
345+
if (EG(exception)) {
346+
return;
347+
}
348+
349+
zend_argument_type_error(num, "must be a valid callback or null, %s", error);
350+
efree(error);
351+
}
352+
/* }}} */
353+
340354
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_unexpected_extra_named_error(void)
341355
{
342356
const char *space;

Zend/zend_API.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_long_or_null
13061306
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_string_error(uint32_t num, const char *name, zval *arg);
13071307
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_string_or_null_error(uint32_t num, const char *name, zval *arg);
13081308
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(uint32_t num, char *error);
1309+
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_or_null_error(uint32_t num, char *error);
13091310
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_unexpected_extra_named_error(void);
13101311
ZEND_API ZEND_COLD void zend_argument_error(zend_class_entry *error_ce, uint32_t arg_num, const char *format, ...);
13111312
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 *
13231324
#define ZPP_ERROR_WRONG_ARG 9
13241325
#define ZPP_ERROR_WRONG_COUNT 10
13251326
#define ZPP_ERROR_UNEXPECTED_EXTRA_NAMED 11
1327+
#define ZPP_ERROR_WRONG_CALLBACK_OR_NULL 12
13261328

13271329
#define ZEND_PARSE_PARAMETERS_START_EX(flags, min_num_args, max_num_args) do { \
13281330
const int _flags = (flags); \
@@ -1547,7 +1549,7 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
15471549
_expected_type = check_null ? Z_EXPECTED_FUNC_OR_NULL : Z_EXPECTED_FUNC; \
15481550
_error_code = ZPP_ERROR_WRONG_ARG; \
15491551
} else { \
1550-
_error_code = ZPP_ERROR_WRONG_CALLBACK; \
1552+
_error_code = check_null ? ZPP_ERROR_WRONG_CALLBACK_OR_NULL : ZPP_ERROR_WRONG_CALLBACK; \
15511553
} \
15521554
break; \
15531555
} \

ext/spl/tests/spl_autoload_001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,4 @@ TestFunc2(TestClass)
100100
%stestclass.class.inc
101101
bool(true)
102102
===NOFUNCTION===
103-
spl_autoload_register(): Argument #1 ($callback) must be a valid callback, function "unavailable_autoload_function" not found or invalid function name
103+
spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, function "unavailable_autoload_function" not found or invalid function name

ext/spl/tests/spl_autoload_005.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ catch(Exception $e)
4343

4444
?>
4545
--EXPECT--
46-
spl_autoload_register(): Argument #1 ($callback) must be a valid callback, non-static method MyAutoLoader::autoLoad() cannot be called statically
46+
spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, non-static method MyAutoLoader::autoLoad() cannot be called statically
4747
MyAutoLoader::autoLoad(TestClass)
4848
MyAutoLoader::autoThrow(TestClass)
4949
Exception: Unavailable

ext/spl/tests/spl_autoload_007.phpt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,32 @@ foreach($funcs as $idx => $func)
5252
?>
5353
--EXPECTF--
5454
string(22) "MyAutoLoader::notExist"
55-
spl_autoload_register(): Argument #1 ($callback) must be a valid callback, class MyAutoLoader does not have a method "notExist"
55+
spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, class MyAutoLoader does not have a method "notExist"
5656

5757
string(22) "MyAutoLoader::noAccess"
58-
spl_autoload_register(): Argument #1 ($callback) must be a valid callback, cannot access protected method MyAutoLoader::noAccess()
58+
spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, cannot access protected method MyAutoLoader::noAccess()
5959

6060
string(22) "MyAutoLoader::autoLoad"
6161
ok
6262

6363
string(22) "MyAutoLoader::dynaLoad"
64-
spl_autoload_register(): Argument #1 ($callback) must be a valid callback, non-static method MyAutoLoader::dynaLoad() cannot be called statically
64+
spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, non-static method MyAutoLoader::dynaLoad() cannot be called statically
6565

6666
array(2) {
6767
[0]=>
6868
string(12) "MyAutoLoader"
6969
[1]=>
7070
string(8) "notExist"
7171
}
72-
spl_autoload_register(): Argument #1 ($callback) must be a valid callback, class MyAutoLoader does not have a method "notExist"
72+
spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, class MyAutoLoader does not have a method "notExist"
7373

7474
array(2) {
7575
[0]=>
7676
string(12) "MyAutoLoader"
7777
[1]=>
7878
string(8) "noAccess"
7979
}
80-
spl_autoload_register(): Argument #1 ($callback) must be a valid callback, cannot access protected method MyAutoLoader::noAccess()
80+
spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, cannot access protected method MyAutoLoader::noAccess()
8181

8282
array(2) {
8383
[0]=>
@@ -93,7 +93,7 @@ array(2) {
9393
[1]=>
9494
string(8) "dynaLoad"
9595
}
96-
spl_autoload_register(): Argument #1 ($callback) must be a valid callback, non-static method MyAutoLoader::dynaLoad() cannot be called statically
96+
spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, non-static method MyAutoLoader::dynaLoad() cannot be called statically
9797

9898
array(2) {
9999
[0]=>
@@ -102,7 +102,7 @@ array(2) {
102102
[1]=>
103103
string(8) "notExist"
104104
}
105-
spl_autoload_register(): Argument #1 ($callback) must be a valid callback, class MyAutoLoader does not have a method "notExist"
105+
spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, class MyAutoLoader does not have a method "notExist"
106106

107107
array(2) {
108108
[0]=>
@@ -111,7 +111,7 @@ array(2) {
111111
[1]=>
112112
string(8) "noAccess"
113113
}
114-
spl_autoload_register(): Argument #1 ($callback) must be a valid callback, cannot access protected method MyAutoLoader::noAccess()
114+
spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, cannot access protected method MyAutoLoader::noAccess()
115115

116116
array(2) {
117117
[0]=>

ext/spl/tests/spl_autoload_008.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Exception: Bla
8181
int(0)
8282
====2====
8383
string(22) "MyAutoLoader::dynaLoad"
84-
TypeError: spl_autoload_register(): Argument #1 ($callback) must be a valid callback, non-static method MyAutoLoader::dynaLoad() cannot be called statically
84+
TypeError: spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, non-static method MyAutoLoader::dynaLoad() cannot be called statically
8585
int(0)
8686
====3====
8787
array(2) {
@@ -101,7 +101,7 @@ array(2) {
101101
[1]=>
102102
string(8) "dynaLoad"
103103
}
104-
TypeError: spl_autoload_register(): Argument #1 ($callback) must be a valid callback, non-static method MyAutoLoader::dynaLoad() cannot be called statically
104+
TypeError: spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, non-static method MyAutoLoader::dynaLoad() cannot be called statically
105105
int(0)
106106
====5====
107107
array(2) {

ext/standard/tests/array/array_filter_variation9.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ array(6) {
6262
[5]=>
6363
int(1000)
6464
}
65-
array_filter(): Argument #2 ($callback) must be a valid callback, function "echo" not found or invalid function name
66-
array_filter(): Argument #2 ($callback) must be a valid callback, function "exit" not found or invalid function name
65+
array_filter(): Argument #2 ($callback) must be a valid callback or null, function "echo" not found or invalid function name
66+
array_filter(): Argument #2 ($callback) must be a valid callback or null, function "exit" not found or invalid function name
6767
Done

0 commit comments

Comments
 (0)