php-src/ext/spl/tests/bug64023.phpt
Gustavo Lopes aa0adce47d Fix bug #64023 (__toString() & SplFileInfo)
Defining a __toString() method was having no effect when concatenating
the object. This was because the cast_object() handler would ignore
__toString().

Using echo() directly would actually use __toString(), but this was a
bug: the ECHO handler would try zend_std_cast_object_tostring() before
cast_object(), but cast_object() should have priority as
zend_std_cast_object_tostring() assumes an object with a
zend_class_entry.
2013-01-22 11:33:29 +01:00

21 lines
397 B
PHP

--TEST--
Bug #64023: Overloading __toString() in SplFileInfo has no effect
--FILE--
<?php
class A extends \SplFileInfo
{
public function __toString() {return ' -expected- ';}
}
$a = new A('/');
// Works
echo $a, $a->__toString(), $a->__toString() . '', "\n";
// Does not work - outputs parent::__toString()
echo $a . '', "\n";
--EXPECT--
-expected- -expected- -expected-
-expected-