Skip to content

Commit

Permalink
Issue #114 ParserCSVIterator set ReturnTypeWillChange attribute (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
herbdool committed Jul 15, 2022
1 parent 00998e6 commit 2d13fe6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libraries/ParserCSV.inc
Expand Up @@ -38,6 +38,7 @@ class ParserCSVIterator implements Iterator {
/**
* Closes the current file.
*/
#[\ReturnTypeWillChange]
public function releaseHandler() {
if ($this->handle) {
fclose($this->handle);
Expand All @@ -48,6 +49,7 @@ class ParserCSVIterator implements Iterator {
/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function rewind($pos = 0) {
if ($this->handle) {
fseek($this->handle, $pos);
Expand All @@ -58,38 +60,42 @@ class ParserCSVIterator implements Iterator {
/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function next() {
if ($this->handle) {
$this->currentLine = feof($this->handle) ? NULL : fgets($this->handle);
$this->currentPos = ftell($this->handle);
return $this->currentLine;
}
}

/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function valid() {
return isset($this->currentLine);
}

/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function current() {
return $this->currentLine;
}

/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function currentPos() {
return $this->currentPos;
}

/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function key() {
return 'line';
}
Expand Down Expand Up @@ -126,7 +132,6 @@ class ParserCSV {
$this->startByte = 0;
$this->lineLimit = 0;
$this->lastLinePos = 0;
ini_set('auto_detect_line_endings', TRUE);
if (extension_loaded('mbstring') && config_get('feeds.settings', 'feeds_use_mbstring')) {
$this->useMbString = TRUE;
}
Expand Down Expand Up @@ -249,6 +254,7 @@ class ParserCSV {
$maxTime = empty($this->timeout) ? FALSE : (microtime() + $this->timeout);
$linesParsed = 0;

/** @var \ParserCSVIterator $lineIterator */
for ($lineIterator->rewind($this->startByte); $lineIterator->valid(); $lineIterator->next()) {

// Make really sure we've got lines without trailing newlines.
Expand Down

0 comments on commit 2d13fe6

Please sign in to comment.