Parser
in package
Read onlyYes
FinalYes
Builds a lossless {@see Document} from raw bytes.
Table of Contents
Constants
- LINE : mixed = '/^[ \t]*(\d{1,3})(?:[ \t]+(@[^@]+@))?[ \t]+([^...
- Level, optional xref, tag, optional value after exactly one delimiter.
Methods
- __construct() : mixed
- checkFile() : Version|null
- declaredVersion() : Version|null
- parse() : Document
- parseRecord() : Document
- parseRecords() : Document
Constants
LINE
Level, optional xref, tag, optional value after exactly one delimiter.
public
mixed
LINE
= '/^[ \t]*(\d{1,3})(?:[ \t]+(@[^@]+@))?[ \t]+([^ \t]+)(?: (.*))?$/s'
Methods
__construct()
public
__construct([EncodingDetector $detector = new EncodingDetector() ]) : mixed
Parameters
- $detector : EncodingDetector = new EncodingDetector()
-
@internal
checkFile()
public
checkFile(Node|null $first, bool $hasTrailer, int|null $afterTrailer, Node|null $head, ReadOptions $options, callable(Diagnostic): void $add) : Version|null
Parameters
- $first : Node|null
- $hasTrailer : bool
- $afterTrailer : int|null
-
line of the first record after the last TRLR; null when there is none
- $head : Node|null
- $options : ReadOptions
- $add : callable(Diagnostic): void
Return values
Version|null —the declared version; null when it is unknown or given in the options
declaredVersion()
public
static declaredVersion(Node $head[, bool $dialects = true ]) : Version|null
Parameters
- $head : Node
- $dialects : bool = true
Return values
Version|nullparse()
public
parse(string $bytes[, ReadOptions $options = new ReadOptions() ]) : Document
Parameters
- $bytes : string
- $options : ReadOptions = new ReadOptions()
Return values
DocumentparseRecord()
public
parseRecord(string $bytes, Encoding $encoding, Version $version, bool $bom, string $lineEnding, int $firstLine, ReadOptions $options) : Document
Parameters
- $bytes : string
- $encoding : Encoding
- $version : Version
- $bom : bool
- $lineEnding : string
- $firstLine : int
- $options : ReadOptions
Return values
DocumentparseRecords()
public
parseRecords(array<int, array{string, int}> $records, Encoding $encoding, Version $version, bool $bom, string $lineEnding, ReadOptions $options) : Document
Parameters
- $records : array<int, array{string, int}>
-
bytes and first line of each, in file order
- $encoding : Encoding
- $version : Version
- $bom : bool
- $lineEnding : string
- $options : ReadOptions