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

This commit is contained in:
Dmitry Stogov 2016-05-31 17:14:50 +03:00
parent 3b0a6dfeb2
commit 662db66e39
47 changed files with 360 additions and 437 deletions

View 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)

View 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)

View 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)

View 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!

View 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

View 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}

View 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

View 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:

View File

@ -11,7 +11,7 @@ function foo1($arg) {
function foo2($arg) {
}
function foo3($arg) {
function foo3() {
echo $undef3;
throw new Exception("test");
}

View File

@ -11,7 +11,7 @@ function foo1($arg) {
function foo2($arg) {
}
function foo3($arg) {
function foo3() {
echo $undef3;
throw new Exception("test");
}

View 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");

View 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

View 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:

View File

@ -861,63 +861,6 @@ 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];
} 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);
}
}
}
static ZEND_COLD void zend_verify_return_error(const zend_function *zf, const char *need_msg, const char *need_kind, const char *returned_msg, const char *returned_kind)
{
const char *fname = ZSTR_VAL(zf->common.function_name);
@ -3110,11 +3053,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

View File

@ -54,7 +54,6 @@ 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);
static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval *value, zend_uchar value_type)
{

View File

@ -4739,9 +4739,29 @@ ZEND_VM_HANDLER(63, ZEND_RECV, NUM, ANY)
uint32_t arg_num = opline->op1.num;
if (UNEXPECTED(arg_num > EX_NUM_ARGS())) {
zend_execute_data *ptr = EX(prev_execute_data);
SAVE_OPLINE();
zend_verify_missing_arg(execute_data, arg_num, CACHE_ADDR(opline->op2.num));
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
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 {
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);
}
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);

View File

@ -1463,9 +1463,29 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RECV_SPEC_HANDLER(ZEND_OPCODE_
uint32_t arg_num = opline->op1.num;
if (UNEXPECTED(arg_num > EX_NUM_ARGS())) {
zend_execute_data *ptr = EX(prev_execute_data);
SAVE_OPLINE();
zend_verify_missing_arg(execute_data, arg_num, CACHE_ADDR(opline->op2.num));
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
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 {
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);
}
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);

View 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.

View File

@ -59,18 +59,25 @@ require_once('skipifconnectfailure.inc');
}
$obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array());
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";
}
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);
}
$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

View 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

View 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) {

View 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
object(A)#%d (0) {
}
In constructor of class A
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) {

View 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) {

View 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

View 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

View 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) {
}

View 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: Ä');
}

View File

@ -90,7 +90,7 @@ class Soap12test {
return count($input);
}
function isNil($input) {
function isNil($input=NULL) {
return is_null($input);
}

View 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

View 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) {

View 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]=>

View 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

View 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===
Exception: Too few arguments to function threeArgs(), 2 passed and exactly 3 expected
===DONE===

View 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) {

View 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) {

View 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) {

View 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) {

View 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) {

View 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) {

View 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

View 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

View 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

View 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

View 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

View 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

View 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+')

View 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}