Iterator class responsible for navigating through a list of Tokens.

category phpDocumentor
package Reflection
author Mike van Riel
license MIT
link http://phpdoc.org

 Methods

Initializes the token store.

__construct(string | \phpDocumentor_Reflection_Token[] | \string[] $data) 

see \token_get_all()

Parameters

$data

string\phpDocumentor_Reflection_Token[]\string[]

String to parse or a list of phpDocumentor_Tokens, or the result from a token_get_all() method call.

Returns a count of the items contained in this iterator.

count() : int
Inherited

inherited_from \phpDocumentor_Reflection_TokenIteratorBase::count()

Returns

int

Returns the currently selected item.

current() : mixed
Inherited

inherited_from \phpDocumentor_Reflection_TokenIteratorBase::current()

Returns

mixed

Search forward for a token of $type and _not_ move the internal pointer when found.

findNextByType(int $type, int $max_count, \string[] $stop_at) : bool | \phpDocumentor_Reflection_Token

Parameters

$type

int

The type of token to find as identified by the token constants, i.e. T_STRING

$max_count

int

The maximum number of tokens to iterate, 0 is unlimited (not recommended)

$stop_at

\string[]

Stops searching when one of these token constants or literals is encountered

Returns

Search backward for a token of $type and _not_ move the internal pointer when found.

findPreviousByType(int $type, int $max_count, \string[] $stop_at) : bool | \phpDocumentor_Reflection_Token

Parameters

$type

int

The type of token to find as identified by the token constants, i.e. T_STRING

$max_count

int

The maximum number of tokens to iterate, 0 is unlimited (not recommended)

$stop_at

\string[]

Stops searching when one of these token constants or literals is encountered

Returns

Returns the name of the file where these tokens come from; or null if unknown.

getFilename() : null | string

Returns

nullstring

Returns the starting and ending position of the next curly braces pair, i.e. {}.

getTokenIdsOfBracePair() : \int[]

Returns

\int[]

Returns the starting and ending position of the next parenthesis pair, i.e. ().

getTokenIdsOfParenthesisPair() : \int[]

Returns

\int[]

Search forward for a token of $type and move the internal pointer when found.

gotoNextByType(int $type, int $max_count, \string[] $stop_at) : bool | \phpDocumentor_Reflection_Token

Parameters

$type

int

The type of token to find as identified by the token constants, i.e. T_STRING

$max_count

int

The maximum number of tokens to iterate, 0 is unlimited (not recommended)

$stop_at

\string[]

Stops searching when one of these token constants or literals is encountered

Returns

Search backward for a token of $type and move the internal pointer when found.

gotoPreviousByType(int $type, int $max_count, \string[] $stop_at) : bool | \phpDocumentor_Reflection_Token

Parameters

$type

int

The type of token to find as identified by the token constants, i.e. T_STRING

$max_count

int

The maximum number of tokens to iterate, 0 is unlimited (not recommended)

$stop_at

\string[]

Stops searching when one of these token constants or literals is encountered

Returns

Returns the key of the currently active item.

key() : int | null
Inherited

inherited_from \phpDocumentor_Reflection_TokenIteratorBase::key()

Returns

intnull

Returns true if an item exists.

offsetExists(integer $offset) : bool
Inherited

inherited_from \phpDocumentor_Reflection_TokenIteratorBase::offsetExists()

Parameters

$offset

integer

the index to check.

Returns

bool

Returns the value from the given $offset; or null when no item could be found.

offsetGet(string $offset) : mixed | null
Inherited

inherited_from \phpDocumentor_Reflection_TokenIteratorBase::offsetGet()

Parameters

$offset

string

The index to retrieve.

Returns

mixednull

Due to the pointers it is not allowed to add an item onto the array.

offsetSet(integer $offset, \phpDocumentor_Reflection_Token $value) : void
Inherited

inherited_from \phpDocumentor_Reflection_TokenIteratorBase::offsetSet()

Parameters

$offset

integer

Offset to overwrite.

