facebook / facebook/hhvm

SplFileObject::fgetcsv does not return null for last line in CSV mode

未关闭
#5,823 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
php5 incompatibility
主要语言
C++
星标
18.7k
派生
3.1k
平均合并
1 小时 47 分钟
30 天内合并 PR
2

描述

I'm reading CSV files using SplFileObject class and `fgetcsv` method. Below code does not work as intended in HHVM 3.8.0 meaning `fgetcsv` does return `false` on the LAST line. In PHP 5.6.7-1 the last line returns `null`.

With the following CSV file

``` csv
row11;;row13
row21;row22;row23

```

and the following code

``` php
$aFile = new SplFileObject ($aPath);
$aFile->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::READ_AHEAD | SplFileObject::DROP_NEW_LINE | SplFileObject::READ_CSV);
$aFile->setCsvControl(';');

for($i = 0; $i < 3; $i++) {
$row = $aFile->fgetcsv();
var_dump($row);
}
```

Result for PHP

```
array(3) {
[0] =>
string(5) "row11"
[1] =>
string(0) ""
[2] =>
string(5) "row13"
}
array(3) {
[0] =>
string(5) "row21"
[1] =>
string(5) "row22"
[2] =>
string(5) "row23"
}
NULL
```

Result for HHVM

```
array(3) {
[0]=>
string(5) "row11"
[1]=>
string(0) ""
[2]=>
string(5) "row13"
}
array(3) {
[0]=>
string(5) "row21"
[1]=>
string(5) "row22"
[2]=>
string(5) "row23"
}
bool(false)
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。