Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions php/WP_CLI/Iterators/CSV.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Countable;
use Iterator;
use ReturnTypeWillChange;
use SplFileObject;
use WP_CLI;

Expand Down Expand Up @@ -33,6 +34,7 @@ public function __construct( $filename, $delimiter = ',' ) {
$this->delimiter = $delimiter;
}

#[ReturnTypeWillChange]
public function rewind() {
rewind( $this->file_pointer );

Expand All @@ -42,14 +44,17 @@ public function rewind() {
$this->next();
}

#[ReturnTypeWillChange]
public function current() {
return $this->current_element;
}

#[ReturnTypeWillChange]
public function key() {
return $this->current_index;
}

#[ReturnTypeWillChange]
public function next() {
$this->current_element = false;

Expand All @@ -76,12 +81,14 @@ public function next() {
}
}

#[ReturnTypeWillChange]
public function count() {
$file = new SplFileObject( $this->filename, 'r' );
$file->seek( PHP_INT_MAX );
return $file->key() + 1;
}

#[ReturnTypeWillChange]
public function valid() {
return is_array( $this->current_element );
}
Expand Down