summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2016-06-16 02:32:02 +0300
committerDmitry Stogov <dmitry@zend.com>2016-06-16 02:32:02 +0300
commitff363e2e7c58353b7e2751d1ca4d7bf616862aae (patch)
tree318bcb9b453c607f1d49c114999895748903b3da
parenta9512af8109e889eb2c6042c57797184930667cd (diff)
downloadphp-git-ff363e2e7c58353b7e2751d1ca4d7bf616862aae.tar.gz
Implemented RFC: Replace "Missing argument" warning with "Too few arguments" exception
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.
-rw-r--r--Zend/tests/001.phpt21
-rw-r--r--Zend/tests/002.phpt31
-rw-r--r--Zend/tests/003.phpt24
-rw-r--r--Zend/tests/bug33996.phpt22
-rw-r--r--Zend/tests/bug38047.phpt10
-rw-r--r--Zend/tests/bug55705.phpt2
-rw-r--r--Zend/tests/bug70689.phpt6
-rw-r--r--Zend/tests/closure_027.phpt10
-rw-r--r--Zend/tests/error_reporting06.phpt2
-rw-r--r--Zend/tests/error_reporting07.phpt2
-rw-r--r--Zend/tests/error_reporting08.phpt2
-rw-r--r--Zend/tests/nullable_types/nullable_type_parameters_do_not_have_default_value.phpt2
-rw-r--r--Zend/tests/type_declarations/scalar_none.phpt10
-rw-r--r--Zend/zend_execute.c79
-rw-r--r--Zend/zend_execute.h2
-rw-r--r--Zend/zend_vm_def.h4
-rw-r--r--Zend/zend_vm_execute.h4
-rw-r--r--ext/libxml/tests/libxml_set_external_entity_loader_error1.phpt10
-rw-r--r--ext/mysqli/tests/mysqli_fetch_object.phpt37
-rw-r--r--ext/mysqli/tests/mysqli_fetch_object_oo.phpt15
-rw-r--r--ext/opcache/Optimizer/zend_inference.c6
-rw-r--r--ext/reflection/tests/007.phpt14
-rw-r--r--ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt40
-rw-r--r--ext/reflection/tests/ReflectionClass_newInstance_001.phpt25
-rw-r--r--ext/reflection/tests/ReflectionMethod_invokeArgs_error1.phpt15
-rw-r--r--ext/reflection/tests/ReflectionMethod_invoke_error2.phpt15
-rw-r--r--ext/reflection/tests/bug38217.phpt14
-rw-r--r--ext/soap/tests/bugs/bug38005.phpt2
-rw-r--r--ext/soap/tests/soap12/soap12-test.inc2
-rw-r--r--ext/standard/tests/array/array_filter_variation10.phpt22
-rw-r--r--ext/standard/tests/array/array_map_error.phpt27
-rw-r--r--ext/standard/tests/array/array_map_variation10.phpt42
-rw-r--r--ext/standard/tests/array/array_map_variation9.phpt45
-rw-r--r--ext/standard/tests/array/array_reduce_variation1.phpt14
-rw-r--r--ext/standard/tests/array/array_udiff_assoc_variation5.phpt14
-rw-r--r--ext/standard/tests/array/array_udiff_uassoc_variation6.phpt13
-rw-r--r--ext/standard/tests/array/array_udiff_variation5.phpt11
-rw-r--r--ext/standard/tests/array/array_uintersect_assoc_variation5.phpt11
-rw-r--r--ext/standard/tests/array/array_uintersect_uassoc_variation6.phpt15
-rw-r--r--ext/standard/tests/array/array_uintersect_variation5.phpt15
-rw-r--r--ext/standard/tests/array/array_walk_error2.phpt50
-rw-r--r--ext/standard/tests/array/array_walk_recursive_error2.phpt50
-rw-r--r--ext/standard/tests/assert/assert_error2.phpt9
-rw-r--r--ext/standard/tests/file/bug38450.phpt3
-rw-r--r--ext/standard/tests/file/bug38450_1.phpt3
-rw-r--r--ext/standard/tests/file/bug38450_2.phpt3
-rw-r--r--ext/standard/tests/file/bug38450_3.phpt2
-rw-r--r--tests/classes/interfaces_003.phpt2
48 files changed, 341 insertions, 438 deletions
diff --git a/Zend/tests/001.phpt b/Zend/tests/001.phpt
index bec7d8adbc..bbd4ea3ece 100644
--- a/Zend/tests/001.phpt
+++ b/Zend/tests/001.phpt
@@ -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)
diff --git a/Zend/tests/002.phpt b/Zend/tests/002.phpt
index b01c7fa329..1728330c08 100644
--- a/Zend/tests/002.phpt
+++ b/Zend/tests/002.phpt
@@ -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)
diff --git a/Zend/tests/003.phpt b/Zend/tests/003.phpt
index 5c3b83d25e..91daa705d3 100644
--- a/Zend/tests/003.phpt
+++ b/Zend/tests/003.phpt
@@ -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)
diff --git a/Zend/tests/bug33996.phpt b/Zend/tests/bug33996.phpt
index c399ee9975..3936eb8845 100644
--- a/Zend/tests/bug33996.phpt
+++ b/Zend/tests/bug33996.phpt
@@ -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!
diff --git a/Zend/tests/bug38047.phpt b/Zend/tests/bug38047.phpt
index 5e7b3efc94..09739d23eb 100644
--- a/Zend/tests/bug38047.phpt
+++ b/Zend/tests/bug38047.phpt
@@ -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
diff --git a/Zend/tests/bug55705.phpt b/Zend/tests/bug55705.phpt
index f051bca6dc..fc17139344 100644
--- a/Zend/tests/bug55705.phpt
+++ b/Zend/tests/bug55705.phpt
@@ -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}
diff --git a/Zend/tests/bug70689.phpt b/Zend/tests/bug70689.phpt
index e3feeed9b0..286b6f4225 100644
--- a/Zend/tests/bug70689.phpt
+++ b/Zend/tests/bug70689.phpt
@@ -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
diff --git a/Zend/tests/closure_027.phpt b/Zend/tests/closure_027.phpt
index db42ae9307..76754f9fba 100644
--- a/Zend/tests/closure_027.phpt
+++ b/Zend/tests/closure_027.phpt
@@ -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:
diff --git a/Zend/tests/error_reporting06.phpt b/Zend/tests/error_reporting06.phpt
index 285a623f2b..175ea37e80 100644
--- a/Zend/tests/error_reporting06.phpt
+++ b/Zend/tests/error_reporting06.phpt
@@ -11,7 +11,7 @@ function foo1($arg) {
function foo2($arg) {
}
-function foo3($arg) {
+function foo3() {
echo $undef3;
throw new Exception("test");
}
diff --git a/Zend/tests/error_reporting07.phpt b/Zend/tests/error_reporting07.phpt
index c63efae604..09b7690d3c 100644
--- a/Zend/tests/error_reporting07.phpt
+++ b/Zend/tests/error_reporting07.phpt
@@ -11,7 +11,7 @@ function foo1($arg) {
function foo2($arg) {
}
-function foo3($arg) {
+function foo3() {
echo $undef3;
throw new Exception("test");
}
diff --git a/Zend/tests/error_reporting08.phpt b/Zend/tests/error_reporting08.phpt
index edf3292779..c9945046ee 100644
--- a/Zend/tests/error_reporting08.phpt
+++ b/Zend/tests/error_reporting08.phpt
@@ -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");
diff --git a/Zend/tests/nullable_types/nullable_type_parameters_do_not_have_default_value.phpt b/Zend/tests/nullable_types/nullable_type_parameters_do_not_have_default_value.phpt
index 13b25e0dac..5de93bb7d6 100644
--- a/Zend/tests/nullable_types/nullable_type_parameters_do_not_have_default_value.phpt
+++ b/Zend/tests/nullable_types/nullable_type_parameters_do_not_have_default_value.phpt
@@ -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
diff --git a/Zend/tests/type_declarations/scalar_none.phpt b/Zend/tests/type_declarations/scalar_none.phpt
index 3bec609599..025276adef 100644
--- a/Zend/tests/type_declarations/scalar_none.phpt
+++ b/Zend/tests/type_declarations/scalar_none.phpt
@@ -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:
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 935eb25f4c..a41c9dd594 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -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
diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h
index e70465fdc6..82c6a4a415 100644
--- a/Zend/zend_execute.h
+++ b/Zend/zend_execute.h
@@ -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)
{
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 300814426e..4742a62b58 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -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);
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 23cd944f8b..b0da3c043d 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -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);
diff --git a/ext/libxml/tests/libxml_set_external_entity_loader_error1.phpt b/ext/libxml/tests/libxml_set_external_entity_loader_error1.phpt
index 5ed079d8dd..7f1adde613 100644
--- a/ext/libxml/tests/libxml_set_external_entity_loader_error1.phpt
+++ b/ext/libxml/tests/libxml_set_external_entity_loader_error1.phpt
@@ -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.
diff --git a/ext/mysqli/tests/mysqli_fetch_object.phpt b/ext/mysqli/tests/mysqli_fetch_object.phpt
index 9706ceac84..dff91531ce 100644
--- a/ext/mysqli/tests/mysqli_fetch_object.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_object.phpt
@@ -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
diff --git a/ext/mysqli/tests/mysqli_fetch_object_oo.phpt b/ext/mysqli/tests/mysqli_fetch_object_oo.phpt
index 82e311cc72..8fac044139 100644
--- a/ext/mysqli/tests/mysqli_fetch_object_oo.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_object_oo.phpt
@@ -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
diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c
index 46b3d0950e..04bf483c1a 100644
--- a/ext/opcache/Optimizer/zend_inference.c
+++ b/ext/opcache/Optimizer/zend_inference.c
@@ -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 */
diff --git a/ext/reflection/tests/007.phpt b/ext/reflection/tests/007.phpt
index 004158ccff..d9204171b5 100644
--- a/ext/reflection/tests/007.phpt
+++ b/ext/reflection/tests/007.phpt
@@ -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) {
diff --git a/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt b/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt
index d3a426de4c..3ad654dd84 100644
--- a/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt
@@ -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) {
diff --git a/ext/reflection/tests/ReflectionClass_newInstance_001.phpt b/ext/reflection/tests/ReflectionClass_newInstance_001.phpt
index afa278a9a1..e29cc8734f 100644
--- a/ext/reflection/tests/ReflectionClass_newInstance_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_newInstance_001.phpt
@@ -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) {
diff --git a/ext/reflection/tests/ReflectionMethod_invokeArgs_error1.phpt b/ext/reflection/tests/ReflectionMethod_invokeArgs_error1.phpt
index ac97e3ed2a..c9d1e6379a 100644
--- a/ext/reflection/tests/ReflectionMethod_invokeArgs_error1.phpt
+++ b/ext/reflection/tests/ReflectionMethod_invokeArgs_error1.phpt
@@ -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
diff --git a/ext/reflection/tests/ReflectionMethod_invoke_error2.phpt b/ext/reflection/tests/ReflectionMethod_invoke_error2.phpt
index a070c8f583..60a9ebae97 100644
--- a/ext/reflection/tests/ReflectionMethod_invoke_error2.phpt
+++ b/ext/reflection/tests/ReflectionMethod_invoke_error2.phpt
@@ -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
diff --git a/ext/reflection/tests/bug38217.phpt b/ext/reflection/tests/bug38217.phpt
index cf007d9547..988f1c8953 100644
--- a/ext/reflection/tests/bug38217.phpt
+++ b/ext/reflection/tests/bug38217.phpt
@@ -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) {
}
diff --git a/ext/soap/tests/bugs/bug38005.phpt b/ext/soap/tests/bugs/bug38005.phpt
index 6a4fb2580b..219696c263 100644
--- a/ext/soap/tests/bugs/bug38005.phpt
+++ b/ext/soap/tests/bugs/bug38005.phpt
@@ -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: Ä');
}
diff --git a/ext/soap/tests/soap12/soap12-test.inc b/ext/soap/tests/soap12/soap12-test.inc
index fbdc855a7e..e27712241f 100644
--- a/ext/soap/tests/soap12/soap12-test.inc
+++ b/ext/soap/tests/soap12/soap12-test.inc
@@ -90,7 +90,7 @@ class Soap12test {
return count($input);
}
- function isNil($input) {
+ function isNil($input=NULL) {
return is_null($input);
}
diff --git a/ext/standard/tests/array/array_filter_variation10.phpt b/ext/standard/tests/array/array_filter_variation10.phpt
index f0a6115f79..b23618794e 100644
--- a/ext/standard/tests/array/array_filter_variation10.phpt
+++ b/ext/standard/tests/array/array_filter_variation10.phpt
@@ -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
diff --git a/ext/standard/tests/array/array_map_error.phpt b/ext/standard/tests/array/array_map_error.phpt
index 7c623ec4ea..56dd033521 100644
--- a/ext/standard/tests/array/array_map_error.phpt
+++ b/ext/standard/tests/array/array_map_error.phpt
@@ -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) {
diff --git a/ext/standard/tests/array/array_map_variation10.phpt b/ext/standard/tests/array/array_map_variation10.phpt
index cc75436999..ecf9157620 100644
--- a/ext/standard/tests/array/array_map_variation10.phpt
+++ b/ext/standard/tests/array/array_map_variation10.phpt
@@ -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]=>
diff --git a/ext/standard/tests/array/array_map_variation9.phpt b/ext/standard/tests/array/array_map_variation9.phpt
index f029beccd6..f33b717c6c 100644
--- a/ext/standard/tests/array/array_map_variation9.phpt
+++ b/ext/standard/tests/array/array_map_variation9.phpt
@@ -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
diff --git a/ext/standard/tests/array/array_reduce_variation1.phpt b/ext/standard/tests/array/array_reduce_variation1.phpt
index b02a82a7ca..adffeb53d4 100644
--- a/ext/standard/tests/array/array_reduce_variation1.phpt
+++ b/ext/standard/tests/array/array_reduce_variation1.phpt
@@ -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===
diff --git a/ext/standard/tests/array/array_udiff_assoc_variation5.phpt b/ext/standard/tests/array/array_udiff_assoc_variation5.phpt
index 69380767bb..6b7f014467 100644
--- a/ext/standard/tests/array/array_udiff_assoc_variation5.phpt
+++ b/ext/standard/tests/array/array_udiff_assoc_variation5.phpt
@@ -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) {
diff --git a/ext/standard/tests/array/array_udiff_uassoc_variation6.phpt b/ext/standard/tests/array/array_udiff_uassoc_variation6.phpt
index ec752a31bb..bf2c0f3d2d 100644
--- a/ext/standard/tests/array/array_udiff_uassoc_variation6.phpt
+++ b/ext/standard/tests/array/array_udiff_uassoc_variation6.phpt
@@ -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) {
diff --git a/ext/standard/tests/array/array_udiff_variation5.phpt b/ext/standard/tests/array/array_udiff_variation5.phpt
index 49405d40be..ce6362fc08 100644
--- a/ext/standard/tests/array/array_udiff_variation5.phpt
+++ b/ext/standard/tests/array/array_udiff_variation5.phpt
@@ -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) {
diff --git a/ext/standard/tests/array/array_uintersect_assoc_variation5.phpt b/ext/standard/tests/array/array_uintersect_assoc_variation5.phpt
index e2d7bd03a6..bebe5b52c9 100644
--- a/ext/standard/tests/array/array_uintersect_assoc_variation5.phpt
+++ b/ext/standard/tests/array/array_uintersect_assoc_variation5.phpt
@@ -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) {
diff --git a/ext/standard/tests/array/array_uintersect_uassoc_variation6.phpt b/ext/standard/tests/array/array_uintersect_uassoc_variation6.phpt
index 6ed86f8417..a5317c1c0d 100644
--- a/ext/standard/tests/array/array_uintersect_uassoc_variation6.phpt
+++ b/ext/standard/tests/array/array_uintersect_uassoc_variation6.phpt
@@ -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) {
diff --git a/ext/standard/tests/array/array_uintersect_variation5.phpt b/ext/standard/tests/array/array_uintersect_variation5.phpt
index 75cf08e270..642ebc0077 100644
--- a/ext/standard/tests/array/array_uintersect_variation5.phpt
+++ b/ext/standard/tests/array/array_uintersect_variation5.phpt
@@ -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) {
diff --git a/ext/standard/tests/array/array_walk_error2.phpt b/ext/standard/tests/array/array_walk_error2.phpt
index 63c5f51ee0..fd3cbf5037 100644
--- a/ext/standard/tests/array/array_walk_error2.phpt
+++ b/ext/standard/tests/array/array_walk_error2.phpt
@@ -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
diff --git a/ext/standard/tests/array/array_walk_recursive_error2.phpt b/ext/standard/tests/array/array_walk_recursive_error2.phpt
index 8e0c8829e6..5a077c6886 100644
--- a/ext/standard/tests/array/array_walk_recursive_error2.phpt
+++ b/ext/standard/tests/array/array_walk_recursive_error2.phpt
@@ -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
diff --git a/ext/standard/tests/assert/assert_error2.phpt b/ext/standard/tests/assert/assert_error2.phpt
index 41a7197535..7861d435c8 100644
--- a/ext/standard/tests/assert/assert_error2.phpt
+++ b/ext/standard/tests/assert/assert_error2.phpt
@@ -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
diff --git a/ext/standard/tests/file/bug38450.phpt b/ext/standard/tests/file/bug38450.phpt
index 07e413b92b..4a2953ea79 100644
--- a/ext/standard/tests/file/bug38450.phpt
+++ b/ext/standard/tests/file/bug38450.phpt
@@ -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
diff --git a/ext/standard/tests/file/bug38450_1.phpt b/ext/standard/tests/file/bug38450_1.phpt
index 07e413b92b..d0682186f9 100644
--- a/ext/standard/tests/file/bug38450_1.phpt
+++ b/ext/standard/tests/file/bug38450_1.phpt
@@ -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
diff --git a/ext/standard/tests/file/bug38450_2.phpt b/ext/standard/tests/file/bug38450_2.phpt
index 7934bb40f5..64c9f8d94a 100644
--- a/ext/standard/tests/file/bug38450_2.phpt
+++ b/ext/standard/tests/file/bug38450_2.phpt
@@ -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
diff --git a/ext/standard/tests/file/bug38450_3.phpt b/ext/standard/tests/file/bug38450_3.phpt
index f2c4643ef3..07c5958ab4 100644
--- a/ext/standard/tests/file/bug38450_3.phpt
+++ b/ext/standard/tests/file/bug38450_3.phpt
@@ -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+')
diff --git a/tests/classes/interfaces_003.phpt b/tests/classes/interfaces_003.phpt
index e1cbfdaf54..e66a86491c 100644
--- a/tests/classes/interfaces_003.phpt
+++ b/tests/classes/interfaces_003.phpt
@@ -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}