|  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
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();

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

Expected result:
Result according to the doc:


Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-24 14:37 UTC] stof at notk dot org
It might be related to
 [2015-03-25 22:06 UTC]
-Status: Open +Status: Feedback
 [2015-03-25 22:06 UTC]
I believe this was fixed by the fix to 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 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-2022 The PHP Group
All rights reserved.
Last updated: Wed Aug 10 05:05:46 2022 UTC