Bug #64023 [Opn->Ver]: Overloading __toString() in SplFileInfo has no effect

From: Date: Sat, 19 Jan 2013 13:48:41 +0000
Subject: Bug #64023 [Opn->Ver]: Overloading __toString() in SplFileInfo has no effect
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-176127@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64023&edit=1 ID: 64023 Updated by: cataphract@php.net Reported by: php at lightning dot hu Summary: Overloading __toString() in SplFileInfo has no effect -Status: Open +Status: Verified Type: Bug Package: SPL related Operating System: Linux PHP Version: Irrelevant Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2013-01-18 15:24:39] php at lightning dot hu Description: ------------ When I overload the __toString() magic method in the SplFileInfo class or in one of it's derivatives it does not work if I concatenate the object with a string. See the example for a simple demonstration. Test script: --------------- class A extends \SplFileInfo { public function __toString() {return ' -expected- ';} } $a = new A('/'); // Works echo $a, $a->__toString(), $a->__toString() . ''; // Does not work - outputs parent::__toString() echo $a . ''; Expected result: ---------------- -expected- -expected- -expected- / ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64023&edit=1

« previous php.bugs (#176127) next »