Bug #77024 [NEW]: SplFileObject::__toString() may return array
From: cmb
Operating system: *
PHP version: master-Git-2018-10-16 (Git)
Package: SPL related
Bug Type: Bug
Bug description:SplFileObject::__toString() may return array
Description:
------------
SplFileObject::__toString() is an alias of ::current(), but since
the latter returns an array instead of a string, if the READ_CSV
flag is set, the former also does. This is at least rather
confusing, since one expects __toString() to return a string.
See also <http://php.net/manual/en/splfileobject.tostring.php#123238>.
Test script:
---------------
<?php
$file = new SplTempFileObject;
$file->fputcsv(['foo', 'bar', 'baz']);
$file->rewind();
$file->setFlags(SplFileObject::READ_CSV);
echo gettype($file->__toString());
?>
Expected result:
----------------
string
Actual result:
--------------
array
--
Edit bug report at https://bugs.php.net/bug.php?id=77024&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77024&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77024&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77024&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77024&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77024&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77024&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77024&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77024&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77024&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77024&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77024&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77024&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77024&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77024&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77024&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77024&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77024&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77024&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77024&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77024&r=mysqlcfg
Thread (4 messages)
- cmb@php.net