]> granicus.if.org Git - php/commitdiff
Implemented RFC: Replace "Missing argument" warning with "Too few arguments" exception
authorDmitry Stogov <dmitry@zend.com>
Wed, 15 Jun 2016 23:32:02 +0000 (02:32 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 15 Jun 2016 23:32:02 +0000 (02:32 +0300)
Squashed commit of the following:

commit 8b45fa2acb8cd92542a39e1e4720fe1f4fabc26c
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Jun 16 01:52:50 2016 +0300

    Separate slow path of ZEND_RECV into a cold function.

commit 9e18895ee59c64c93a96b1ba3061355c4663e962
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jun 15 23:26:28 2016 +0300

    Required argument can't be IS_UNDEF anymore.

commit 662db66e3943d4455c65e4f987bb54abf724ecb2
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue May 31 17:14:50 2016 +0300

    Replace "Missing argument" warning by "Too few arguments" exception.

48 files changed:
Zend/tests/001.phpt
Zend/tests/002.phpt
Zend/tests/003.phpt
Zend/tests/bug33996.phpt
Zend/tests/bug38047.phpt
Zend/tests/bug55705.phpt
Zend/tests/bug70689.phpt
Zend/tests/closure_027.phpt
Zend/tests/error_reporting06.phpt
Zend/tests/error_reporting07.phpt
Zend/tests/error_reporting08.phpt
Zend/tests/nullable_types/nullable_type_parameters_do_not_have_default_value.phpt
Zend/tests/type_declarations/scalar_none.phpt
Zend/zend_execute.c
Zend/zend_execute.h
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
ext/libxml/tests/libxml_set_external_entity_loader_error1.phpt
ext/mysqli/tests/mysqli_fetch_object.phpt
ext/mysqli/tests/mysqli_fetch_object_oo.phpt
ext/opcache/Optimizer/zend_inference.c
ext/reflection/tests/007.phpt
ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt
ext/reflection/tests/ReflectionClass_newInstance_001.phpt
ext/reflection/tests/ReflectionMethod_invokeArgs_error1.phpt
ext/reflection/tests/ReflectionMethod_invoke_error2.phpt
ext/reflection/tests/bug38217.phpt
ext/soap/tests/bugs/bug38005.phpt
ext/soap/tests/soap12/soap12-test.inc
ext/standard/tests/array/array_filter_variation10.phpt
ext/standard/tests/array/array_map_error.phpt
ext/standard/tests/array/array_map_variation10.phpt
ext/standard/tests/array/array_map_variation9.phpt
ext/standard/tests/array/array_reduce_variation1.phpt
ext/standard/tests/array/array_udiff_assoc_variation5.phpt
ext/standard/tests/array/array_udiff_uassoc_variation6.phpt
ext/standard/tests/array/array_udiff_variation5.phpt
ext/standard/tests/array/array_uintersect_assoc_variation5.phpt
ext/standard/tests/array/array_uintersect_uassoc_variation6.phpt
ext/standard/tests/array/array_uintersect_variation5.phpt
ext/standard/tests/array/array_walk_error2.phpt
ext/standard/tests/array/array_walk_recursive_error2.phpt
ext/standard/tests/assert/assert_error2.phpt
ext/standard/tests/file/bug38450.phpt
ext/standard/tests/file/bug38450_1.phpt
ext/standard/tests/file/bug38450_2.phpt
ext/standard/tests/file/bug38450_3.phpt
tests/classes/interfaces_003.phpt

index bec7d8adbcd4f31667f79afc64808ccacfa026da..bbd4ea3ece636c27a7706e87c25919ad96c566e8 100644 (file)
@@ -17,11 +17,20 @@ function test3($a, $b) {
 
 test1();
 test2(1);
-test2();
+try {
+       test2();
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
+
 test3(1,2);
 
 call_user_func("test1");
-call_user_func("test3", 1);
+try {
+       call_user_func("test3", 1);
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 call_user_func("test3", 1, 2);
 
 class test {
@@ -38,14 +47,10 @@ echo "Done\n";
 --EXPECTF--    
 int(0)
 int(1)
-
-Warning: Missing argument 1 for test2(), called in %s on line %d
-int(0)
+Exception: Too few arguments to function test2(), 0 passed in %s001.php on line 18 and exactly 1 expected
 int(2)
 int(0)
-
-Warning: Missing argument 2 for test3()%s
-int(1)
+Exception: Too few arguments to function test3(), 1 passed in %s001.php on line 27 and exactly 2 expected
 int(2)
 int(1)
 
index b01c7fa329d8bd65be2ce20cf7dfa1139815cf03..1728330c08bb2ce35b469d4e6c91cf977ebff047 100644 (file)
@@ -23,11 +23,19 @@ function test3($a, $b) {
 test1();
 test1(10);
 test2(1);
-test2();
+try {
+       test2();
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 test3(1,2);
 
 call_user_func("test1");
-call_user_func("test3", 1);
+try {
+       call_user_func("test3", 1);
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 call_user_func("test3", 1, 2);
 
 class test {
@@ -62,14 +70,7 @@ int(1)
 
 Warning: func_get_arg():  Argument 1 not passed to function in %s on line %d
 bool(false)
-
-Warning: Missing argument 1 for test2(), called in %s on line %d and defined in %s on line %d
-
-Warning: func_get_arg():  Argument 0 not passed to function in %s on line %d
-bool(false)
-
-Warning: func_get_arg():  Argument 1 not passed to function in %s on line %d
-bool(false)
+Exception: Too few arguments to function test2(), 0 passed in %s002.php on line %d and exactly 1 expected
 int(1)
 int(2)
 
@@ -84,15 +85,7 @@ bool(false)
 
 Warning: func_get_arg():  Argument 1 not passed to function in %s on line %d
 bool(false)
-
-Warning: Missing argument 2 for test3()%s
-int(1)
-
-Warning: func_get_arg():  Argument 1 not passed to function in %s on line %d
-bool(false)
-
-Warning: func_get_arg():  Argument 2 not passed to function in %s on line %d
-bool(false)
+Exception: Too few arguments to function test3(), 1 passed in %s002.php on line %d and exactly 2 expected
 int(1)
 int(2)
 
index 5c3b83d25e1d11d7e0d818552a7a55224f81c7e8..91daa705d37a3f0989e32fd4955ff9eae2d52a15 100644 (file)
@@ -18,11 +18,19 @@ function test3($a, $b) {
 test1();
 test1(10);
 test2(1);
-test2();
+try {
+       test2();
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 test3(1,2);
 
 call_user_func("test1");
-call_user_func("test3", 1);
+try {
+       call_user_func("test3", 1);
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 call_user_func("test3", 1, 2);
 
 class test {
@@ -47,10 +55,7 @@ array(1) {
   [0]=>
   int(1)
 }
-
-Warning: Missing argument 1 for test2(), called in %s on line %d and defined in %s on line %d
-array(0) {
-}
+Exception: Too few arguments to function test2(), 0 passed in %s003.php on line %d and exactly 1 expected
 array(2) {
   [0]=>
   int(1)
@@ -59,12 +64,7 @@ array(2) {
 }
 array(0) {
 }
-
-Warning: Missing argument 2 for test3()%s
-array(1) {
-  [0]=>
-  int(1)
-}
+Exception: Too few arguments to function test3(), 1 passed in %s003.php on line %d and exactly 2 expected
 array(2) {
   [0]=>
   int(1)
index c399ee99756c84cff513c2c8984301865172a985..3936eb8845b8bbe098c1ce3794dbc2c037d0923a 100644 (file)
@@ -19,15 +19,19 @@ function NormalTest($a)
     echo "Hi!";
 }
 
-NormalTest();
-FooTest();
+try {
+       NormalTest();
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
+try {
+       FooTest();
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 FooTest(new Foo());
 ?>
 --EXPECTF--
-Warning: Missing argument 1 for NormalTest(), called in %sbug33996.php on line %d and defined in %sbug33996.php on line %d
-Hi!
-Fatal error: Uncaught TypeError: Argument 1 passed to FooTest() must be an instance of Foo, none given, called in %sbug33996.php on line %d and defined in %sbug33996.php:%d
-Stack trace:
-#0 %s(%d): FooTest()
-#1 {main}
-  thrown in %sbug33996.php on line %d
+Exception: Too few arguments to function NormalTest(), 0 passed in %sbug33996.php on line 18 and exactly 1 expected
+Exception: Too few arguments to function FooTest(), 0 passed in %sbug33996.php on line 23 and exactly 1 expected
+Hello!
index 5e7b3efc9409fb433a1b7b1d9c48c163af6de02e..09739d23ebbba0c84866790a1b9dd0bd141843d6 100644 (file)
@@ -43,7 +43,9 @@ Non-static method A::A_ftk() should not be called statically
 1 %sbug38047.php:13 get_error_context()
 2 %sbug38047.php:36 kalus_error_handler()
 
-Missing argument 1 for A::A_ftk(), called in %sbug38047.php on line 36 and defined
-1 %sbug38047.php:13 get_error_context()
-2 %sbug38047.php:7 kalus_error_handler()
-3 %sbug38047.php:36 A_ftk()
+
+Fatal error: Uncaught Error: Too few arguments to function A::A_ftk(), 0 passed in %sbug38047.php on line 36 and exactly 1 expected in %sbug38047.php:7
+Stack trace:
+#0 %sbug38047.php(36): A::A_ftk()
+#1 {main}
+  thrown in %sbug38047.php on line 7
index f051bca6dcbf4e1a33541a783ad5f7f59a712a06..fc17139344d784a1e285b7d9236e8a6113b173a6 100644 (file)
@@ -6,7 +6,7 @@ function f(callable $c) {}
 f();
 ?>
 --EXPECTF--
-Fatal error: Uncaught TypeError: Argument 1 passed to f() must be callable, none given, called in %s on line 3 and defined in %s:%d
+Fatal error: Uncaught Error: Too few arguments to function f(), 0 passed in %s on line 3 and exactly 1 expected in %s:2
 Stack trace:
 #0 %s(%d): f()
 #1 {main}
index e3feeed9b0be670d3955779f5cf92ca52e8924be..286b6f422580dc40c60e9d997ab192122a1dbcfe 100644 (file)
@@ -19,4 +19,8 @@ try {
 
 ?>
 --EXPECTF--
-Missing argument 1 for foo(), called in %sbug70689.php on line %d and defined
+Fatal error: Uncaught Error: Too few arguments to function foo(), 0 passed in %sbug70689.php on line 12 and exactly 1 expected in %sbug70689.php:3
+Stack trace:
+#0 %sbug70689.php(12): foo()
+#1 {main}
+  thrown in %sbug70689.php on line 3
index db42ae9307e116ee63cc2893c48464836042c8af..76754f9fba038a0618b0f3752af34f9ff9823b39 100644 (file)
@@ -13,7 +13,11 @@ test(function() { return new stdclass; });
 test(function() { });
 
 $a = function($x) use ($y) {};
-test($a);
+try {
+       test($a);
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 test(new stdclass);
 
@@ -24,9 +28,7 @@ object(stdClass)#%d (0) {
 NULL
 
 Notice: Undefined variable: y in %s on line %d
-
-Warning: Missing argument 1 for {closure}(), called in %s on line %d and defined in %s on line %d
-NULL
+Exception: Too few arguments to function {closure}(), 0 passed in %s on line %d and exactly 1 expected
 
 Fatal error: Uncaught TypeError: Argument 1 passed to test() must be an instance of Closure, instance of stdClass given, called in %s on line %d and defined in %s:%d
 Stack trace:
index 285a623f2b4b677ea692f91fbeebb647e47f8cf3..175ea37e809085d749a308283883fcf6ec1531b9 100644 (file)
@@ -11,7 +11,7 @@ function foo1($arg) {
 function foo2($arg) {
 }
 
-function foo3($arg) {
+function foo3() {
        echo $undef3;
        throw new Exception("test");
 }
index c63efae604b5e110a32681a38f45b144721ae451..09b7690d3cf9758be6dcece4f8cb94136f674197 100644 (file)
@@ -11,7 +11,7 @@ function foo1($arg) {
 function foo2($arg) {
 }
 
-function foo3($arg) {
+function foo3() {
        echo $undef3;
        throw new Exception("test");
 }
index edf3292779308338ca1de3746e2efd51188d6334..c9945046eefb9cfe2f2a31df822adc74ca6b573a 100644 (file)
@@ -11,7 +11,7 @@ function foo1($arg) {
 function foo2($arg) {
 }
 
-function foo3($arg) {
+function foo3() {
        error_reporting(E_ALL|E_STRICT);
        echo $undef3;
        throw new Exception("test");
index 13b25e0daca0765009cd8553da71d64d6d8c6331..5de93bb7d62562fd1c2a931e16241e2044814e10 100644 (file)
@@ -9,7 +9,7 @@ function f(?callable $p) {}
 f();
 
 --EXPECTF--
-Fatal error: Uncaught TypeError: Argument 1 passed to f() must be callable, none given, called in %s on line %d and defined in %s:%d
+Fatal error: Uncaught Error: Too few arguments to function f(), 0 passed in %snullable_type_parameters_do_not_have_default_value.php on line %d and exactly 1 expected in %s:%d
 Stack trace:
 #%d %s
 #%d %s
index 3bec609599e6659aa3a3613e1f00199f7fbd7f33..025276adefa0bf8145d23c236f088c0786eaec0e 100644 (file)
@@ -28,20 +28,20 @@ foreach ($functions as $type => $function) {
     echo "Testing $type:", PHP_EOL;
     try {
         var_dump($function());
-    } catch (TypeError $e) {
+    } catch (Throwable $e) {
         echo "*** Caught " . $e->getMessage() . PHP_EOL;
     }
 }
 echo PHP_EOL . "Done";
 --EXPECTF--
 Testing int:
-*** Caught Argument 1 passed to {closure}() must be of the type integer, none given, called in %s on line %d
+*** Caught Too few arguments to function {closure}(), 0 passed in %s on line %d and exactly 1 expected
 Testing float:
-*** Caught Argument 1 passed to {closure}() must be of the type float, none given, called in %s on line %d
+*** Caught Too few arguments to function {closure}(), 0 passed in %s on line %d and exactly 1 expected
 Testing string:
-*** Caught Argument 1 passed to {closure}() must be of the type string, none given, called in %s on line %d
+*** Caught Too few arguments to function {closure}(), 0 passed in %s on line %d and exactly 1 expected
 Testing bool:
-*** Caught Argument 1 passed to {closure}() must be of the type boolean, none given, called in %s on line %d
+*** Caught Too few arguments to function {closure}(), 0 passed in %s on line %d and exactly 1 expected
 Testing int nullable:
 NULL
 Testing float nullable:
index 935eb25f4caecffa6519341c56f72a5b38536ea2..a41c9dd59432f61168c5c839fbcf2c30b871be03 100644 (file)
@@ -861,60 +861,28 @@ static zend_always_inline int zend_verify_arg_type(zend_function *zf, uint32_t a
        return 1;
 }
 
-static zend_always_inline int zend_verify_missing_arg_type(zend_function *zf, uint32_t arg_num, void **cache_slot)
-{
-       zend_arg_info *cur_arg_info;
-       char *need_msg;
-       zend_class_entry *ce;
-
-       if (EXPECTED(arg_num <= zf->common.num_args)) {
-               cur_arg_info = &zf->common.arg_info[arg_num-1];
-       } else if (UNEXPECTED(zf->common.fn_flags & ZEND_ACC_VARIADIC)) {
-               cur_arg_info = &zf->common.arg_info[zf->common.num_args];
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_missing_arg_error(zend_execute_data *execute_data)
+{
+       zend_execute_data *ptr = EX(prev_execute_data);
+
+       if (ptr && ptr->func && ZEND_USER_CODE(ptr->func->common.type)) {
+               zend_throw_error(NULL, "Too few arguments to function %s%s%s(), %d passed in %s on line %d and %s %d expected",
+                       EX(func)->common.scope ? ZSTR_VAL(EX(func)->common.scope->name) : "",
+                       EX(func)->common.scope ? "::" : "",
+                       ZSTR_VAL(EX(func)->common.function_name),
+                       EX_NUM_ARGS(),
+                       ZSTR_VAL(ptr->func->op_array.filename),
+                       ptr->opline->lineno,
+                       EX(func)->common.required_num_args == EX(func)->common.num_args ? "exactly" : "at least",
+                       EX(func)->common.required_num_args);
        } else {
-               return 1;
-       }
-
-       if (cur_arg_info->type_hint) {
-               if (cur_arg_info->class_name) {
-                       if (EXPECTED(*cache_slot)) {
-                               ce = (zend_class_entry*)*cache_slot;
-                       } else {
-                               ce = zend_verify_arg_class_kind(cur_arg_info);
-                               if (UNEXPECTED(!ce)) {
-                                       zend_verify_arg_error(zf, arg_num, "be an instance of ", ZSTR_VAL(cur_arg_info->class_name), "none", "");
-                                       return 0;
-                               }
-                               *cache_slot = (void*)ce;
-                       }
-                       need_msg =
-                               (ce->ce_flags & ZEND_ACC_INTERFACE) ?
-                               "implement interface " : "be an instance of ";
-                       zend_verify_arg_error(zf, arg_num, need_msg, ZSTR_VAL(ce->name), "none", "");
-               } else if (cur_arg_info->type_hint == IS_CALLABLE) {
-                       zend_verify_arg_error(zf, arg_num, "be callable", "", "none", "");
-               } else {
-                       zend_verify_arg_error(zf, arg_num, "be of the type ", zend_get_type_by_const(cur_arg_info->type_hint), "none", "");
-               }
-               return 0;
-       }
-       return 1;
-}
-
-static ZEND_COLD void zend_verify_missing_arg(zend_execute_data *execute_data, uint32_t arg_num, void **cache_slot)
-{
-       if (EXPECTED(!(EX(func)->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS)) ||
-           UNEXPECTED(zend_verify_missing_arg_type(EX(func), arg_num, cache_slot))) {
-               const char *class_name = EX(func)->common.scope ? ZSTR_VAL(EX(func)->common.scope->name) : "";
-               const char *space = EX(func)->common.scope ? "::" : "";
-               const char *func_name = EX(func)->common.function_name ? ZSTR_VAL(EX(func)->common.function_name) : "main";
-               zend_execute_data *ptr = EX(prev_execute_data);
-
-               if (ptr && ptr->func && ZEND_USER_CODE(ptr->func->common.type)) {
-                       zend_error(E_WARNING, "Missing argument %u for %s%s%s(), called in %s on line %d and defined", arg_num, class_name, space, func_name, ZSTR_VAL(ptr->func->op_array.filename), ptr->opline->lineno);
-               } else {
-                       zend_error(E_WARNING, "Missing argument %u for %s%s%s()", arg_num, class_name, space, func_name);
-               }
+               zend_throw_error(NULL, "Too few arguments to function %s%s%s(), %d passed and %s %d expected",
+                       EX(func)->common.scope ? ZSTR_VAL(EX(func)->common.scope->name) : "",
+                       EX(func)->common.scope ? "::" : "",
+                       ZSTR_VAL(EX(func)->common.function_name),
+                       EX_NUM_ARGS(),
+                       EX(func)->common.required_num_args == EX(func)->common.num_args ? "exactly" : "at least",
+                       EX(func)->common.required_num_args);
        }
 }
 
@@ -3073,11 +3041,6 @@ ZEND_API int ZEND_FASTCALL zend_check_arg_type(zend_function *zf, uint32_t arg_n
        return zend_verify_arg_type(zf, arg_num, arg, default_value, cache_slot);
 }
 
-ZEND_API void ZEND_FASTCALL zend_check_missing_arg(zend_execute_data *execute_data, uint32_t arg_num, void **cache_slot)
-{
-       zend_verify_missing_arg(execute_data, arg_num, cache_slot);
-}
-
 /*
  * Local variables:
  * tab-width: 4
index e70465fdc668664ed539edab640a2e9433b1a9b3..82c6a4a4151d8c6cb9174dc1438afddd815e0e51 100644 (file)
@@ -54,7 +54,7 @@ extern ZEND_API const zend_internal_function zend_pass_function;
 
 ZEND_API void ZEND_FASTCALL zend_check_internal_arg_type(zend_function *zf, uint32_t arg_num, zval *arg);
 ZEND_API int  ZEND_FASTCALL zend_check_arg_type(zend_function *zf, uint32_t arg_num, zval *arg, zval *default_value, void **cache_slot);
-ZEND_API void ZEND_FASTCALL zend_check_missing_arg(zend_execute_data *execute_data, uint32_t arg_num, void **cache_slot);
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_missing_arg_error(zend_execute_data *execute_data);
 
 static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval *value, zend_uchar value_type)
 {
index 300814426e36fa6c1d129169a747e8afe51c961c..4742a62b5860896089ef537f93767d39aca7ab82 100644 (file)
@@ -4720,8 +4720,8 @@ ZEND_VM_HANDLER(63, ZEND_RECV, NUM, ANY)
 
        if (UNEXPECTED(arg_num > EX_NUM_ARGS())) {
                SAVE_OPLINE();
-               zend_verify_missing_arg(execute_data, arg_num, CACHE_ADDR(opline->op2.num));
-               ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
+               zend_missing_arg_error(execute_data);
+               HANDLE_EXCEPTION();
        } else if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
                zval *param = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var);
 
index 23cd944f8b48fc3da541b2acb494bf596c5fe71f..b0da3c043d645b2d7c062e123dd54e6fddca267d 100644 (file)
@@ -1469,8 +1469,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RECV_SPEC_HANDLER(ZEND_OPCODE_
 
        if (UNEXPECTED(arg_num > EX_NUM_ARGS())) {
                SAVE_OPLINE();
-               zend_verify_missing_arg(execute_data, arg_num, CACHE_ADDR(opline->op2.num));
-               ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
+               zend_missing_arg_error(execute_data);
+               HANDLE_EXCEPTION();
        } else if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
                zval *param = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var);
 
index 5ed079d8dd1be52b9f0e9c803a22be87058e93f8..7f1adde613ecf92de85688dc029a58cee9932a1e 100644 (file)
@@ -17,7 +17,11 @@ var_dump(libxml_set_external_entity_loader());
 var_dump(libxml_set_external_entity_loader(function() {}, 2));
 
 var_dump(libxml_set_external_entity_loader(function($a, $b, $c, $d) {}));
-var_dump($dd->validate());
+try {
+       var_dump($dd->validate());
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 echo "Done.\n";
 
@@ -32,8 +36,6 @@ Warning: libxml_set_external_entity_loader() expects exactly 1 parameter, 2 give
 NULL
 bool(true)
 
-Warning: Missing argument 4 for {closure}() in %s on line %d
-
 Warning: DOMDocument::validate(): Could not load the external subset "http://example.com/foobar" in %s on line %d
-bool(false)
+Exception: Too few arguments to function {closure}(), 3 passed and exactly 4 expected
 Done.
index 9706ceac845e2226ea2259ea9bda28b32835b7d1..dff91531ceebba2f30445ae32028c789c4dcd368 100644 (file)
@@ -59,18 +59,25 @@ require_once('skipifconnectfailure.inc');
 
        }
 
-       $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array());
-
-       if (($obj->ID !== "3") || ($obj->label !== "c") || ($obj->a !== NULL) || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) {
-               printf("[006] Object seems wrong. [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-               var_dump($obj);
-       }
+       try {
+               $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array());
+               if (($obj->ID !== "3") || ($obj->label !== "c") || ($obj->a !== NULL) || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) {
+                       printf("[006] Object seems wrong. [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+                       var_dump($obj);
+               }
+       } catch (Throwable $e) {
+               echo "Exception: " . $e->getMessage() . "\n";
+       }       
 
-       $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array('a'));
-       if (($obj->ID !== "4") || ($obj->label !== "d") || ($obj->a !== 'a') || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) {
-               printf("[007] Object seems wrong. [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-               var_dump($obj);
-       }
+       try {
+               $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array('a'));
+               if (($obj->ID !== "4") || ($obj->label !== "d") || ($obj->a !== 'a') || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) {
+                       printf("[007] Object seems wrong. [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+                       var_dump($obj);
+               }
+       } catch (Throwable $e) {
+               echo "Exception: " . $e->getMessage() . "\n";
+       }       
 
        $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array('a', 'b'));
        if (($obj->ID !== "5") || ($obj->label !== "e") || ($obj->a !== 'a') || ($obj->b !== 'b') || (get_class($obj) != 'mysqli_fetch_object_construct')) {
@@ -140,12 +147,8 @@ require_once('skipifconnectfailure.inc');
 --EXPECTF--
 [E_WARNING] mysqli_fetch_object() expects at least 1 parameter, 0 given in %s on line %d
 [E_WARNING] mysqli_fetch_object() expects parameter 1 to be mysqli_result, null given in %s on line %d
-[E_WARNING] Missing argument 1 for mysqli_fetch_object_construct::__construct() in %s on line %d
-[E_WARNING] Missing argument 2 for mysqli_fetch_object_construct::__construct() in %s on line %d
-[E_NOTICE] Undefined variable: a in %s on line %d
-[E_NOTICE] Undefined variable: b in %s on line %d
-[E_WARNING] Missing argument 2 for mysqli_fetch_object_construct::__construct() in %s on line %d
-[E_NOTICE] Undefined variable: b in %s on line %d
+Exception: Too few arguments to function mysqli_fetch_object_construct::__construct(), 0 passed and exactly 2 expected
+Exception: Too few arguments to function mysqli_fetch_object_construct::__construct(), 1 passed and exactly 2 expected
 NULL
 NULL
 [E_WARNING] mysqli_fetch_object(): Couldn't fetch mysqli_result in %s on line %d
index 82e311cc72ac6a71cc737200b33605002bcdc056..8fac044139b1bf3c848ef563b9d4a14b95ef7fa0 100644 (file)
@@ -89,10 +89,14 @@ require_once('skipifconnectfailure.inc');
                mysqli_fetch_object($res);
        }
 
-       $obj = $res->fetch_object('mysqli_fetch_object_construct', array('a'));
-       if (($obj->ID !== "4") || ($obj->label !== "d") || ($obj->a !== 'a') || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) {
-               printf("[010] Object seems wrong. [%d] %s\n", $mysqli->errno, $mysqli->error);
-               var_dump($obj);
+       try {
+               $obj = $res->fetch_object('mysqli_fetch_object_construct', array('a'));
+               if (($obj->ID !== "4") || ($obj->label !== "d") || ($obj->a !== 'a') || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) {
+                       printf("[010] Object seems wrong. [%d] %s\n", $mysqli->errno, $mysqli->error);
+                       var_dump($obj);
+               }
+       } catch (Throwable $e) {
+               echo "Exception: " . $e->getMessage() . "\n";
        }
 
        $obj = $res->fetch_object('mysqli_fetch_object_construct', array('a', 'b'));
@@ -132,8 +136,7 @@ require_once('skipifconnectfailure.inc');
 [0] Argument 2 passed to mysqli_result::fetch_object() must be of the type array, object given in %s on line %d
 [0] Argument 2 passed to mysqli_result::fetch_object() must be of the type array, object given in %s on line %d
 [0] Argument 2 passed to mysqli_result::fetch_object() must be of the type array, null given in %s on line %d
-[E_WARNING] Missing argument 2 for mysqli_fetch_object_construct::__construct() in %s on line %d
-[E_NOTICE] Undefined variable: b in %s on line %d
+Exception: Too few arguments to function mysqli_fetch_object_construct::__construct(), 1 passed and exactly 2 expected
 NULL
 NULL
 [E_WARNING] mysqli_fetch_object(): Couldn't fetch mysqli_result in %s on line %d
index 46b3d0950e1626c289ca0d128c78f07fdaf233a8..04bf483c1a4ef08ea26052893bfb070f424a80ca 100644 (file)
@@ -2894,12 +2894,6 @@ static void zend_update_type_info(const zend_op_array *op_array,
                        if (func_info && (int)opline->op1.num-1 < func_info->num_args) {
                                tmp = (tmp & (MAY_BE_RC1|MAY_BE_RCN|MAY_BE_REF)) |
                                        (tmp & func_info->arg_info[opline->op1.num-1].info.type);
-                       } else {
-                               if (opline->opcode == ZEND_RECV && (!arg_info || arg_info->type_hint == IS_UNDEF)) {
-                                       /* If the argument has no default value and no typehint, it is possible
-                                        * to pass less arguments than the function expects */
-                                       tmp |= MAY_BE_UNDEF|MAY_BE_RC1;
-                               }
                        }
 #if 0
                        /* We won't recieve unused arguments */
index 004158ccffad61b3199e1eff9e6ce6e49d2af409..d9204171b564ef08ad5d6a63e462cfff05191930 100644 (file)
@@ -25,6 +25,10 @@ function test($class)
        {
                var_dump($e->getMessage());
        }
+       catch (Throwable $e)
+       {
+               echo "Exception: " . $e->getMessage() . "\n";
+       }
        
        echo "====>newInstance(25)\n";
        try
@@ -129,15 +133,7 @@ object(WithCtor)#%d (0) {
 
 ====>WithCtorWithArgs
 ====>newInstance()
-
-Warning: Missing argument 1 for WithCtorWithArgs::__construct() in %s007.php on line %d
-
-Notice: Undefined variable: arg in %s007.php on line %d
-WithCtorWithArgs::__construct()
-array(0) {
-}
-object(WithCtorWithArgs)#%d (0) {
-}
+Exception: Too few arguments to function WithCtorWithArgs::__construct(), 0 passed and exactly 1 expected
 ====>newInstance(25)
 WithCtorWithArgs::__construct(25)
 array(1) {
index d3a426de4c02f42562e56c3502d3b8f57e60260c..3ad654dd8495c8a7bb9be40768423e11d56785d4 100644 (file)
@@ -38,13 +38,27 @@ $rcC = new ReflectionClass('C');
 $rcD = new ReflectionClass('D');
 $rcE = new ReflectionClass('E');
 
-$a1 = $rcA->newInstanceArgs();
-$a2 = $rcA->newInstanceArgs(array('x'));
-var_dump($a1, $a2);
+try {
+       var_dump($rcA->newInstanceArgs());
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
+try {
+       var_dump($rcA->newInstanceArgs(array('x')));
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
-$b1 = $rcB->newInstanceArgs();
-$b2 = $rcB->newInstanceArgs(array('x', 123));
-var_dump($b1, $b2);
+try {
+       var_dump($rcB->newInstanceArgs());
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
+try {
+       var_dump($rcB->newInstanceArgs(array('x', 123)));
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 try {
        $rcC->newInstanceArgs();
@@ -73,25 +87,15 @@ try {
 --EXPECTF--
 Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in %s on line %d
 In constructor of class A
-In constructor of class A
 object(A)#%d (0) {
 }
+In constructor of class A
 object(A)#%d (0) {
 }
-
-Warning: Missing argument 1 for B::__construct() in %s on line 9
-
-Warning: Missing argument 2 for B::__construct() in %s on line 9
-
-Notice: Undefined variable: a in %s on line 10
-
-Notice: Undefined variable: b in %s on line 10
-In constructor of class B with args , 
+Exception: Too few arguments to function B::__construct(), 0 passed and exactly 2 expected
 In constructor of class B with args x, 123
 object(B)#%d (0) {
 }
-object(B)#%d (0) {
-}
 Access to non-public constructor of class C
 Access to non-public constructor of class D
 object(E)#%d (0) {
index afa278a9a19a5a55416d0a89068bd83a79f41be3..e29cc8734f4e47c63e0f8f183d129198b1d5a49e 100644 (file)
@@ -42,9 +42,16 @@ $a1 = $rcA->newInstance();
 $a2 = $rcA->newInstance('x');
 var_dump($a1, $a2);
 
-$b1 = $rcB->newInstance();
-$b2 = $rcB->newInstance('x', 123);
-var_dump($b1, $b2);
+try {
+       var_dump($rcB->newInstance());
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
+try {
+       var_dump($rcB->newInstance('x', 123));
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 try {
        $rcC->newInstance();
@@ -78,20 +85,10 @@ object(A)#%d (0) {
 }
 object(A)#%d (0) {
 }
-
-Warning: Missing argument 1 for B::__construct() in %s on line 9
-
-Warning: Missing argument 2 for B::__construct() in %s on line 9
-
-Notice: Undefined variable: a in %s on line 10
-
-Notice: Undefined variable: b in %s on line 10
-In constructor of class B with args , 
+Exception: Too few arguments to function B::__construct(), 0 passed and exactly 2 expected
 In constructor of class B with args x, 123
 object(B)#%d (0) {
 }
-object(B)#%d (0) {
-}
 Access to non-public constructor of class C
 Access to non-public constructor of class D
 object(E)#%d (0) {
index ac97e3ed2a4470500957880a58955e02d3d80250..c9d1e6379a91d322d30398d201a58c7c0f9542b7 100644 (file)
@@ -25,12 +25,9 @@ var_dump($methodWithArgs->invokeArgs($testClassInstance, array()));
 --EXPECTF--
 Method with args:
 
-Warning: Missing argument 1 for TestClass::methodWithArgs() in %s on line %d
-
-Warning: Missing argument 2 for TestClass::methodWithArgs() in %s on line %d
-
-Notice: Undefined variable: a in %s on line %d
-
-Notice: Undefined variable: b in %s on line %d
-Called methodWithArgs(, )
-NULL
+Fatal error: Uncaught Error: Too few arguments to function TestClass::methodWithArgs(), 0 passed and exactly 2 expected in %sReflectionMethod_invokeArgs_error1.php:5
+Stack trace:
+#0 [internal function]: TestClass->methodWithArgs()
+#1 %sReflectionMethod_invokeArgs_error1.php(19): ReflectionMethod->invokeArgs(Object(TestClass), Array)
+#2 {main}
+  thrown in %sReflectionMethod_invokeArgs_error1.php on line 5
index a070c8f583131d6d23ddb75498febe3d50baad86..60a9ebae974ca09fe35769d059c20c4bdebbc3bf 100644 (file)
@@ -21,12 +21,9 @@ var_dump($methodWithArgs->invoke($testClassInstance));
 --EXPECTF--
 Method with args:
 
-Warning: Missing argument 1 for TestClass::methodWithArgs() in %s on line %d
-
-Warning: Missing argument 2 for TestClass::methodWithArgs() in %s on line %d
-
-Notice: Undefined variable: a in %s on line %d
-
-Notice: Undefined variable: b in %s on line %d
-Called methodWithArgs(, )
-NULL
+Fatal error: Uncaught Error: Too few arguments to function TestClass::methodWithArgs(), 0 passed and exactly 2 expected in %sReflectionMethod_invoke_error2.php:5
+Stack trace:
+#0 [internal function]: TestClass->methodWithArgs()
+#1 %sReflectionMethod_invoke_error2.php(15): ReflectionMethod->invoke(Object(TestClass))
+#2 {main}
+  thrown in %sReflectionMethod_invoke_error2.php on line 5
index cf007d95478e6a235f6d4db5706025c4f7b2a3e9..988f1c8953289d224b88ba9fa7277a5e0a1c2082 100644 (file)
@@ -18,7 +18,11 @@ class Object1 {
 }
 
 $class= new ReflectionClass('Object1');
-var_dump($class->newInstanceArgs());
+try {
+       var_dump($class->newInstanceArgs());
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 var_dump($class->newInstanceArgs(array('test')));
 
 
@@ -27,13 +31,7 @@ echo "Done\n";
 --EXPECTF--    
 object(Object)#%d (0) {
 }
-
-Warning: Missing argument 1 for Object1::__construct() in %s on line %d
-
-Notice: Undefined variable: var in %s on line %d
-NULL
-object(Object1)#%d (0) {
-}
+Exception: Too few arguments to function Object1::__construct(), 0 passed and exactly 1 expected
 string(4) "test"
 object(Object1)#%d (0) {
 }
index 6a4fb2580bc2f29e2c1ef7ac14ef578525b87bc7..219696c263eff0356cd260280507c906d0521acb 100644 (file)
@@ -6,7 +6,7 @@ Bug #38005 (SoapFault faultstring doesn't follow encoding rules)
 soap.wsdl_cache_enabled=0
 --FILE--
 <?php
-function Test($param) {
+function Test($param=NULL) {
        return new SoapFault('Test', 'This is our fault: Ã„');
 }
 
index fbdc855a7ea8b543d3ff41f4d072f5a43cd6432c..e27712241f5b6646120577f6a5700f260be20f14 100644 (file)
@@ -90,7 +90,7 @@ class Soap12test {
                return count($input);
        }
 
-       function isNil($input) {
+       function isNil($input=NULL) {
                return is_null($input);
        }
 
index f0a6115f79ccf583d21ba1c1fe523b349b55252e..b23618794ea1c545d4c92ea91342b332b2bdc358 100644 (file)
@@ -34,7 +34,11 @@ var_dump( array_filter($input, 'dump2', true) );
 
 echo "*** Testing array_filter() : usage variations - 'callback' expecting second argument ***\n";
 
-var_dump( array_filter($small, 'dump', false) );
+try {
+       var_dump( array_filter($small, 'dump', false) );
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 echo "*** Testing array_filter() with various use types ***\n";
 
@@ -70,13 +74,7 @@ array(3) {
   NULL
 }
 *** Testing array_filter() : usage variations - 'callback' expecting second argument ***
-
-Warning: Missing argument 2 for dump() in %s on line %d
-
-Notice: Undefined variable: key in %s on line %d
- = 123
-array(0) {
-}
+Exception: Too few arguments to function dump(), 1 passed and exactly 2 expected
 *** Testing array_filter() with various use types ***
 array(2) {
   [1]=>
@@ -91,13 +89,13 @@ array(2) {
   int(2)
 }
 
-Warning: is_numeric() expects exactly 1 parameter, 2 given in %s on line 44
+Warning: is_numeric() expects exactly 1 parameter, 2 given in %s on line 48
 
-Warning: is_numeric() expects exactly 1 parameter, 2 given in %s on line 44
+Warning: is_numeric() expects exactly 1 parameter, 2 given in %s on line 48
 
-Warning: is_numeric() expects exactly 1 parameter, 2 given in %s on line 44
+Warning: is_numeric() expects exactly 1 parameter, 2 given in %s on line 48
 
-Warning: is_numeric() expects exactly 1 parameter, 2 given in %s on line 44
+Warning: is_numeric() expects exactly 1 parameter, 2 given in %s on line 48
 array(0) {
 }
 Done
index 7c623ec4ea006a6b2d03eb07dfbfe4217b04df65..56dd033521e06586d6c2c52b0c969ed9257045b5 100644 (file)
@@ -18,14 +18,22 @@ echo "\n-- Testing array_map() function with one less than expected no. of argum
 function callback1() {
   return 1;
 }
-var_dump( array_map('callback1') );
+try {
+       var_dump( array_map('callback1') );
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 echo "\n-- Testing array_map() function with less no. of arrays than callback function arguments --\n";
 $arr1 = array(1, 2);
 function callback2($p, $q) {
   return $p * $q;
 }
-var_dump( array_map('callback2', $arr1) );
+try {
+       var_dump( array_map('callback2', $arr1) );
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 echo "\n-- Testing array_map() function with more no. of arrays than callback function arguments --\n";
 $arr2 = array(3, 4);
@@ -48,20 +56,7 @@ Warning: array_map() expects at least 2 parameters, 1 given in %s on line %d%d
 NULL
 
 -- Testing array_map() function with less no. of arrays than callback function arguments --
-
-Warning: Missing argument 2 for callback2() in %s on line %d%d
-
-Notice: Undefined variable: q in %s on line %d%d
-
-Warning: Missing argument 2 for callback2() in %s on line %d%d
-
-Notice: Undefined variable: q in %s on line %d%d
-array(2) {
-  [0]=>
-  int(0)
-  [1]=>
-  int(0)
-}
+Exception: Too few arguments to function callback2(), 1 passed and exactly 2 expected
 
 -- Testing array_map() function with more no. of arrays than callback function arguments --
 array(2) {
index cc75436999d08a0d1a7a88251a5d3e18e374ede2..ecf91576207e723b6f44b816aa974453749beb17 100644 (file)
@@ -20,7 +20,11 @@ echo "-- anonymous function with all parameters and body --\n";
 var_dump( array_map( create_function('$a, $b', 'return array($a, $b);'), $array1, $array2));
 
 echo "-- anonymous function with two parameters and passing one array --\n";
-var_dump( array_map( create_function('$a, $b', 'return array($a, $b);'), $array1));
+try {
+       var_dump( array_map( create_function('$a, $b', 'return array($a, $b);'), $array1));
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 echo "-- anonymous function with NULL parameter --\n";
 var_dump( array_map( create_function(NULL, 'return NULL;'), $array1));
@@ -60,41 +64,7 @@ array(3) {
   }
 }
 -- anonymous function with two parameters and passing one array --
-
-Warning: Missing argument 2 for __lambda_func() in %s(20) : runtime-created function on line %d
-
-Notice: Undefined variable: b in %s(20) : runtime-created function on line %d
-
-Warning: Missing argument 2 for __lambda_func() in %s(20) : runtime-created function on line %d
-
-Notice: Undefined variable: b in %s(20) : runtime-created function on line %d
-
-Warning: Missing argument 2 for __lambda_func() in %s(20) : runtime-created function on line %d
-
-Notice: Undefined variable: b in %s(20) : runtime-created function on line %d
-array(3) {
-  [0]=>
-  array(2) {
-    [0]=>
-    int(1)
-    [1]=>
-    NULL
-  }
-  [1]=>
-  array(2) {
-    [0]=>
-    int(2)
-    [1]=>
-    NULL
-  }
-  [2]=>
-  array(2) {
-    [0]=>
-    int(3)
-    [1]=>
-    NULL
-  }
-}
+Exception: Too few arguments to function __lambda_func(), 1 passed and exactly 2 expected
 -- anonymous function with NULL parameter --
 array(3) {
   [0]=>
index f029beccd6d400f8094d082e3e33960879fe99dc..f33b717c6c9c275abe298cca337fcc78a2222b48 100644 (file)
@@ -29,7 +29,11 @@ echo "-- checking binary safe array with one parameter callback function --\n";
 var_dump( array_map('callback1', $arr1) );
 
 echo "-- checking binary safe array with two parameter callback function --\n";
-var_dump( array_map(b"callback2", $arr1) );
+try {
+       var_dump( array_map(b"callback2", $arr1) );
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 echo "Done";
 ?>
@@ -47,42 +51,5 @@ array(4) {
   string(5) "22.22"
 }
 -- checking binary safe array with two parameter callback function --
-
-Warning: Missing argument 2 for callback2() in %s on line %d%d
-
-Notice: Undefined variable: b in %s on line %d%d
-
-Warning: Missing argument 2 for callback2() in %s on line %d%d
-
-Notice: Undefined variable: b in %s on line %d%d
-
-Warning: Missing argument 2 for callback2() in %s on line %d%d
-
-Notice: Undefined variable: b in %s on line %d%d
-
-Warning: Missing argument 2 for callback2() in %s on line %d%d
-
-Notice: Undefined variable: b in %s on line %d%d
-array(4) {
-  [0]=>
-  array(1) {
-    ["hello"]=>
-    NULL
-  }
-  [1]=>
-  array(1) {
-    ["world"]=>
-    NULL
-  }
-  [2]=>
-  array(1) {
-    [1]=>
-    NULL
-  }
-  [3]=>
-  array(1) {
-    ["22.22"]=>
-    NULL
-  }
-}
+Exception: Too few arguments to function callback2(), 1 passed and exactly 2 expected
 Done
index b02a82a7ca3eca95bc701027cf5d0ca3fb1650ff..adffeb53d4c8a35f4e8833448098a287b04b9edd 100644 (file)
@@ -25,7 +25,11 @@ echo "\n--- Testing with a callback with too few parameters ---\n";
 var_dump(array_reduce($array, "oneArg", 2));
 
 echo "\n--- Testing with a callback with too many parameters ---\n";
-var_dump(array_reduce($array, "threeArgs", 2));
+try {
+       var_dump(array_reduce($array, "threeArgs", 2));
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 ?>
 ===DONE===
@@ -36,9 +40,5 @@ var_dump(array_reduce($array, "threeArgs", 2));
 int(2)
 
 --- Testing with a callback with too many parameters ---
-
-Warning: Missing argument 3 for threeArgs() in %sarray_reduce_variation1.php on line %d
-
-Notice: Undefined variable: x in %sarray_reduce_variation1.php on line %d
-int(3)
-===DONE===
\ No newline at end of file
+Exception: Too few arguments to function threeArgs(), 2 passed and exactly 3 expected
+===DONE===
index 69380767bba7532b46569c2f892a104656cb39a4..6b7f014467452f013ab5b7553eecd732c8e046bf 100644 (file)
@@ -24,7 +24,11 @@ echo "\n-- comparison function taking too many parameters --\n";
 function too_many_parameters ($val1, $val2, $val3) {
   return 1;
 }
-var_dump(array_udiff_assoc($arr1, $arr2, 'too_many_parameters'));
+try {
+       var_dump(array_udiff_assoc($arr1, $arr2, 'too_many_parameters'));
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 echo "\n-- comparison function taking too few parameters --\n";
 function too_few_parameters ($val1) {
@@ -32,7 +36,6 @@ function too_few_parameters ($val1) {
 }
 var_dump(array_udiff_assoc($arr1, $arr2, 'too_few_parameters'));
 
-
 ?>
 ===DONE===
 --EXPECTF--
@@ -45,12 +48,7 @@ array(1) {
 }
 
 -- comparison function taking too many parameters --
-
-Warning: Missing argument 3 for too_many_parameters() in %sarray_udiff_assoc_variation5.php on line %d
-array(1) {
-  [0]=>
-  int(1)
-}
+Exception: Too few arguments to function too_many_parameters(), 2 passed and exactly 3 expected
 
 -- comparison function taking too few parameters --
 array(1) {
index ec752a31bb256dd3e909bdfbfb4bd4480248f5b7..bf2c0f3d2d51feccdc04507d86e4cf0f602aec77 100644 (file)
@@ -23,7 +23,11 @@ echo "\n-- comparison function taking too many parameters --\n";
 function too_many_parameters ($val1, $val2, $val3) {
   return 1;
 }
-var_dump(array_udiff_uassoc($arr1, $arr2, 'too_many_parameters', 'too_many_parameters'));
+try {
+       var_dump(array_udiff_uassoc($arr1, $arr2, 'too_many_parameters', 'too_many_parameters'));
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 echo "\n-- comparison function taking too few parameters --\n";
 function too_few_parameters ($val1) {
@@ -43,12 +47,7 @@ array(1) {
 }
 
 -- comparison function taking too many parameters --
-
-Warning: Missing argument 3 for too_many_parameters() in %sarray_udiff_uassoc_variation6.php on line %d
-array(1) {
-  [0]=>
-  int(1)
-}
+Exception: Too few arguments to function too_many_parameters(), 2 passed and exactly 3 expected
 
 -- comparison function taking too few parameters --
 array(1) {
index 49405d40be89458d15d9ef140bf5e633d37e085b..ce6362fc08e716213f702a28999918a7ee232157 100644 (file)
@@ -24,7 +24,11 @@ echo "\n-- comparison function taking too many parameters --\n";
 function too_many_parameters ($val1, $val2, $val3) {
   return 0;
 }
-var_dump(array_udiff($arr1, $arr2, 'too_many_parameters'));
+try {
+       var_dump(array_udiff($arr1, $arr2, 'too_many_parameters'));
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 echo "\n-- comparison function taking too few parameters --\n";
 function too_few_parameters ($val1) {
@@ -44,10 +48,7 @@ array(1) {
 }
 
 -- comparison function taking too many parameters --
-
-Warning: Missing argument 3 for too_many_parameters() in %sarray_udiff_variation5.php on line %d
-array(0) {
-}
+Exception: Too few arguments to function too_many_parameters(), 2 passed and exactly 3 expected
 
 -- comparison function taking too few parameters --
 array(0) {
index e2d7bd03a6ec84c5a090a6c087bf66429be3c6ff..bebe5b52c97b54792a3d0269b4e9fce47e98c068 100644 (file)
@@ -23,7 +23,11 @@ echo "\n-- comparison function taking too many parameters --\n";
 function too_many_parameters ($val1, $val2, $val3) {
   return 1;
 }
-var_dump(array_uintersect_assoc($arr1, $arr2, 'too_many_parameters'));
+try {
+       var_dump(array_uintersect_assoc($arr1, $arr2, 'too_many_parameters'));
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 echo "\n-- comparison function taking too few parameters --\n";
 function too_few_parameters ($val1) {
@@ -42,10 +46,7 @@ array(0) {
 }
 
 -- comparison function taking too many parameters --
-
-Warning: Missing argument 3 for too_many_parameters() in %sarray_uintersect_assoc_variation5.php on line %d
-array(0) {
-}
+Exception: Too few arguments to function too_many_parameters(), 2 passed and exactly 3 expected
 
 -- comparison function taking too few parameters --
 array(0) {
index 6ed86f8417f498e66029b19cd3807c21936f12a9..a5317c1c0d943caa33c7f9dac86881204067f6b6 100644 (file)
@@ -23,7 +23,11 @@ echo "\n-- comparison function taking too many parameters --\n";
 function too_many_parameters ($val1, $val2, $val3) {
   return 1;
 }
-var_dump(array_uintersect_uassoc($arr1, $arr2, 'too_many_parameters', 'too_many_parameters'));
+try {
+       var_dump(array_uintersect_uassoc($arr1, $arr2, 'too_many_parameters', 'too_many_parameters'));
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 echo "\n-- comparison function taking too few parameters --\n";
 function too_few_parameters ($val1) {
@@ -41,14 +45,7 @@ array(0) {
 }
 
 -- comparison function taking too many parameters --
-
-Warning: Missing argument 3 for too_many_parameters() in %sarray_uintersect_uassoc_variation6.php on line %d
-
-Warning: Missing argument 3 for too_many_parameters() in %sarray_uintersect_uassoc_variation6.php on line %d
-
-Warning: Missing argument 3 for too_many_parameters() in %sarray_uintersect_uassoc_variation6.php on line %d
-array(0) {
-}
+Exception: Too few arguments to function too_many_parameters(), 2 passed and exactly 3 expected
 
 -- comparison function taking too few parameters --
 array(0) {
index 75cf08e270532348bf715cf747242f5d1eefac45..642ebc0077576370d00f9475af95c5cdac97ed68 100644 (file)
@@ -23,7 +23,11 @@ echo "\n-- comparison function taking too many parameters --\n";
 function too_many_parameters ($val1, $val2, $val3) {
   return 1;
 }
-var_dump(array_uintersect($arr1, $arr2, 'too_many_parameters'));
+try {
+       var_dump(array_uintersect($arr1, $arr2, 'too_many_parameters'));
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 echo "\n-- comparison function taking too few parameters --\n";
 function too_few_parameters ($val1) {
@@ -42,14 +46,7 @@ array(0) {
 }
 
 -- comparison function taking too many parameters --
-
-Warning: Missing argument 3 for too_many_parameters() in %sarray_uintersect_variation5.php on line %d
-
-Warning: Missing argument 3 for too_many_parameters() in %sarray_uintersect_variation5.php on line %d
-
-Warning: Missing argument 3 for too_many_parameters() in %sarray_uintersect_variation5.php on line %d
-array(0) {
-}
+Exception: Too few arguments to function too_many_parameters(), 2 passed and exactly 3 expected
 
 -- comparison function taking too few parameters --
 array(0) {
index 63c5f51ee090eaa8f322b5ed1eab13996975e29d..fd3cbf5037cb79f6d0712aff83fdebf5209ebad3 100644 (file)
@@ -22,36 +22,44 @@ function callback2($value, $key, $user_data1, $user_data2) {
 echo "*** Testing array_walk() : error conditions - callback parameters ***\n";
 
 // expected: Missing argument Warning
-var_dump( array_walk($input, "callback1") );
-var_dump( array_walk($input, "callback2", 4) );
+try {
+       var_dump( array_walk($input, "callback1") );
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
+try {
+       var_dump( array_walk($input, "callback2", 4) );
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 // expected: Warning is suppressed
-var_dump( @array_walk($input, "callback1") );  
-var_dump( @array_walk($input, "callback2", 4) );  
+try {
+       var_dump( @array_walk($input, "callback1") );  
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
+try {
+       var_dump( @array_walk($input, "callback2", 4) );  
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 echo "-- Testing array_walk() function with too many callback parameters --\n";
-var_dump( array_walk($input, "callback1", 20, 10) );
+try {
+       var_dump( array_walk($input, "callback1", 20, 10) );
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 echo "Done";
 ?>
 --EXPECTF--
 *** Testing array_walk() : error conditions - callback parameters ***
-
-Warning: Missing argument 3 for callback1() in %s on line %d
-
-callback1() invoked 
-bool(true)
-
-Warning: Missing argument 4 for callback2() in %s on line %d
-
-callback2() invoked 
-bool(true)
-
-callback1() invoked 
-bool(true)
-
-callback2() invoked 
-bool(true)
+Exception: Too few arguments to function callback1(), 2 passed and exactly 3 expected
+Exception: Too few arguments to function callback2(), 3 passed and exactly 4 expected
+Exception: Too few arguments to function callback1(), 2 passed and exactly 3 expected
+Exception: Too few arguments to function callback2(), 3 passed and exactly 4 expected
 -- Testing array_walk() function with too many callback parameters --
 
 Warning: array_walk() expects at most 3 parameters, 4 given in %s on line %d
index 8e0c8829e632ff47e7bf3fe595c31afac8af2189..5a077c68869d15d3795d0828dc41c9611a6c00ce 100644 (file)
@@ -22,36 +22,44 @@ function callback2($value, $key, $user_data1, $user_data2) {
 echo "*** Testing array_walk_recursive() : error conditions - callback parameters ***\n";
 
 // expected: Missing argument Warning
-var_dump( array_walk_recursive($input, "callback1") );
-var_dump( array_walk_recursive($input, "callback2", 4) );
+try {
+       var_dump( array_walk_recursive($input, "callback1") );
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
+try {
+       var_dump( array_walk_recursive($input, "callback2", 4) );
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 // expected: Warning is suppressed
-var_dump( @array_walk_recursive($input, "callback1") );  
-var_dump( @array_walk_recursive($input, "callback2", 4) );  
+try {
+       var_dump( @array_walk_recursive($input, "callback1") );  
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
+try {
+       var_dump( @array_walk_recursive($input, "callback2", 4) );  
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 echo "-- Testing array_walk_recursive() function with too many callback parameters --\n";
-var_dump( array_walk_recursive($input, "callback1", 20, 10) );
+try {
+       var_dump( array_walk_recursive($input, "callback1", 20, 10) );
+} catch (Throwable $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
 
 echo "Done";
 ?>
 --EXPECTF--
 *** Testing array_walk_recursive() : error conditions - callback parameters ***
-
-Warning: Missing argument 3 for callback1() in %s on line %d
-
-callback1() invoked 
-bool(true)
-
-Warning: Missing argument 4 for callback2() in %s on line %d
-
-callback2() invoked 
-bool(true)
-
-callback1() invoked 
-bool(true)
-
-callback2() invoked 
-bool(true)
+Exception: Too few arguments to function callback1(), 2 passed and exactly 3 expected
+Exception: Too few arguments to function callback2(), 3 passed and exactly 4 expected
+Exception: Too few arguments to function callback1(), 2 passed and exactly 3 expected
+Exception: Too few arguments to function callback2(), 3 passed and exactly 4 expected
 -- Testing array_walk_recursive() function with too many callback parameters --
 
 Warning: array_walk_recursive() expects at most 3 parameters, 4 given in %s on line %d
index 41a7197535e26fb27228752009aa7212d0578c05..7861d435c83e499a4293b889bdd97f86843b4cda 100644 (file)
@@ -22,8 +22,11 @@ echo "If this is printed BAIL hasn't worked";
 --EXPECTF--
 int(0)
 
-Warning: Missing argument 4 for f1() in %s on line 2
-f1 called
-
 Warning: assert(): Assertion "0 != 0" failed in %s on line 9
 
+Fatal error: Uncaught Error: Too few arguments to function f1(), 3 passed and exactly 4 expected in %sassert_error2.php:2
+Stack trace:
+#0 [internal function]: f1('%s', 9, '0 != 0')
+#1 %sassert_error2.php(9): assert('0 != 0')
+#2 {main}
+  thrown in %sassert_error2.php on line 2
index 07e413b92b9218114cb70a0ce6b916cf6f3ced1e..4a2953ea7923b76c91d00d2cc0d8b9e8ede0b776 100644 (file)
@@ -7,7 +7,7 @@ class VariableStream {
        var $position;
        var $varname;
 
-       function __construct($var) {
+       function __construct($var=null) {
                var_dump("constructor!");
        }
 
@@ -102,7 +102,6 @@ var_dump($myvar);
 echo "Done\n";
 ?>
 --EXPECTF--    
-Warning: Missing argument 1 for VariableStream::__construct() in %s on line %d
 string(12) "constructor!"
 line1
 line2
index 07e413b92b9218114cb70a0ce6b916cf6f3ced1e..d0682186f9f379fea618b78d428573b13999c748 100644 (file)
@@ -7,7 +7,7 @@ class VariableStream {
        var $position;
        var $varname;
 
-       function __construct($var) {
+       function __construct($var = null) {
                var_dump("constructor!");
        }
 
@@ -102,7 +102,6 @@ var_dump($myvar);
 echo "Done\n";
 ?>
 --EXPECTF--    
-Warning: Missing argument 1 for VariableStream::__construct() in %s on line %d
 string(12) "constructor!"
 line1
 line2
index 7934bb40f5573bb22325026bb9f313e8f1fc75b0..64c9f8d94a22d98554a4020dde22615fc77cbf34 100644 (file)
@@ -7,7 +7,7 @@ class VariableStream {
        var $position;
        var $varname;
 
-       function __construct($var) {
+       function __construct($var = null) {
                throw new Exception("constructor");
        }
 
@@ -102,7 +102,6 @@ var_dump($myvar);
 echo "Done\n";
 ?>
 --EXPECTF--    
-Warning: Missing argument 1 for VariableStream::__construct() in %s on line %d
 
 Warning: fopen(var://myvar): failed to open stream: "VariableStream::stream_open" call failed in %s on line %d
 
index f2c4643ef3ec46ab7df64ce91ae9db597d538dec..07c5958ab4ef84ce4f80bbf54d1cdc445b310709 100644 (file)
@@ -104,7 +104,7 @@ echo "Done\n";
 --EXPECTF--    
 Warning: fopen(var://myvar): failed to open stream: "VariableStream::stream_open" call failed in %sbug38450_3.php on line %d
 
-Fatal error: Uncaught TypeError: Argument 1 passed to VariableStream::__construct() must be of the type array, none given in %s:%d
+Fatal error: Uncaught Error: Too few arguments to function VariableStream::__construct(), 0 passed and exactly 1 expected in %sbug38450_3.php:7
 Stack trace:
 #0 [internal function]: VariableStream->__construct()
 #1 %s(%d): fopen('var://myvar', 'r+')
index e1cbfdaf54e8adb1c4474c8db4562447d5c55707..e66a86491c21d67e5f54620321b8df5165f443dc 100644 (file)
@@ -23,7 +23,7 @@ $obj = new MyTestClass;
 ===DONE===
 --EXPECTF--
 
-Fatal error: Uncaught TypeError: Argument 1 passed to MyTestClass::__construct() must be an instance of MyObject, none given, called in %sinterfaces_003.php:%d
+Fatal error: Uncaught Error: Too few arguments to function MyTestClass::__construct(), 0 passed in %sinterfaces_003.php on line 17 and exactly 1 expected in %sinterfaces_003.php:12
 Stack trace:
 #0 %s(%d): MyTestClass->__construct()
 #1 {main}