public static function parse($document): Generator
    {
        self::$document = self::filterDocument($document);
        list(self::$delimiter, self::$enclosure, ) = self::$document->getCsvControl();
        self::$trim_mask = str_replace([self::$delimiter, self::$enclosure], '', " \t\0\x0B");
        self::$document->setFlags(0);
        self::$document->rewind();
        while (self::$document->valid()) {
            $record = self::extractRecord();
            if (!in_array(null, $record, true)) {
                yield $record;
            }
        }
    }
public static function parse($document): Generator
    {
        self::$document = self::filterDocument($document);
        list(self::$delimiter, self::$enclosure, ) = self::$document->getCsvControl();
        self::$trim_mask = str_replace([self::$delimiter, self::$enclosure], '', " \t\0\x0B");
        self::$document->setFlags(0);
        self::$document->rewind();
        while (self::$document->valid()) {
            $record = self::extractRecord();
            if (!in_array(null, $record, true)) {
                yield $record;
            }
        }
    }
public static function parse ( $ document ) : Generator { self :: $ document = self :: filterDocument ( $ document ) ; list ( self :: $ delimiter , self :: $ enclosure , ) = self :: $ document -> getCsvControl ( ) ; self :: $ trim_mask = str_replace ( [ self :: $ delimiter , self :: $ enclosure ] , '' , " \t\0\x0B" ) ; self :: $ document -> setFlags ( 0 ) ; self :: $ document -> rewind ( ) ; while ( self :: $ document -> valid ( ) ) { $ record = self :: extractRecord ( ) ; if ( ! in_array ( null , $ record , true ) ) { yield $ record ; } } }
Converts the document into a CSV record iterator.

In PHP7.4+ you'll be able to do

<code>
$file = new SplFileObject('/path/to/file.csv', 'r');
$file->setFlags(SplFileObject::READ_CSV | SplFileObject::READ_AHEAD | SplFileObject::SKIP_EMPTY);
$file->setCsvControl($delimiter, $enclosure, '');
foreach ($file as $record) {
//$record escape mechanism is blocked by the empty string
}
</code>

In PHP7.3- you can do

<code>
$file = new SplFileObject('/path/to/file.csv', 'r');
$it = EmptyEscapeParser::parse($file); //parsing will be done while ignoring the escape character value.
foreach ($it as $record) {
//fgetcsv is not directly use hence the escape char is not taken into account
}
</code>

Each record array contains strings elements.

@param SplFileObject|Stream $document

@return Generator|array[]
Converts the document into a CSV record iterator .