]> granicus.if.org Git - php/commitdiff
Fixed error message
authorDmitry Stogov <dmitry@zend.com>
Wed, 24 Feb 2021 16:12:32 +0000 (19:12 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 24 Feb 2021 16:12:32 +0000 (19:12 +0300)
18 files changed:
Zend/tests/bug70895.phpt
Zend/tests/bug70898.phpt
Zend/tests/type_declarations/internal_function_strict_mode.phpt
Zend/zend_API.c
Zend/zend_API.h
ext/spl/tests/spl_autoload_001.phpt
ext/spl/tests/spl_autoload_005.phpt
ext/spl/tests/spl_autoload_007.phpt
ext/spl/tests/spl_autoload_008.phpt
ext/standard/tests/array/array_filter_variation9.phpt
ext/standard/tests/array/array_map_object1.phpt
ext/standard/tests/array/array_map_object2.phpt
ext/standard/tests/array/array_map_object3.phpt
ext/standard/tests/array/array_map_variation12.phpt
ext/standard/tests/array/array_map_variation14.phpt
ext/standard/tests/array/array_map_variation15.phpt
ext/standard/tests/array/array_map_variation16.phpt
ext/standard/tests/array/array_map_variation17.phpt

index 1a28d9ef5cefc931592529595012bf7e52362bf9..afbea1c91d76bcb332bc7e550b9d71b81c9a95ed 100644 (file)
@@ -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
index 2aff5109d836ba918ecb9bdeda06f8ffec134c66..d3d2cf79a9d1673729104d6952b4a2b333b29e7f 100644 (file)
@@ -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
index 04c59ae3410ef7ea72334933b2d2e21f0d6d4737..455164f3276d3d5cce325cd6e70a1b2372b1806c 100644 (file)
@@ -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
index 6aa9a043ff99d04819c7d227ff65690c51a06493..e532e9754a324a969029a694de74e6fc069fe5b3 100644 (file)
@@ -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;
index a811d9c5334f68eab3ff60349c3c8a1f9f3e72d3..8072befb030a32eef7e34cc82e4493b4fc5aa7e4 100644 (file)
@@ -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; \
                } \
index c7f5e573f37ad853435f4dc143414795144f26f7..befb96570950a6a9e94d31e389e83874f745caca 100644 (file)
@@ -100,4 +100,4 @@ TestFunc2(TestClass)
 %stestclass.class.inc
 bool(true)
 ===NOFUNCTION===
-spl_autoload_register(): Argument #1 ($callback) must be a valid callback, function "unavailable_autoload_function" not found or invalid function name
+spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, function "unavailable_autoload_function" not found or invalid function name
index 6eb851032504c2de54cbf344e242597f4d1d71bb..0f2c5ed2c3024cfdbfd04fdf8c6dcd87543b47f7 100644 (file)
@@ -43,7 +43,7 @@ catch(Exception $e)
 
 ?>
 --EXPECT--
-spl_autoload_register(): Argument #1 ($callback) must be a valid callback, non-static method MyAutoLoader::autoLoad() cannot be called statically
+spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, non-static method MyAutoLoader::autoLoad() cannot be called statically
 MyAutoLoader::autoLoad(TestClass)
 MyAutoLoader::autoThrow(TestClass)
 Exception: Unavailable
index 589ce74b7f7467cd6d6f685b8ed26f241f7c7117..0a8183dfb403ace67bdce5af7a65235e614f37e9 100644 (file)
@@ -52,16 +52,16 @@ foreach($funcs as $idx => $func)
 ?>
 --EXPECTF--
 string(22) "MyAutoLoader::notExist"
-spl_autoload_register(): Argument #1 ($callback) must be a valid callback, class MyAutoLoader does not have a method "notExist"
+spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, class MyAutoLoader does not have a method "notExist"
 
 string(22) "MyAutoLoader::noAccess"
