MFB: fix error messages when converting objects to other types

This commit is contained in:
Antony Dovgal 2006-05-25 10:34:01 +00:00
parent 40439b1670
commit 34126e4a64
3 changed files with 17 additions and 19 deletions

View File

@ -194,19 +194,15 @@ ZEND_API void zend_wrong_param_count(TSRMLS_D)
/* Argument parsing API -- andrei */
ZEND_API char *zend_zval_type_name(zval *arg)
ZEND_API char *zend_get_type_by_const(int type)
{
switch (Z_TYPE_P(arg)) {
case IS_NULL:
return "null";
switch(type) {
case IS_BOOL:
return "boolean";
case IS_LONG:
return "integer";
case IS_DOUBLE:
return "double";
case IS_STRING:
{
TSRMLS_FETCH();
@ -217,26 +213,26 @@ ZEND_API char *zend_zval_type_name(zval *arg)
return "string";
}
}
case IS_ARRAY:
return "array";
case IS_OBJECT:
return "object";
case IS_BOOL:
return "boolean";
case IS_RESOURCE:
return "resource";
case IS_NULL:
return "null";
case IS_ARRAY:
return "array";
case IS_UNICODE:
return "Unicode string";
default:
return "unknown";
}
}
ZEND_API char *zend_zval_type_name(zval *arg)
{
return zend_get_type_by_const(Z_TYPE_P(arg));
}
ZEND_API zend_class_entry *zend_get_class_entry(zval *zobject TSRMLS_DC)
{
if (Z_OBJ_HT_P(zobject)->get_class_entry) {

View File

@ -289,6 +289,7 @@ ZEND_API zval *zend_read_static_property(zend_class_entry *scope, char *name, in
ZEND_API zend_class_entry *zend_get_class_entry(zval *zobject TSRMLS_DC);
ZEND_API int zend_get_object_classname(zval *object, zstr *class_name, zend_uint *class_name_len TSRMLS_DC);
ZEND_API zend_uchar zend_get_unified_string_type(int num_args TSRMLS_DC, ...);
ZEND_API char *zend_get_type_by_const(int type);
#define getThis() (this_ptr)

View File

@ -318,10 +318,11 @@ ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC)
zval dst; \
if (Z_OBJ_HT_P(op)->cast_object(op, &dst, ctype TSRMLS_CC) == FAILURE) { \
zend_error(E_RECOVERABLE_ERROR, \
"Object of class %v could not be converted to " # ctype, Z_OBJCE_P(op)->name); \
"Object of class %v could not be converted to %s", Z_OBJCE_P(op)->name, \
zend_get_type_by_const(ctype)); \
} else { \
zval_dtor(op); \
Z_TYPE_P(op) = ctype; \
Z_TYPE_P(op) = ctype; \
op->value = dst.value; \
} \
} else { \