Documentation

FileInputStream extends StringInputStream
in package
implements InputStream

The FileInputStream loads a file to be parsed.

since 2.4, to remove in 3.0. Use a string in the scanner instead.

So right now we read files into strings and then process the string. We chose to do this largely for the sake of expediency of development, and also because we could optimize toward processing arbitrarily large chunks of the input. But in the future, we'd really like to rewrite this class to efficiently handle lower level stream reads (and thus efficiently handle large documents).

Table of Contents

Interfaces

InputStream
Interface for stream readers.

Properties

$errors  : mixed
Parse errors.

Methods

__construct()  : mixed
Load a file input stream.
__toString()  : mixed
charsUntil()  : mixed
Read to a particular match (or until $max bytes are consumed).
charsWhile()  : string
Returns the string so long as $bytes matches.
columnOffset()  : int
Returns the current column of the current line that the tokenizer is at.
current()  : string
Get the current character.
currentLine()  : mixed
Returns the current line that the tokenizer is at.
getColumnOffset()  : mixed
getCurrentLine()  : mixed
key()  : mixed
next()  : mixed
Advance the pointer.
peek()  : mixed
Look ahead without moving cursor.
remainingChars()  : string
Get all characters until EOF.
rewind()  : mixed
Rewind to the start of the string.
unconsume()  : mixed
Unconsume characters.
valid()  : bool
Is the current pointer location valid.
replaceLinefeeds()  : mixed
Replace linefeed characters according to the spec.

Properties

Methods

__construct()

Load a file input stream.

public __construct(string $data[, string $encoding = 'UTF-8' ][, string $debug = '' ]) : mixed
Parameters
$data : string

The file or url path to load.

$encoding : string = 'UTF-8'

The encoding to use for the data.

$debug : string = ''

A fprintf format to use to echo the data on stdout.

charsUntil()

Read to a particular match (or until $max bytes are consumed).

public charsUntil(string $bytes[, int $max = null ]) : mixed

This operates on byte sequences, not characters.

Matches as far as possible until we reach a certain set of bytes and returns the matched substring.

Parameters
$bytes : string

Bytes to match.

$max : int = null

Maximum number of bytes to scan.

Return values
mixed

Index or false if no match is found. You should use strong equality when checking the result, since index could be 0.

charsWhile()

Returns the string so long as $bytes matches.

public charsWhile(string $bytes[, int $max = null ]) : string

Matches as far as possible with a certain set of bytes and returns the matched substring.

Parameters
$bytes : string

A mask of bytes to match. If ANY byte in this mask matches the current char, the pointer advances and the char is part of the substring.

$max : int = null

The max number of chars to read.

Return values
string

columnOffset()

Returns the current column of the current line that the tokenizer is at.

public columnOffset() : int

Newlines are column 0. The first char after a newline is column 1.

Return values
int

The column number.

current()

Get the current character.

public current() : string
Attributes
#[ReturnTypeWillChange]
Return values
string

The current character.

currentLine()

Returns the current line that the tokenizer is at.

public currentLine() : mixed

next()

Advance the pointer.

public next() : mixed

This is part of the Iterator interface.

Attributes
#[ReturnTypeWillChange]

remainingChars()

Get all characters until EOF.

public remainingChars() : string

This reads to the end of the file, and sets the read marker at the end of the file.

Note this performs bounds checking.

Return values
string

Returns the remaining text. If called when the InputStream is already exhausted, it returns an empty string.

rewind()

Rewind to the start of the string.

public rewind() : mixed
Attributes
#[ReturnTypeWillChange]

unconsume()

Unconsume characters.

public unconsume([int $howMany = 1 ]) : mixed
Parameters
$howMany : int = 1

The number of characters to unconsume.

valid()

Is the current pointer location valid.

public valid() : bool
Attributes
#[ReturnTypeWillChange]
Return values
bool

Whether the current pointer location is valid.

replaceLinefeeds()

Replace linefeed characters according to the spec.

protected replaceLinefeeds(mixed $data) : mixed
Parameters
$data : mixed

        
On this page

Search results