php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64023 Overloading __toString() in SplFileInfo has no effect
Submitted: 2013-01-18 15:24 UTC Modified: 2013-01-19 15:54 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: php at lightning dot hu Assigned: cataphract (profile)
Status: Closed Package: SPL related
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
 [2013-01-18 15:24 UTC] 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- /


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-19 13:48 UTC] cataphract@php.net
-Status: Open +Status: Verified
 [2013-01-19 14:58 UTC] cataphract@php.net
-Assigned To: +Assigned To: cataphract
 [2013-01-23 12:30 UTC] cataphract@php.net
-Status: Verified +Status: Closed
 [2013-01-23 12:30 UTC] cataphract@php.net
Automatic comment on behalf of glopes@nebm.ist.utl.pt
Revision: http://git.php.net/?p=php-src.git;a=commit;h=aa0adce47d9b8ead59efede63a769e395e27bcd5
Log: Fix bug #64023 (__toString() & SplFileInfo)
 [2013-03-01 18:32 UTC] stas@php.net
Automatic comment on behalf of glopes@nebm.ist.utl.pt
Revision: http://git.php.net/?p=php-src.git;a=commit;h=aa0adce47d9b8ead59efede63a769e395e27bcd5
Log: Fix bug #64023 (__toString() & SplFileInfo)
 [2014-10-07 23:20 UTC] stas@php.net
Automatic comment on behalf of glopes@nebm.ist.utl.pt
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=aa0adce47d9b8ead59efede63a769e395e27bcd5
Log: Fix bug #64023 (__toString() & SplFileInfo)
 [2014-10-07 23:31 UTC] stas@php.net
Automatic comment on behalf of glopes@nebm.ist.utl.pt
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=aa0adce47d9b8ead59efede63a769e395e27bcd5
Log: Fix bug #64023 (__toString() & SplFileInfo)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 19:01:29 2024 UTC