cvs: php-src /tests/lang bug24658.phpt ZendEngine2 zend_execute.c
| From: | Marcus Boerger | Date: | Sun, 21 May 2006 12:38:28 +0000 |
| Subject: | cvs: php-src /tests/lang bug24658.phpt ZendEngine2 zend_execute.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-38331@lists.php.net to get a copy of this message | ||
helly Sun May 21 12:38:28 2006 UTC
Modified files:
/ZendEngine2 zend_execute.c
/php-src/tests/lang bug24658.phpt
Log:
- Improve error messages (part 2)
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_execute.c?r1=1.743&r2=1.744&diff_format=u
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.743 ZendEngine2/zend_execute.c:1.744
--- ZendEngine2/zend_execute.c:1.743 Sun May 21 11:23:35 2006
+++ ZendEngine2/zend_execute.c Sun May 21 12:38:28 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute.c,v 1.743 2006/05/21 11:23:35 helly Exp $ */
+/* $Id: zend_execute.c,v 1.744 2006/05/21 12:38:28 helly Exp $ */
#define ZEND_INTENSIVE_DEBUGGING 0
@@ -477,8 +477,9 @@
{
zend_arg_info *cur_arg_info;
zend_execute_data *ptr = EG(current_execute_data)->prev_execute_data;
- char *fsep;
+ char *fsep, *error_msg;
zstr fclass, fname;
+ zend_class_entry *ce;
if (!zf->common.arg_info
|| arg_num>zf->common.num_args) {
@@ -511,9 +512,8 @@
}
break;
case IS_OBJECT: {
- zend_class_entry *ce = zend_u_fetch_class(UG(unicode) ? IS_UNICODE : IS_STRING,
cur_arg_info->class_name, cur_arg_info->class_name_len, ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
+ ce = zend_u_fetch_class(UG(unicode) ? IS_UNICODE : IS_STRING, 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 {
@@ -528,13 +528,20 @@
}
}
break;
- default:
+ default: {
+ ce = zend_u_fetch_class(UG(unicode) ? IS_UNICODE : IS_STRING, 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 %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);
+ zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must %s %v, %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 %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));
+ zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must %s %v, %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) {
http://cvs.php.net/viewcvs.cgi/php-src/tests/lang/bug24658.phpt?r1=1.6&r2=1.7&diff_format=u
Index: php-src/tests/lang/bug24658.phpt
diff -u php-src/tests/lang/bug24658.phpt:1.6 php-src/tests/lang/bug24658.phpt:1.7
--- php-src/tests/lang/bug24658.phpt:1.6 Sun May 21 11:23:35 2006
+++ php-src/tests/lang/bug24658.phpt Sun May 21 12:38:28 2006
@@ -53,4 +53,4 @@
object(foo)#%d (0) {
}
-Catchable fatal error: Argument 1 passed to typehint() must be an object of class foo, integer
given 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