Bug #64919 [Com]: SplFileObject::__toString is not used when casting as string
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
[PHP-BUG] Bug #64919 [NEW]: SplFileObject::__toString is not used when casting as string
From: stof at notk dot org Operating system: PHP version: 5.4.15 Package: SPL related Bug Type: Bug Bug description:SplFileObject::__toString is not used when casting as string 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 bug report at https://bugs.php.net/bug.php?id=64919&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64919&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64919&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64919&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64919&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64919&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64919&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64919&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64919&r=oldversion Not developer issue:https://bugs.php.net/fix.php?id=64919&r=support Expected behavior: https://bugs.php.net/fix.php?id=64919&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64919&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64919&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64919&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64919&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64919&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64919&r=isapi Install GNU Sed:https://bugs.php.net/fix.php?id=64919&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64919&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64919&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64919&r=mysqlcfg