You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CsvReader::current() does not check for end of line. #130
CsvReader::current() does not check for end of line.
So if we have the end of the file $line = $this->file->current(); returns us false.
Then php die when try to count for false if (count($this->columnHeaders) === count($line)) {
It as well can happen here:
if (empty($this->columnHeaders)) {
return $this->file->current();
}
So that means public function current(): ?array has a wrong return type (according to code, it has to be false|null|array)
I am currently use composer patch which is adding a simple check.
do {
$line = $this->file->current();
+ if ($line === false) {
+ return false;
+ }
+
// In non-strict mode pad/slice the line to match the column headers
if (!$this->isStrict()) {
if ($this->headersCount > count($line)) {
CsvReader::current() no longer enters the header-mapping loop when the iterator is invalid / at EOF, which avoided count(false) and the TypeError you described. Regression tests cover this path.
Activity
slashrsm commentedon Jul 23, 2026
Closing as fixed in portphp/csv 3.1.0.
CsvReader::current()no longer enters the header-mapping loop when the iterator is invalid / at EOF, which avoidedcount(false)and the TypeError you described. Regression tests cover this path.Upgrade with
"portphp/csv": "^3.1". Thanks for the clear report and patch.