php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64919 SplFileObject::__toString is not used when casting as string
Submitted: 2013-05-24 14:36 UTC Modified: 2015-04-05 04:22 UTC
From: stof at notk dot org Assigned:
Status: No Feedback Package: SPL related
PHP Version: 5.4.15 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-05-24 14:36 UTC] stof at notk dot org
Description:
------------
The doc documents SplFileObject::__toString as being an alias for SplFileObject::current.
When calling __toString explicitly, this indeed works (and can return an array when READ_CSV is used, which seems confusing)
But when casting a SplFileObject to a string, it will return the path to the file, like for the SplFileInfo parent class.

Test script:
---------------
$tempFile = new \SplTempFileObject();
$tempFile->fwrite('foobar-');
$tempFile->rewind();

echo (string) $tempFile;
echo PHP_EOL;
echo $tempFile->__toString();

Expected result:
----------------
Result according to the doc:

foobar-
foobar-

Actual result:
--------------
php://temp
foobar-

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-24 14:37 UTC] stof at notk dot org
It might be related to https://bugs.php.net/bug.php?id=64023
 [2015-03-25 22:06 UTC] danack@php.net
-Status: Open +Status: Feedback
 [2015-03-25 22:06 UTC] danack@php.net
I believe this was fixed by the fix to https://bugs.php.net/bug.php?id=64023. I cannot reproduce on PHP 5.4.9

I realise that the version listed on the bug report is 5.4.15 - however testing the repro case in http://3v4l.org/9HuIJ seems to indicate that it was fixed in 5.4.7.

Can you update the issue if you think it still is an issue.
 [2015-04-05 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 22:01:31 2024 UTC