-spl_autoload_register(): Argument #1 ($callback) must be a valid callback, cannot access protected method MyAutoLoader::noAccess()
+spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, cannot access protected method MyAutoLoader::noAccess()
 
 string(22) "MyAutoLoader::autoLoad"
 ok
 
 string(22) "MyAutoLoader::dynaLoad"
-spl_autoload_register(): Argument #1 ($callback) must be a valid callback, non-static method MyAutoLoader::dynaLoad() cannot be called statically
+spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, non-static method MyAutoLoader::dynaLoad() cannot be called statically
 
 array(2) {
   [0]=>
@@ -69,7 +69,7 @@ array(2) {
   [1]=>
   string(8) "notExist"
 }
-spl_autoload_register(): Argument #1 ($callback) must be a valid callback, class MyAutoLoader does not have a method "notExist"
+spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, class MyAutoLoader does not have a method "notExist"
 
 array(2) {
   [0]=>
@@ -77,7 +77,7 @@ array(2) {
   [1]=>
   string(8) "noAccess"
 }
-spl_autoload_register(): Argument #1 ($callback) must be a valid callback, cannot access protected method MyAutoLoader::noAccess()
+spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, cannot access protected method MyAutoLoader::noAccess()
 
 array(2) {
   [0]=>
@@ -93,7 +93,7 @@ array(2) {
   [1]=>
   string(8) "dynaLoad"
 }
-spl_autoload_register(): Argument #1 ($callback) must be a valid callback, non-static method MyAutoLoader::dynaLoad() cannot be called statically
+spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, non-static method MyAutoLoader::dynaLoad() cannot be called statically
 
 array(2) {
   [0]=>
@@ -102,7 +102,7 @@ array(2) {
   [1]=>
   string(8) "notExist"
 }
-spl_autoload_register(): Argument #1 ($callback) must be a valid callback, class MyAutoLoader does not have a method "notExist"
+spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, class MyAutoLoader does not have a method "notExist"
 
 array(2) {
   [0]=>
@@ -111,7 +111,7 @@ array(2) {
   [1]=>
   string(8) "noAccess"
 }
-spl_autoload_register(): Argument #1 ($callback) must be a valid callback, cannot access protected method MyAutoLoader::noAccess()
+spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, cannot access protected method MyAutoLoader::noAccess()
 
 array(2) {
   [0]=>
index 99f61cd561be43e4fb494446f92a888db6e3b68c..738c691ddfe9fbfcda79fd4a857443312864c594 100644 (file)
@@ -81,7 +81,7 @@ Exception: Bla
 int(0)
 ====2====
 string(22) "MyAutoLoader::dynaLoad"
-TypeError: spl_autoload_register(): Argument #1 ($callback) must be a valid callback, non-static method MyAutoLoader::dynaLoad() cannot be called statically
+TypeError: spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, non-static method MyAutoLoader::dynaLoad() cannot be called statically
 int(0)
 ====3====
 array(2) {
@@ -101,7 +101,7 @@ array(2) {
   [1]=>
   string(8) "dynaLoad"
 }
-TypeError: spl_autoload_register(): Argument #1 ($callback) must be a valid callback, non-static method MyAutoLoader::dynaLoad() cannot be called statically
+TypeError: spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, non-static method MyAutoLoader::dynaLoad() cannot be called statically
 int(0)
 ====5====
 array(2) {
index d9abf7dac1994b392e5a5dde6ec9589c24ccb809..d9c1f9258f3a9ec54aa4edb50f727aae98686a39 100644 (file)
@@ -62,6 +62,6 @@ array(6) {
   [5]=>
   int(1000)
 }
-array_filter(): Argument #2 ($callback) must be a valid callback, function "echo" not found or invalid function name
-array_filter(): Argument #2 ($callback) must be a valid callback, function "exit" not found or invalid function name
+array_filter(): Argument #2 ($callback) must be a valid callback or null, function "echo" not found or invalid function name
+array_filter(): Argument #2 ($callback) must be a valid callback or null, function "exit" not found or invalid function name
 Done
index b5da9798e4d24530f0cd3324e75d4d6998acd50e..88ebe2414b3f2e74fe0dee90be5abffbb621c723 100644 (file)
@@ -132,15 +132,15 @@ array(2) {
 
 -- simple class with private variable and method --
 SimpleClassPri::add
-array_map(): Argument #1 ($callback) must be a valid callback, cannot access private method SimpleClassPri::add()
+array_map(): Argument #1 ($callback) must be a valid callback or null, cannot access private method SimpleClassPri::add()
 
 -- simple class with protected variable and method --
 SimpleClassPro::mul
-array_map(): Argument #1 ($callback) must be a valid callback, cannot access protected method SimpleClassPro::mul()
+array_map(): Argument #1 ($callback) must be a valid callback or null, cannot access protected method SimpleClassPro::mul()
 
 -- class without members --
 EmptyClass
-array_map(): Argument #1 ($callback) must be a valid callback, array must have exactly two members
+array_map(): Argument #1 ($callback) must be a valid callback or null, array must have exactly two members
 
 -- abstract class --
 ChildClass::emptyFunction
@@ -173,9 +173,9 @@ array(2) {
   int(4)
 }
 StaticClass::cube
-array_map(): Argument #1 ($callback) must be a valid callback, cannot access private method StaticClass::cube()
+array_map(): Argument #1 ($callback) must be a valid callback or null, cannot access private method StaticClass::cube()
 StaticClass::retVal
-array_map(): Argument #1 ($callback) must be a valid callback, cannot access protected method StaticClass::retVal()
+array_map(): Argument #1 ($callback) must be a valid callback or null, cannot access protected method StaticClass::retVal()
 -- class implementing an interface --
 InterClass::square
 array(2) {
index 53524fc8196a5e25736ae212b41916e76bd8f285..3b9666ce50acedf808a51915704809456aded26f 100644 (file)
@@ -39,7 +39,7 @@ echo "Done";
 --EXPECT--
 *** Testing array_map() :  with non-existent class and method ***
 -- with non-existent class --
-array_map(): Argument #1 ($callback) must be a valid callback, class "non-existent" not found
+array_map(): Argument #1 ($callback) must be a valid callback or null, class "non-existent" not found
 -- with existent class and non-existent method --
-array_map(): Argument #1 ($callback) must be a valid callback, class SimpleClass does not have a method "non-existent"
+array_map(): Argument #1 ($callback) must be a valid callback or null, class SimpleClass does not have a method "non-existent"
 Done
index b5528c9e7c1664c03dfe592288b92abd19284616..55a97a317f2ab526946c5500bcedbae7e194018b 100644 (file)
@@ -76,7 +76,7 @@ array(3) {
   int(7)
 }
 -- accessing child method from parent class --
-array_map(): Argument #1 ($callback) must be a valid callback, class ParentClass does not have a method "staticChild"
+array_map(): Argument #1 ($callback) must be a valid callback or null, class ParentClass does not have a method "staticChild"
 -- accessing parent method using child class object --
 array(3) {
   [0]=>
@@ -87,5 +87,5 @@ array(3) {
   int(7)
 }
 -- accessing child method using parent class object --
-array_map(): Argument #1 ($callback) must be a valid callback, class ParentClass does not have a method "staticChild"
+array_map(): Argument #1 ($callback) must be a valid callback or null, class ParentClass does not have a method "staticChild"
 Done
index b642bd0cb50d6cbd17108a617dd8a29ee7e266fc..d3fa62e93d6786ddaf5a9f6166e469ed0b29bf55 100644 (file)
@@ -44,5 +44,5 @@ array(3) {
 -- with built-in function 'pow' and one parameter --
 pow() expects exactly 2 arguments, 1 given
 -- with language construct --
-array_map(): Argument #1 ($callback) must be a valid callback, function "echo" not found or invalid function name
+array_map(): Argument #1 ($callback) must be a valid callback or null, function "echo" not found or invalid function name
 Done
index 2670537b4674cf32675a4bd0911a5eb84029e0e1..d1f0b517ea4f752a0bed57b36d69cab4c4859f4a 100644 (file)
@@ -118,7 +118,7 @@ array(2) {
   int(2)
 }
 -- with empty string --
-array_map(): Argument #1 ($callback) must be a valid callback, function "" not found or invalid function name
+array_map(): Argument #1 ($callback) must be a valid callback or null, function "" not found or invalid function name
 -- with empty array --
-array_map(): Argument #1 ($callback) must be a valid callback, array must have exactly two members
+array_map(): Argument #1 ($callback) must be a valid callback or null, array must have exactly two members
 Done
index f10be3cc328a95f46e3968cd1fcced14c2c67a33..d053a720463990ed2ce90f43776e46dafff0d1dd 100644 (file)
@@ -23,5 +23,5 @@ echo "Done";
 ?>
 --EXPECT--
 *** Testing array_map() : non existent 'callback' function ***
-array_map(): Argument #1 ($callback) must be a valid callback, function "non_existent" not found or invalid function name
+array_map(): Argument #1 ($callback) must be a valid callback or null, function "non_existent" not found or invalid function name
 Done
index 21034375b9c6e897a5ddb7c3e7ef79d060b76632..b7c6690040162d87ae1509246b8956da17eb7545 100644 (file)
@@ -38,19 +38,19 @@ echo "Done";
 --EXPECT--
 *** Testing array_map() : non-permmited built-in functions ***
 -- Iteration 1 --
-array_map(): Argument #1 ($callback) must be a valid callback, function "echo" not found or invalid function name
+array_map(): Argument #1 ($callback) must be a valid callback or null, function "echo" not found or invalid function name
 -- Iteration 2 --
-array_map(): Argument #1 ($callback) must be a valid callback, function "array" not found or invalid function name
+array_map(): Argument #1 ($callback) must be a valid callback or null, function "array" not found or invalid function name
 -- Iteration 3 --
-array_map(): Argument #1 ($callback) must be a valid callback, function "empty" not found or invalid function name
+array_map(): Argument #1 ($callback) must be a valid callback or null, function "empty" not found or invalid function name
 -- Iteration 4 --
-array_map(): Argument #1 ($callback) must be a valid callback, function "eval" not found or invalid function name
+array_map(): Argument #1 ($callback) must be a valid callback or null, function "eval" not found or invalid function name
 -- Iteration 5 --
-array_map(): Argument #1 ($callback) must be a valid callback, function "exit" not found or invalid function name
+array_map(): Argument #1 ($callback) must be a valid callback or null, function "exit" not found or invalid function name
 -- Iteration 6 --
-array_map(): Argument #1 ($callback) must be a valid callback, function "isset" not found or invalid function name
+array_map(): Argument #1 ($callback) must be a valid callback or null, function "isset" not found or invalid function name
 -- Iteration 7 --
-array_map(): Argument #1 ($callback) must be a valid callback, function "list" not found or invalid function name
+array_map(): Argument #1 ($callback) must be a valid callback or null, function "list" not found or invalid function name
 -- Iteration 8 --
-array_map(): Argument #1 ($callback) must be a valid callback, function "print" not found or invalid function name
+array_map(): Argument #1 ($callback) must be a valid callback or null, function "print" not found or invalid function name
 Done
index a3aeb9f22a1e37dac6b1785877bca1aad17a0247..78b8d8c5c838fe60b50af838945a6027ad2e9abf 100644 (file)
@@ -76,62 +76,62 @@ echo "Done";
 *** Testing array_map() : unexpected values for 'callback' argument ***
 
 -- Iteration 1 --
-array_map(): Argument #1 ($callback) must be a valid callback, no array or string given
+array_map(): Argument #1 ($callback) must be a valid callback or null, no array or string given
 
 -- Iteration 2 --
-array_map(): Argument #1 ($callback) must be a valid callback, no array or string given
+array_map(): Argument #1 ($callback) must be a valid callback or null, no array or string given
 
 -- Iteration 3 --
-array_map(): Argument #1 ($callback) must be a valid callback, no array or string given
+array_map(): Argument #1 ($callback) must be a valid callback or null, no array or string given
 
 -- Iteration 4 --
-array_map(): Argument #1 ($callback) must be a valid callback, no array or string given
+array_map(): Argument #1 ($callback) must be a valid callback or null, no array or string given
 
 -- Iteration 5 --
-array_map(): Argument #1 ($callback) must be a valid callback, no array or string given
+array_map(): Argument #1 ($callback) must be a valid callback or null, no array or string given
 
 -- Iteration 6 --
-array_map(): Argument #1 ($callback) must be a valid callback, no array or string given
+array_map(): Argument #1 ($callback) must be a valid callback or null, no array or string given
 
 -- Iteration 7 --
-array_map(): Argument #1 ($callback) must be a valid callback, no array or string given
+array_map(): Argument #1 ($callback) must be a valid callback or null, no array or string given
 
 -- Iteration 8 --
-array_map(): Argument #1 ($callback) must be a valid callback, no array or string given
+array_map(): Argument #1 ($callback) must be a valid callback or null, no array or string given
 
 -- Iteration 9 --
-array_map(): Argument #1 ($callback) must be a valid callback, no array or string given
+array_map(): Argument #1 ($callback) must be a valid callback or null, no array or string given
 
 -- Iteration 10 --
-array_map(): Argument #1 ($callback) must be a valid callback, no array or string given
+array_map(): Argument #1 ($callback) must be a valid callback or null, no array or string given
 
 -- Iteration 11 --
-array_map(): Argument #1 ($callback) must be a valid callback, no array or string given
+array_map(): Argument #1 ($callback) must be a valid callback or null, no array or string given
 
 -- Iteration 12 --
-array_map(): Argument #1 ($callback) must be a valid callback, no array or string given
+array_map(): Argument #1 ($callback) must be a valid callback or null, no array or string given
 
 -- Iteration 13 --
-array_map(): Argument #1 ($callback) must be a valid callback, no array or string given
+array_map(): Argument #1 ($callback) must be a valid callback or null, no array or string given
 
 -- Iteration 14 --
-array_map(): Argument #1 ($callback) must be a valid callback, function "" not found or invalid function name
+array_map(): Argument #1 ($callback) must be a valid callback or null, function "" not found or invalid function name
 
 -- Iteration 15 --
-array_map(): Argument #1 ($callback) must be a valid callback, function "" not found or invalid function name
+array_map(): Argument #1 ($callback) must be a valid callback or null, function "" not found or invalid function name
 
 -- Iteration 16 --
-array_map(): Argument #1 ($callback) must be a valid callback, array must have exactly two members
+array_map(): Argument #1 ($callback) must be a valid callback or null, array must have exactly two members
 
 -- Iteration 17 --
-array_map(): Argument #1 ($callback) must be a valid callback, first array member is not a valid class name or object
+array_map(): Argument #1 ($callback) must be a valid callback or null, first array member is not a valid class name or object
 
 -- Iteration 18 --
-array_map(): Argument #1 ($callback) must be a valid callback, first array member is not a valid class name or object
+array_map(): Argument #1 ($callback) must be a valid callback or null, first array member is not a valid class name or object
 
 -- Iteration 19 --
-array_map(): Argument #1 ($callback) must be a valid callback, no array or string given
+array_map(): Argument #1 ($callback) must be a valid callback or null, no array or string given
 
 -- Iteration 20 --
-array_map(): Argument #1 ($callback) must be a valid callback, no array or string given
+array_map(): Argument #1 ($callback) must be a valid callback or null, no array or string given
 Done