Skip to content

Commit a5dfd41

Browse files
committed
zend_make_printable_zval choses cast_object over __toString
https://bugs.php.net/bug.php?id=62328 Added a check to see if the object implements a __toString magic method. This should be called instead of the cast_object method of built-in classes when defined.
1 parent 7e4c012 commit a5dfd41

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Zend/zend.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,12 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
258258
{
259259
TSRMLS_FETCH();
260260

261+
if (Z_OBJCE_P(expr)->__tostring) {
262+
if (zend_std_cast_object_tostring(expr, expr_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
263+
break;
264+
}
265+
}
266+
261267
if (Z_OBJ_HANDLER_P(expr, cast_object)) {
262268
zval *val;
263269

0 commit comments

Comments
 (0)