PHP Класс Kahlan\Jit\TokenStream

Наследование: implements ArrayAccess, implements Countable, implements SeekableIterator
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_current integer Current pointer key value.
$_data array The items contained in the collection.

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
_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.

Описание методов

__construct() публичный Метод

Constructor
public __construct ( $options = [] )

__toString() публичный Метод

Returns the stream source code.
public __toString ( ) : string
Результат string

_getToken() защищенный Метод

Returns the current token value.
protected _getToken ( integer $index, $type ) : string | null
$index integer Token position, if none given, consider the current iteration position.
Результат string | null

_skip() защищенный Метод

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.
Результат The skipped string.

count() публичный Метод

Counts the items of the object.
public count ( ) : integer
Результат integer Returns the number of items in the collection.

current() публичный Метод

Returns the current token or the token value.
public current ( $token = false ) : array | string
Результат array | string

getName() публичный Метод

Returns the token type name.
public getName ( integer $index = null ) : string | null
$index integer Token position, if none given, consider the current iteration position.
Результат string | null

getType() публичный Метод

Returns the type of a token.
public getType ( integer $index = null ) : mixed
$index integer Token position, if none given, consider the current iteration position.
Результат mixed

getValue() публичный Метод

Returns the current token value.
public getValue ( integer $index = null ) : string | null
$index integer Token position, if none given, consider the current iteration position.
Результат string | null

is() публичный Метод

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.
Результат boolean

key() публичный Метод

Returns the current internal pointer value.
public key ( ) : integer
Результат integer

load() публичный Метод

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

next() публичный Метод

Move to the next token of a given type.
public next ( mixed $type = false ) : string | null
$type mixed Token type to search for.
Результат string | null Returns the skipped text content (the current is not saved).

nextMatchingBracket() публичный Метод

Move to the next matching bracket.
public nextMatchingBracket ( ) : string | null
Результат string | null Returns the skipped text content.

nextSequence() публичный Метод

Moves to the next sequence of tokens.
public nextSequence ( $sequence ) : array | null
Результат array | null Returns the skipped text content (the current is not saved).

offsetExists() публичный Метод

Checks of there is a token with the given index.
public offsetExists ( integer $offset ) : boolean
$offset integer Token index
Результат boolean

offsetGet() публичный Метод

Returns a token at the given index.
public offsetGet ( integer $offset ) : array
$offset integer Token index
Результат array

offsetSet() публичный Метод

Unsupported
public offsetSet ( $offset, $value )

offsetUnset() публичный Метод

Unsupported
public offsetUnset ( $offset )

prev() публичный Метод

Move to previous.
public prev ( $token = false ) : array | string
Результат array | string

rewind() публичный Метод

Sets the internal pointer to zero.
public rewind ( $token = false ) : array | string
Результат array | string

seek() публичный Метод

Move to a specific index.
public seek ( integer $index, $token = false ) : array | string
$index integer New position
Результат array | string

skipWhile() публичный Метод

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.
Результат The skipped string.

skipWhitespaces() публичный Метод

Skips whitespaces and comments next to the current position.
public skipWhitespaces ( boolean $skipComment = false ) : The
$skipComment boolean Skip docblocks as well.
Результат The skipped string.

source() публичный Метод

Returns the stream content.
public source ( mixed $start = null, mixed $end = null ) : string
$start mixed Start offset
$end mixed End offset
Результат string

valid() публичный Метод

Checks if there is a token on the current position.
public valid ( ) : boolean
Результат boolean

Описание свойств

$_current защищенное свойство

Current pointer key value.
protected int $_current
Результат integer

$_data защищенное свойство

The items contained in the collection.
protected array $_data
Результат array