PHP Class Kahlan\Jit\TokenStream

Inheritance: implements ArrayAccess, implements Countable, implements SeekableIterator
Datei anzeigen Open project: crysalead/kahlan Class Usage Examples

Protected Properties

Property Type Description
$_current integer Current pointer key value.
$_data array The items contained in the collection.

Public Methods

Method Description
__construct ( $options = [] ) Constructor
__toString ( ) : string Returns the stream source code.
count ( ) : integer Counts the items of the object.
current ( $token = false ) : array | string Returns the current token or the token value.
getName ( integer $index = null ) : string | null Returns the token type name.
getType ( integer $index = null ) : mixed Returns the type of a token.
getValue ( integer $index = null ) : string | null Returns the current token value.
is ( integer | string $type, integer $index = null ) : boolean Checks if there is a token of the given type at the given position.
key ( ) : integer Returns the current internal pointer value.
load ( string $source, $options = [] ) Load the stream using a string (destroy previous loaded tokens)
next ( mixed $type = false ) : string | null Move to the next token of a given type.
nextMatchingBracket ( ) : string | null Move to the next matching bracket.
nextSequence ( $sequence ) : array | null Moves to the next sequence of tokens.
offsetExists ( integer $offset ) : boolean Checks of there is a token with the given index.
offsetGet ( integer $offset ) : array Returns a token at the given index.
offsetSet ( $offset, $value ) Unsupported
offsetUnset ( $offset ) Unsupported
prev ( $token = false ) : array | string Move to previous.
rewind ( $token = false ) : array | string Sets the internal pointer to zero.
seek ( integer $index, $token = false ) : array | string Move to a specific index.
skipWhile ( array $skips = [] ) : The Skips elements until an element doesn't match the elements in the passed array.
skipWhitespaces ( boolean $skipComment = false ) : The Skips whitespaces and comments next to the current position.
source ( mixed $start = null, mixed $end = null ) : string Returns the stream content.
valid ( ) : boolean Checks if there is a token on the current position.

Protected Methods

Method Description
_getToken ( integer $index, $type ) : string | null Returns the current token value.
_skip ( array $skips ) : The Skips elements until an element doesn't match the elements in the passed array.

Method Details

__construct() public method

Constructor
public __construct ( $options = [] )

__toString() public method

Returns the stream source code.
public __toString ( ) : string
return string

_getToken() protected method

Returns the current token value.
protected _getToken ( integer $index, $type ) : string | null
$index integer Token position, if none given, consider the current iteration position.
return string | null

_skip() protected method

Skips elements until an element doesn't match the elements in the passed array.
protected _skip ( array $skips ) : The
$skips array The elements array to skip.
return The skipped string.

count() public method

Counts the items of the object.
public count ( ) : integer
return integer Returns the number of items in the collection.

current() public method

Returns the current token or the token value.
public current ( $token = false ) : array | string
return array | string

getName() public method

Returns the token type name.
public getName ( integer $index = null ) : string | null
$index integer Token position, if none given, consider the current iteration position.
return string | null

getType() public method

Returns the type of a token.
public getType ( integer $index = null ) : mixed
$index integer Token position, if none given, consider the current iteration position.
return mixed

getValue() public method

Returns the current token value.
public getValue ( integer $index = null ) : string | null
$index integer Token position, if none given, consider the current iteration position.
return string | null

is() public method

Checks if there is a token of the given type at the given position.
public is ( integer | string $type, integer $index = null ) : boolean
$type integer | string Token type.
$index integer Token position, if none given, consider the current iteration position.
return boolean

key() public method

Returns the current internal pointer value.
public key ( ) : integer
return integer

load() public method

Load the stream using a string (destroy previous loaded tokens)
public load ( string $source, $options = [] )
$source string Source code

next() public method

Move to the next token of a given type.
public next ( mixed $type = false ) : string | null
$type mixed Token type to search for.
return string | null Returns the skipped text content (the current is not saved).

nextMatchingBracket() public method

Move to the next matching bracket.
public nextMatchingBracket ( ) : string | null
return string | null Returns the skipped text content.

nextSequence() public method

Moves to the next sequence of tokens.
public nextSequence ( $sequence ) : array | null
return array | null Returns the skipped text content (the current is not saved).

offsetExists() public method

Checks of there is a token with the given index.
public offsetExists ( integer $offset ) : boolean
$offset integer Token index
return boolean

offsetGet() public method

Returns a token at the given index.
public offsetGet ( integer $offset ) : array
$offset integer Token index
return array

offsetSet() public method

Unsupported
public offsetSet ( $offset, $value )

offsetUnset() public method

Unsupported
public offsetUnset ( $offset )

prev() public method

Move to previous.
public prev ( $token = false ) : array | string
return array | string

rewind() public method

Sets the internal pointer to zero.
public rewind ( $token = false ) : array | string
return array | string

seek() public method

Move to a specific index.
public seek ( integer $index, $token = false ) : array | string
$index integer New position
return array | string

skipWhile() public method

Skips elements until an element doesn't match the elements in the passed array.
public skipWhile ( array $skips = [] ) : The
$skips array The elements array to skip.
return The skipped string.

skipWhitespaces() public method

Skips whitespaces and comments next to the current position.
public skipWhitespaces ( boolean $skipComment = false ) : The
$skipComment boolean Skip docblocks as well.
return The skipped string.

source() public method

Returns the stream content.
public source ( mixed $start = null, mixed $end = null ) : string
$start mixed Start offset
$end mixed End offset
return string

valid() public method

Checks if there is a token on the current position.
public valid ( ) : boolean
return boolean

Property Details

$_current protected_oe property

Current pointer key value.
protected int $_current
return integer

$_data protected_oe property

The items contained in the collection.
protected array $_data
return array