helly Sun May 21 18:10:32 2006 UTC Modified files: (Branch: PHP_5_2) /ZendEngine2 zend_execute.c /ZendEngine2/tests array_type_hint_001.phpt bug33996.phpt /php-src/tests/classes interfaces_003.phpt type_hinting_001.phpt type_hinting_003.phpt /php-src/tests/lang bug24658.phpt type_hints_001.phpt Log: - MFH improve error messages
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_execute.c?r1=1.716.2.12.2.4&r2=1.716.2.12.2.5&diff_format=u Index: ZendEngine2/zend_execute.c diff -u ZendEngine2/zend_execute.c:1.716.2.12.2.4 ZendEngine2/zend_execute.c:1.716.2.12.2.5 --- ZendEngine2/zend_execute.c:1.716.2.12.2.4 Mon May 15 15:31:27 2006 +++ ZendEngine2/zend_execute.c Sun May 21 18:10:30 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.c,v 1.716.2.12.2.4 2006/05/15 15:31:27 dmitry Exp $ */ +/* $Id: zend_execute.c,v 1.716.2.12.2.5 2006/05/21 18:10:30 helly Exp $ */ #define ZEND_INTENSIVE_DEBUGGING 0 @@ -454,7 +454,9 @@ { zend_arg_info *cur_arg_info; zend_execute_data *ptr = EG(current_execute_data)->prev_execute_data; - char *fclass, *fsep, *fname; + char *fsep, *error_msg; + char *fclass, *fname; + zend_class_entry *ce; if (!zf->common.arg_info || arg_num>zf->common.num_args) { @@ -469,9 +471,9 @@ if (cur_arg_info->class_name) { if (!arg) { if (ptr && ptr->op_array) { - zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an object of class %s, 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 %s%s%s() must be an object of class %s, 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 %s%s%s() must be an object of class %s", arg_num, fclass, fsep, fname, cur_arg_info->class_name); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an object of class %s, none given", arg_num, fclass, fsep, fname, cur_arg_info->class_name); } return 0; } @@ -479,45 +481,51 @@ case IS_NULL: if (!cur_arg_info->allow_null) { if (ptr && ptr->op_array) { - zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() 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 %s%s%s() must be an object of class %s, 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 %s%s%s() must not be null", arg_num, fclass, fsep, fname); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an object of class %s, null given", arg_num, fclass, fsep, fname, cur_arg_info->class_name); } return 0; } break; case IS_OBJECT: { - zend_class_entry *ce = zend_fetch_class(cur_arg_info->class_name, cur_arg_info->class_name_len, ZEND_FETCH_CLASS_AUTO TSRMLS_CC); + ce = zend_fetch_class(cur_arg_info->class_name, cur_arg_info->class_name_len, ZEND_FETCH_CLASS_AUTO TSRMLS_CC); if (!instanceof_function(Z_OBJCE_P(arg), ce TSRMLS_CC)) { - char *error_msg; if (ce->ce_flags & ZEND_ACC_INTERFACE) { error_msg = "implement interface"; } else { error_msg = "be an instance of"; } if (ptr && ptr->op_array) { - zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must %s %s, 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 %s%s%s() must %s %s, instance of %s 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 %s%s%s() must %s %s", arg_num, fclass, fsep, fname, error_msg, ce->name); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must %s %s, instance of %s given", arg_num, fclass, fsep, fname, error_msg, ce->name, Z_OBJCE_P(arg)->name); } return 0; } } break; - default: + default: { + ce = zend_fetch_class(cur_arg_info->class_name, cur_arg_info->class_name_len, ZEND_FETCH_CLASS_AUTO TSRMLS_CC); + if (ce->ce_flags & ZEND_ACC_INTERFACE) { + error_msg = "implement interface"; + } else { + error_msg = "be an instance of"; + } if (ptr && ptr->op_array) { - zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an object of class %s, 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 %s%s%s() must %s %s, %s given, called in %s on line %d and defined", arg_num, fclass, fsep, fname, error_msg, ce->name, zend_zval_type_name(arg), ptr->op_array->filename, ptr->opline->lineno); } else { - zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an object of class %s", arg_num, fclass, fsep, fname, cur_arg_info->class_name); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must %s %s, %s given", arg_num, fclass, fsep, fname, error_msg, ce->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 %s%s%s() 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 %s%s%s() 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 %s%s%s() must be an array", arg_num, fclass, fsep, fname); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an array, none given", arg_num, fclass, fsep, fname); } return 0; } @@ -525,9 +533,9 @@ case IS_NULL: if (!cur_arg_info->allow_null) { if (ptr && ptr->op_array) { - zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() 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 %s%s%s() 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 %s%s%s() must not be null", arg_num, fclass, fsep, fname); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an array, null given", arg_num, fclass, fsep, fname); } return 0; } @@ -536,9 +544,9 @@ break; default: if (ptr && ptr->op_array) { - zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() 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 %s%s%s() 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 %s%s%s() must be an array", arg_num, fclass, fsep, fname); + zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %s%s%s() must be an array, %s given", arg_num, fclass, fsep, fname, zend_zval_type_name(arg)); } return 0; } http://cvs.php.net/viewcvs.cgi/ZendEngine2/tests/array_type_hint_001.phpt?r1=1.2.2.1.2.1&r2=1.2.2.1.2.2&diff_format=u Index: ZendEngine2/tests/array_type_hint_001.phpt diff -u ZendEngine2/tests/array_type_hint_001.phpt:1.2.2.1.2.1 ZendEngine2/tests/array_type_hint_001.phpt:1.2.2.1.2.2 --- ZendEngine2/tests/array_type_hint_001.phpt:1.2.2.1.2.1 Wed May 10 22:46:16 2006 +++ ZendEngine2/tests/array_type_hint_001.phpt Sun May 21 18:10:31 2006 @@ -12,4 +12,4 @@ --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 http://cvs.php.net/viewcvs.cgi/ZendEngine2/tests/bug33996.phpt?r1=1.1.2.1.2.1&r2=1.1.2.1.2.2&diff_format=u Index: ZendEngine2/tests/bug33996.phpt diff -u ZendEngine2/tests/bug33996.phpt:1.1.2.1.2.1 ZendEngine2/tests/bug33996.phpt:1.1.2.1.2.2 --- ZendEngine2/tests/bug33996.phpt:1.1.2.1.2.1 Wed May 10 22:46:16 2006 +++ ZendEngine2/tests/bug33996.phpt Sun May 21 18:10:31 2006 @@ -26,5 +26,5 @@ --EXPECTF-- Warning: Missing argument 1 for NormalTest(), called in %sbug33996.php on line 17 and defined in %sbug33996.php on line 12 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 18 and defined in %sbug33996.php on line 7 http://cvs.php.net/viewcvs.cgi/php-src/tests/classes/interfaces_003.phpt?r1=1.1.2.2.2.1&r2=1.1.2.2.2.2&diff_format=u Index: php-src/tests/classes/interfaces_003.phpt diff -u php-src/tests/classes/interfaces_003.phpt:1.1.2.2.2.1 php-src/tests/classes/interfaces_003.phpt:1.1.2.2.2.2 --- php-src/tests/classes/interfaces_003.phpt:1.1.2.2.2.1 Wed May 10 21:19:37 2006 +++ php-src/tests/classes/interfaces_003.phpt Sun May 21 18:10:31 2006 @@ -23,4 +23,4 @@ ===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 http://cvs.php.net/viewcvs.cgi/php-src/tests/classes/type_hinting_001.phpt?r1=1.3.2.1.2.1&r2=1.3.2.1.2.2&diff_format=u Index: php-src/tests/classes/type_hinting_001.phpt diff -u php-src/tests/classes/type_hinting_001.phpt:1.3.2.1.2.1 php-src/tests/classes/type_hinting_001.phpt:1.3.2.1.2.2 --- php-src/tests/classes/type_hinting_001.phpt:1.3.2.1.2.1 Wed May 10 21:19:37 2006 +++ php-src/tests/classes/type_hinting_001.phpt Sun May 21 18:10:31 2006 @@ -35,4 +35,4 @@ ?> --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 http://cvs.php.net/viewcvs.cgi/php-src/tests/classes/type_hinting_003.phpt?r1=1.1.2.2.2.1&r2=1.1.2.2.2.2&diff_format=u Index: php-src/tests/classes/type_hinting_003.phpt diff -u php-src/tests/classes/type_hinting_003.phpt:1.1.2.2.2.1 php-src/tests/classes/type_hinting_003.phpt:1.1.2.2.2.2 --- php-src/tests/classes/type_hinting_003.phpt:1.1.2.2.2.1 Wed May 10 21:19:37 2006 +++ php-src/tests/classes/type_hinting_003.phpt Sun May 21 18:10:31 2006 @@ -57,4 +57,4 @@ 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 http://cvs.php.net/viewcvs.cgi/php-src/tests/lang/bug24658.phpt?r1=1.3.4.1.2.1&r2=1.3.4.1.2.2&diff_format=u Index: php-src/tests/lang/bug24658.phpt diff -u php-src/tests/lang/bug24658.phpt:1.3.4.1.2.1 php-src/tests/lang/bug24658.phpt:1.3.4.1.2.2 --- php-src/tests/lang/bug24658.phpt:1.3.4.1.2.1 Wed May 10 22:38:35 2006 +++ php-src/tests/lang/bug24658.phpt Sun May 21 18:10:31 2006 @@ -53,4 +53,4 @@ 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 instance of foo, integer given in %s on line %d http://cvs.php.net/viewcvs.cgi/php-src/tests/lang/type_hints_001.phpt?r1=1.3.2.1.2.1&r2=1.3.2.1.2.2&diff_format=u Index: php-src/tests/lang/type_hints_001.phpt diff -u php-src/tests/lang/type_hints_001.phpt:1.3.2.1.2.1 php-src/tests/lang/type_hints_001.phpt:1.3.2.1.2.2 --- php-src/tests/lang/type_hints_001.phpt:1.3.2.1.2.1 Wed May 10 22:38:35 2006 +++ php-src/tests/lang/type_hints_001.phpt Sun May 21 18:10:31 2006 @@ -23,4 +23,4 @@ ?> --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
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php