Guides

LinesIterator
in package
implements Iterator

FinalYes

Table of Contents

Interfaces

Iterator

Properties

$lines  : array<string|int, string>
$peek  : int
$position  : int

Methods

atStart()  : bool
current()  : string
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()  : array<string|int, string>
valid()  : bool
isIndentedBy()  : bool
prepareDocument()  : string

Properties

Methods

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() : array<string|int, string>
Return values
array<string|int, 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