Browse files

fix error messages when converting objects to other types

add new function
MFB will follow soon
  • Loading branch information...
1 parent ec79dd7 commit 9dd24c6d8734126f86cc0bad7d99bf36b6c8ef71 @tony2001 tony2001 committed May 25, 2006
Showing with 16 additions and 17 deletions.
  1. +13 −16 Zend/zend_API.c
  2. +1 −0 Zend/zend_API.h
  3. +2 −1 Zend/zend_operators.c
View
29 Zend/zend_API.c
@@ -195,38 +195,35 @@ 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:
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";
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
1 Zend/zend_API.h
@@ -258,6 +258,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, char **class_name, zend_uint *class_name_len TSRMLS_DC);
+ZEND_API char *zend_get_type_by_const(int type);
#define getThis() (this_ptr)
View
3 Zend/zend_operators.c
@@ -271,7 +271,8 @@ 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 %s could not be converted to " # ctype, Z_OBJCE_P(op)->name); \
+ "Object of class %s 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; \

0 comments on commit 9dd24c6

Please sign in to comment.