mirror of
https://github.com/php/php-src.git
synced 2024-12-11 10:54:47 +08:00
aa0adce47d
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.
21 lines
397 B
PHP
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-
|