Browse Source

- Improved error messages

migration/RELEASE_1_0_0
Marcus Boerger 20 years ago
parent
commit
426b40fc77
  1. 2
      Zend/tests/array_type_hint_001.phpt
  2. 5
      Zend/tests/bug33996.phpt
  3. 28
      Zend/zend_execute.c
  4. 2
      tests/classes/interfaces_003.phpt
  5. 2
      tests/classes/type_hinting_001.phpt
  6. 2
      tests/classes/type_hinting_003.phpt
  7. 2
      tests/lang/bug24658.phpt
  8. 2
      tests/lang/catchable_error_001.phpt
  9. 2
      tests/lang/catchable_error_002.phpt
  10. 2
      tests/lang/type_hints_001.phpt

2
Zend/tests/array_type_hint_001.phpt

@ -12,4 +12,4 @@ foo(123);
--EXPECTF--
3
Catchable fatal error: Argument 1 passed to foo() must be an array, called in %sarray_type_hint_001.php on line 7 and defined in %sarray_type_hint_001.php on line 2
Catchable fatal error: Argument 1 passed to foo() must be an array, integer given, called in %sarray_type_hint_001.php on line 7 and defined in %sarray_type_hint_001.php on line 2

5
Zend/tests/bug33996.phpt

@ -24,7 +24,6 @@ FooTest();
FooTest(new Foo());
?>
--EXPECTF--
Warning: Missing argument 1 for NormalTest(), called in %sbug33996.php on line 17 and defined in %sbug33996.php on line 12
Warning: Missing argument 1 for NormalTest(), called in %sbug33996.php on line %d and defined in %sbug33996.php on line %d
Hi!
Catchable fatal error: Argument 1 passed to FooTest() must be an object of class Foo, called in %sbug33996.php on line 18 and defined in %sbug33996.php on line 7
Catchable fatal error: Argument 1 passed to FooTest() must be an object of class Foo, none given, called in %sbug33996.php on line %d and defined in %sbug33996.php on line %d

28
Zend/zend_execute.c

@ -493,9 +493,9 @@ static inline int zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zva
if (cur_arg_info->class_name.v) {
if (!arg) {
if (ptr && ptr->op_array) {
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an object of class %v, called in %s on line %d and defined", arg_num, fclass, fsep, fname, cur_arg_info->class_name, ptr->op_array->filename, ptr->opline->lineno);
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an object of class %v, none given, called in %s on line %d and defined", arg_num, fclass, fsep, fname, cur_arg_info->class_name, ptr->op_array->filename, ptr->opline->lineno);
} else {
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an object of class %v", arg_num, fclass, fsep, fname, cur_arg_info->class_name);
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an object of class %v, none given", arg_num, fclass, fsep, fname, cur_arg_info->class_name);
}
return 0;
}
@ -503,9 +503,9 @@ static inline int zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zva
case IS_NULL:
if (!cur_arg_info->allow_null) {
if (ptr && ptr->op_array) {
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must not be null, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno);
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an object of class %v, null given, called in %s on line %d and defined", arg_num, fclass, fsep, fname, cur_arg_info->class_name, ptr->op_array->filename, ptr->opline->lineno);
} else {
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must not be null", arg_num, fclass, fsep, fname);
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an object of class %v, null given", arg_num, fclass, fsep, fname, cur_arg_info->class_name);
}
return 0;
}
@ -520,9 +520,9 @@ static inline int zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zva
error_msg = "be an instance of";
}
if (ptr && ptr->op_array) {
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must %s %v, called in %s on line %d and defined", arg_num, fclass, fsep, fname, error_msg, ce->name, ptr->op_array->filename, ptr->opline->lineno);
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must %s %v, instance of %v given, called in %s on line %d and defined", arg_num, fclass, fsep, fname, error_msg, ce->name, Z_OBJCE_P(arg)->name, ptr->op_array->filename, ptr->opline->lineno);
} else {
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must %s %v", arg_num, fclass, fsep, fname, error_msg, ce->name);
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must %s %v, instance of %v given", arg_num, fclass, fsep, fname, error_msg, ce->name, Z_OBJCE_P(arg)->name);
}
return 0;
}
@ -530,18 +530,18 @@ static inline int zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zva
break;
default:
if (ptr && ptr->op_array) {
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an object of class %v, called in %s on line %d and defined", arg_num, fclass, fsep, fname, cur_arg_info->class_name, ptr->op_array->filename, ptr->opline->lineno);
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an object of class %v, %s given, called in %s on line %d and defined", arg_num, fclass, fsep, fname, cur_arg_info->class_name, zend_zval_type_name(arg), ptr->op_array->filename, ptr->opline->lineno);
} else {
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an object of class %v", arg_num, fclass, fsep, fname, cur_arg_info->class_name);
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an object of class %v, %s given", arg_num, fclass, fsep, fname, cur_arg_info->class_name, zend_zval_type_name(arg));
}
return 0;
}
} else if (cur_arg_info->array_type_hint) {
if (!arg) {
if (ptr && ptr->op_array) {
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an array, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno);
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an array, none given, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno);
} else {
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an array", arg_num, fclass, fsep, fname);
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an array, none given", arg_num, fclass, fsep, fname);
}
return 0;
}
@ -549,9 +549,9 @@ static inline int zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zva
case IS_NULL:
if (!cur_arg_info->allow_null) {
if (ptr && ptr->op_array) {
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must not be null, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno);
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an array, null given, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno);
} else {
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must not be null", arg_num, fclass, fsep, fname);
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an array, null given", arg_num, fclass, fsep, fname);
}
return 0;
}
@ -560,9 +560,9 @@ static inline int zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zva
break;
default:
if (ptr && ptr->op_array) {
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an array, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno);
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an array, %s given, called in %s on line %d and defined", arg_num, fclass, fsep, fname, zend_zval_type_name(arg), ptr->op_array->filename, ptr->opline->lineno);
} else {
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an array", arg_num, fclass, fsep, fname);
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an array, %s given", arg_num, fclass, fsep, fname, zend_zval_type_name(arg));
}
return 0;
}

