Guides

LinesIterator
in package
implements Iterator, Countable

FinalYes

Table of Contents

Interfaces

Iterator
Countable

Properties

$leadingLinesRemoved  : int
$lines  : string[]
$peek  : int
$position  : int

Methods

atStart()  : bool
count()  : int
current()  : string
getLeadingLinesRemoved()  : int
Number of empty lines removed from the start of the document by load(), so that line numbers can still be mapped back to the loaded document.
getNextLine()  : string|null
isBlockLine()  : bool
Is this line "indented"?
isEmpty()  : bool
isEmptyLine()  : bool
isIndented()  : bool
Check if line is an indented one.
isNullOrEmptyLine()  : bool
key()  : int
load()  : void
next()  : void
peek()  : string|null
Moves the lookahead token forward.
prev()  : void
rewind()  : void
toArray()  : string[]
valid()  : bool
isIndentedBy()  : bool
prepareDocument()  : string

Properties

Methods

getLeadingLinesRemoved()

Number of empty lines removed from the start of the document by load(), so that line numbers can still be mapped back to the loaded document.

public getLeadingLinesRemoved() : int
Return values
int

getNextLine()

public getNextLine() : string|null
Return values
string|null

isBlockLine()

Is this line "indented"?

public static isBlockLine(string|null $line[, int $minIndent = 1 ]) : bool

A blank line also counts as a "block" line, as it may be the empty line between, for example, a ".. note::" directive and the indented content on the next lines.

Parameters
$line : string|null
$minIndent : int = 1

can be used to require a specific level of indentation for non-blank lines (number of spaces)

Return values
bool

isEmptyLine()

public static isEmptyLine(string|null $line) : bool
Parameters
$line : string|null
Tags
psalm-assert-if-false

non-empty-string $line

Return values
bool

isIndented()

Check if line is an indented one.

public static isIndented(string $line, int $minIndent) : bool

This does not include blank lines, use isBlockLine() to check for blank or indented lines.

Parameters
$line : string
$minIndent : int

can be used to require a specific level of indentation (number of spaces)

Return values
bool

isNullOrEmptyLine()

public static isNullOrEmptyLine(string|null $line) : bool
Parameters
$line : string|null
Tags
psalm-assert-if-true

null $line

Return values
bool

load()

public load(string $document[, bool $preserveSpace = false ]) : void
Parameters
$document : string
$preserveSpace : bool = false

peek()

Moves the lookahead token forward.

public peek() : string|null
Return values
string|null

prev()

public prev() : void

Work around for Production's eating one line too many

Tags
todo

Revisit The Loop in DocumentParserContext::parseLines() and see if the Look Ahead timing should be done differently

toArray()

public toArray() : string[]
Return values
string[]

isIndentedBy()

private static isIndentedBy(string $line, int $minIndent, string $indentationChar) : bool
Parameters
$line : string
$minIndent : int
$indentationChar : string
Return values
bool

prepareDocument()

private prepareDocument(string $document) : string
Parameters
$document : string
Return values
string
On this page

Search results