Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Zend/tests/bug62328.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
Bug #62328 (cast_object takes precedence over __toString)
--FILE--
<?php

class SplFileInfo62328 extends SplFileInfo
{
public function __toString()
{
return '__toString';
}
}

$fi = new SplFileInfo62328(__FILE__);

echo (string)$fi . PHP_EOL;
echo (string)$fi->__toString() . PHP_EOL;

?>
--EXPECT--
__toString
__toString
6 changes: 6 additions & 0 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
{
TSRMLS_FETCH();

if (Z_OBJCE_P(expr)->__tostring) {
if (zend_std_cast_object_tostring(expr, expr_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
break;
}
}

if (Z_OBJ_HANDLER_P(expr, cast_object)) {
zval *val;

Expand Down