2
tests/classes/interfaces_003.phpt

@ -23,4 +23,4 @@ $obj = new MyTestClass;
===DONE===
--EXPECTF--
Catchable fatal error: Argument 1 passed to MyTestClass::__construct() must be an object of class MyObject, called in %sinterfaces_003.php on line %d
Catchable fatal error: Argument 1 passed to MyTestClass::__construct() must be an object of class MyObject, none given, called in %sinterfaces_003.php on line %d

2
tests/classes/type_hinting_001.phpt

@ -35,4 +35,4 @@ $a->b($b);
?>
--EXPECTF--
Catchable fatal error: Argument 1 passed to FooBar::a() must implement interface Foo, called in %s on line 27 and defined in %s on line 12
Catchable fatal error: Argument 1 passed to FooBar::a() must implement interface Foo, instance of Blort given, called in %s on line 27 and defined in %s on line 12

2
tests/classes/type_hinting_003.phpt

@ -57,4 +57,4 @@ array(1) {
int(25)
}
Catchable fatal error: Argument 1 passed to Test::f1() must be an array, called in %stype_hinting_003.php on line %d and defined in %stype_hinting_003.php on line %d
Catchable fatal error: Argument 1 passed to Test::f1() must be an array, integer given, called in %stype_hinting_003.php on line %d and defined in %stype_hinting_003.php on line %d

2
tests/lang/bug24658.phpt

@ -53,4 +53,4 @@ int(2)
object(foo)#%d (0) {
}
Catchable fatal error: Argument 1 passed to typehint() must be an object of class foo in %s on line %d
Catchable fatal error: Argument 1 passed to typehint() must be an object of class foo, integer given in %s on line %d

2
tests/lang/catchable_error_001.phpt

@ -19,4 +19,4 @@ Catchable fatal error [1]
echo "ALIVE!\n";
?>
--EXPECTF--
Catchable fatal error: Argument 1 passed to blah() must be an instance of Foo, called in %scatchable_error_001.php on line 15 and defined in %scatchable_error_001.php on line 5
Catchable fatal error: Argument 1 passed to blah() must be an instance of Foo, instance of stdClass given, called in %scatchable_error_001.php on line 15 and defined in %scatchable_error_001.php on line 5

2
tests/lang/catchable_error_002.phpt

@ -25,7 +25,7 @@ array(5) {
[0]=>
int(4096)
[1]=>
string(%d) "Argument 1 passed to blah() must be an instance of Foo, called in %scatchable_error_002.php on line 17 and defined"
string(%d) "Argument 1 passed to blah() must be an instance of Foo, instance of stdClass given, called in %scatchable_error_002.php on line 17 and defined"
[2]=>
string(%d) "%scatchable_error_002.php"
[3]=>

2
tests/lang/type_hints_001.phpt

@ -23,4 +23,4 @@ type_hint_foo($bar);
?>
--EXPECTF--
Catchable fatal error: Argument 1 passed to type_hint_foo() must be an instance of Foo, called in %s on line 16 and defined in %s on line 9
Catchable fatal error: Argument 1 passed to type_hint_foo() must be an instance of Foo, instance of Bar given, called in %s on line 16 and defined in %s on line 9
Loading…
Cancel
Save