$value

\phpDocumentor_Reflection_Token

Token to overwrite entry with.

Exceptions

\BadMethodCallException when the user tries to add an item.

Due to the pointers it is not allowed to remove an item from the array.

offsetUnset(int $offset) : void
Inherited

inherited_from \phpDocumentor_Reflection_TokenIteratorBase::offsetUnset()

Parameters

$offset

int

Offset to remove.

Exceptions

\BadMethodCallException if the user invokes this method.

Sets the array pointer to the first item and returns that item.

rewind() : mixed | null
Inherited

inherited_from \phpDocumentor_Reflection_TokenIteratorBase::rewind()

Returns

mixednull

Moves the pointer to a specific position in the store.

seek(int | string $key) : mixed
Inherited

NOTE: this function is used A LOT during the reflection process. This should be as high-performance as possible and ways should be devised to not use it.

inherited_from \phpDocumentor_Reflection_TokenIteratorBase::seek()

Parameters

$key

intstring

the index to move to.

Returns

mixed

Serialize the store.

serialize() : string
Inherited

inherited_from \phpDocumentor_Reflection_TokenIteratorBase::serialize()

Returns

string

Sets the filename where these tokens come from.

setFilename(string $filename) : void

Parameters

$filename

string

path to the file which contains these tokens.

Load a serialized store and populate the pointers.

unserialize(string $serialized) : void
Inherited

inherited_from \phpDocumentor_Reflection_TokenIteratorBase::unserialize()

Parameters

$serialized

string

String to unserialize.

Returns true if the pointer is at an existing item.

valid() : boolean
Inherited

inherited_from \phpDocumentor_Reflection_TokenIteratorBase::valid()

Returns

boolean

Finds a token of $type within $max_count tokens in the given $direction and returns the found token, false if none found.

findByTypeInDirection(int $type, string $direction, int $max_count, \string[] $stop_at) : bool | \phpDocumentor_Reflection_Token

Note: this function does _not_ move the internal pointer.

Parameters

$type

int

The type of token to find as identified by the token constants, i.e. T_STRING

$direction

string

The direction where to search, may be 'next' or 'previous'

$max_count

int

The maximum number of tokens to iterate, 0 is unlimited (not recommended)

$stop_at

\string[]

Stops searching when one of these token constants or literals is encountered

Exceptions

\InvalidArgumentException

Returns

Find the first and last index of a set of matching pair literals (i.e. {}, (), []).

getTokenIdsBetweenPair(string $start_literal, string $end_literal) : \int[]

Parameters

$start_literal

string

Opening character, i.e. {

$end_literal

string

Closing character, i.e. }

Returns

\int[]

Finds a token of $type within $max_count tokens in the given $direction, moves the internal pointer when found * and returns the found token, false if none found.

gotoTokenByTypeInDirection(int $type, string $direction, int $max_count, \string[] $stop_at) : bool | \phpDocumentor_Reflection_Token

Parameters

$type

int

The type of token to find as identified by the token constants, i.e. T_STRING

$direction

string

The direction where to search, may be 'next' or 'previous'

$max_count

int

The maximum number of tokens to iterate, 0 is unlimited (not recommended)

$stop_at

\string[]

Stops searching when one of these token constants or literals is encountered

Exceptions

\InvalidArgumentException

Returns

 Properties

 

<p>Count of items</p>

$count : int
Inherited

inherited_from \phpDocumentor_Reflection_TokenIteratorBase::$$count
 

<p>Current value</p>

$current : mixed
Inherited

inherited_from \phpDocumentor_Reflection_TokenIteratorBase::$$current
 

<p>The name of the file where these tokens come from</p>

$filename : string | null

 

<p>Current key value</p>

$key : int
Inherited

inherited_from \phpDocumentor_Reflection_TokenIteratorBase::$$key
 

<p>Contents for this iterator</p>

$store : \mixed[]
Inherited

inherited_from \phpDocumentor_Reflection_TokenIteratorBase::$$store