mirror of
https://github.com/php/php-src.git
synced 2025-01-27 14:13:41 +08:00
Fallback to default behaviour for unsupported object type conversions
This commit is contained in:
parent
d7fdf15a41
commit
71ba442768
@ -227,11 +227,12 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
|
||||
case IS_OBJECT:
|
||||
if (expr->value.obj.handlers->cast_object) {
|
||||
TSRMLS_FETCH();
|
||||
expr->value.obj.handlers->cast_object(expr, expr_copy, IS_STRING, 0 TSRMLS_CC);
|
||||
} else {
|
||||
expr_copy->value.str.val = (char *) emalloc(sizeof("Object id #")-1 + MAX_LENGTH_OF_LONG);
|
||||
expr_copy->value.str.len = sprintf(expr_copy->value.str.val, "Object id #%ld", (long)expr->value.obj.handle);
|
||||
if (expr->value.obj.handlers->cast_object(expr, expr_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
expr_copy->value.str.val = (char *) emalloc(sizeof("Object id #")-1 + MAX_LENGTH_OF_LONG);
|
||||
expr_copy->value.str.len = sprintf(expr_copy->value.str.val, "Object id #%ld", (long)expr->value.obj.handle);
|
||||
#if 0
|
||||
/* FIXME: This might break BC for some people */
|
||||
expr_copy->value.str.len = sizeof("Object")-1;
|
||||
|
@ -297,11 +297,12 @@ ZEND_API void convert_to_long_base(zval *op, int base)
|
||||
case IS_OBJECT:
|
||||
if (op->value.obj.handlers->cast_object) {
|
||||
TSRMLS_FETCH();
|
||||
op->value.obj.handlers->cast_object(op, op, IS_LONG, 1 TSRMLS_CC);
|
||||
} else {
|
||||
zval_dtor(op);
|
||||
op->value.lval = 1;
|
||||
if (op->value.obj.handlers->cast_object(op, op, IS_LONG, 1 TSRMLS_CC) == SUCCESS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
zval_dtor(op);
|
||||
op->value.lval = 1;
|
||||
break;
|
||||
default:
|
||||
zend_error(E_WARNING, "Cannot convert to ordinal value");
|
||||
@ -349,11 +350,12 @@ ZEND_API void convert_to_double(zval *op)
|
||||
case IS_OBJECT:
|
||||
if (op->value.obj.handlers->cast_object) {
|
||||
TSRMLS_FETCH();
|
||||
op->value.obj.handlers->cast_object(op, op, IS_DOUBLE, 1 TSRMLS_CC);
|
||||
} else {
|
||||
zval_dtor(op);
|
||||
op->value.dval = 1; /* TBI!! */
|
||||
if (op->value.obj.handlers->cast_object(op, op, IS_DOUBLE, 1 TSRMLS_CC) == SUCCESS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
zval_dtor(op);
|
||||
op->value.dval = 1; /* TBI!! */
|
||||
break;
|
||||
default:
|
||||
zend_error(E_WARNING, "Cannot convert to real value (type=%d)", op->type);
|
||||
@ -370,8 +372,9 @@ ZEND_API void convert_to_null(zval *op)
|
||||
if (op->type == IS_OBJECT) {
|
||||
if (op->value.obj.handlers->cast_object) {
|
||||
TSRMLS_FETCH();
|
||||
op->value.obj.handlers->cast_object(op, op, IS_NULL, 1 TSRMLS_CC);
|
||||
return;
|
||||
if (op->value.obj.handlers->cast_object(op, op, IS_NULL, 1 TSRMLS_CC) == SUCCESS) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -422,11 +425,12 @@ ZEND_API void convert_to_boolean(zval *op)
|
||||
case IS_OBJECT:
|
||||
if (op->value.obj.handlers->cast_object) {
|
||||
TSRMLS_FETCH();
|
||||
op->value.obj.handlers->cast_object(op, op, IS_BOOL, 1 TSRMLS_CC);
|
||||
} else {
|
||||
zval_dtor(op);
|
||||
op->value.lval = 1; /* TBI!! */
|
||||
if (op->value.obj.handlers->cast_object(op, op, IS_BOOL, 1 TSRMLS_CC) == SUCCESS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
zval_dtor(op);
|
||||
op->value.lval = 1; /* TBI!! */
|
||||
break;
|
||||
default:
|
||||
zval_dtor(op);
|
||||
|
Loading…
Reference in New Issue
Block a user