Edit report at https://bugs.php.net/bug.php?id=64919&edit=1
ID: 64919
Comment by: stof at notk dot org
Reported by: stof at notk dot org
Summary: SplFileObject::__toString is not used when casting
as string
Status: Open
Type: Bug
Package: SPL related
PHP Version: 5.4.15
Block user comment: N
Private report: N
New Comment:
It might be related to https://bugs.php.net/bug.php?id=64023
Previous Comments:
------------------------------------------------------------------------
[2013-05-24 14:36:26] 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-
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64919&edit=1