Bug #64023 [Ver]: Overloading __toString() in SplFileInfo has no effect
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: Verified
Type: Bug
Package: SPL related
Operating System: Linux
PHP Version: Irrelevant
Assigned To: cataphract
Block user comment: N
Private report: N
New Comment:
Fix: https://github.com/cataphract/php-src/compare/bug64023
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
Thread (4 messages)