mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
fix error messages when converting objects to other types
add new function MFB will follow soon
This commit is contained in:
parent
ec79dd793d
commit
9dd24c6d87
3 changed files with 22 additions and 23 deletions
|
@ -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";
|
||||
|
||||
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";
|
||||
|
||||
switch(type) {
|
||||
case IS_BOOL:
|
||||
return "boolean";
|
||||
|
||||
case IS_LONG:
|
||||
return "integer";
|
||||
case IS_DOUBLE:
|
||||
return "double";
|
||||
case IS_STRING:
|
||||
return "string";
|
||||
case IS_OBJECT:
|
||||
return "object";
|
||||
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) {
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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; \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue