Documentation

PHP_Token_Stream
in package
implements ArrayAccess, Countable, SeekableIterator

A stream of PHP tokens.

Tags
author

Sebastian Bergmann sebastian@phpunit.de

copyright

Sebastian Bergmann sebastian@phpunit.de

license

http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License

link
http://github.com/sebastianbergmann/php-token-stream/tree
since

Class available since Release 1.0.0

Interfaces, Classes and Traits

ArrayAccess
Countable
SeekableIterator

Table of Contents

$classes  : array<string|int, mixed>
$customTokens  : array<string|int, mixed>
$filename  : string
$functions  : array<string|int, mixed>
$includes  : array<string|int, mixed>
$interfaces  : array<string|int, mixed>
$linesOfCode  : array<string|int, mixed>
$lineToFunctionMap  : array<string|int, mixed>
$position  : int
$tokens  : array<string|int, mixed>
$traits  : array<string|int, mixed>
__construct()  : mixed
Constructor.
__destruct()  : mixed
Destructor.
__toString()  : string
count()  : int
current()  : PHP_Token
getClasses()  : array<string|int, mixed>
getFilename()  : string
getFunctionForLine()  : string
Returns the name of the function or method a line belongs to.
getFunctions()  : array<string|int, mixed>
getIncludes()  : array<string|int, mixed>
Gets the names of all files that have been included using include(), include_once(), require() or require_once().
getInterfaces()  : array<string|int, mixed>
getLinesOfCode()  : array<string|int, mixed>
getTraits()  : array<string|int, mixed>
key()  : int
next()  : mixed
offsetExists()  : bool
offsetGet()  : mixed
offsetSet()  : mixed
offsetUnset()  : mixed
rewind()  : mixed
seek()  : mixed
Seek to an absolute position.
tokens()  : array<string|int, PHP_Token>
valid()  : bool
parse()  : mixed
scan()  : mixed
Scans the source for sequences of characters and converts them into a stream of tokens.
addFunctionToMap()  : mixed

Properties

$classes

protected array<string|int, mixed> $classes

$customTokens

protected static array<string|int, mixed> $customTokens = array('(' => 'PHP_Token_OPEN_BRACKET', ')' => 'PHP_Token_CLOSE_BRACKET', '[' => 'PHP_Token_OPEN_SQUARE', ']' => 'PHP_Token_CLOSE_SQUARE', '{' => 'PHP_Token_OPEN_CURLY', '}' => 'PHP_Token_CLOSE_CURLY', ';' => 'PHP_Token_SEMICOLON', '.' => 'PHP_Token_DOT', ',' => 'PHP_Token_COMMA', '=' => 'PHP_Token_EQUAL', '<' => 'PHP_Token_LT', '>' => 'PHP_Token_GT', '+' => 'PHP_Token_PLUS', '-' => 'PHP_Token_MINUS', '*' => 'PHP_Token_MULT', '/' => 'PHP_Token_DIV', '?' => 'PHP_Token_QUESTION_MARK', '!' => 'PHP_Token_EXCLAMATION_MARK', ':' => 'PHP_Token_COLON', '"' => 'PHP_Token_DOUBLE_QUOTES', '@' => 'PHP_Token_AT', '&' => 'PHP_Token_AMPERSAND', '%' => 'PHP_Token_PERCENT', '|' => 'PHP_Token_PIPE', '$' => 'PHP_Token_DOLLAR', '^' => 'PHP_Token_CARET', '~' => 'PHP_Token_TILDE', '`' => 'PHP_Token_BACKTICK')

$filename

protected string $filename

$functions

protected array<string|int, mixed> $functions

$includes

protected array<string|int, mixed> $includes

$interfaces

protected array<string|int, mixed> $interfaces

$linesOfCode

protected array<string|int, mixed> $linesOfCode = array('loc' => 0, 'cloc' => 0, 'ncloc' => 0)

$lineToFunctionMap

protected array<string|int, mixed> $lineToFunctionMap = array()

$position

protected int $position = 0

$tokens

protected array<string|int, mixed> $tokens = array()

$traits

protected array<string|int, mixed> $traits

Methods

__construct()

Constructor.

public __construct(string $sourceCode) : mixed
Parameters
$sourceCode : string
Return values
mixed

__destruct()

Destructor.

public __destruct() : mixed
Return values
mixed

__toString()

public __toString() : string
Return values
string

count()

public count() : int
Return values
int

getClasses()

public getClasses() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFilename()

public getFilename() : string
Tags
since

Method available since Release 1.1.0

Return values
string

getFunctionForLine()

Returns the name of the function or method a line belongs to.

public getFunctionForLine(mixed $line) : string
Parameters
$line : mixed
Tags
since

Method available since Release 1.2.0

Return values
string

or null if the line is not in a function or method

getFunctions()

public getFunctions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getIncludes()

Gets the names of all files that have been included using include(), include_once(), require() or require_once().

public getIncludes([bool $categorize = false ][, string $category = null ]) : array<string|int, mixed>

Parameter $categorize set to TRUE causing this function to return a multi-dimensional array with categories in the keys of the first dimension and constants and their values in the second dimension.

Parameter $category allow to filter following specific inclusion type

Parameters
$categorize : bool = false

OPTIONAL

$category : string = null

OPTIONAL Either 'require_once', 'require', 'include_once', 'include'.

Tags
since

Method available since Release 1.1.0

Return values
array<string|int, mixed>

getInterfaces()

public getInterfaces() : array<string|int, mixed>
Return values
array<string|int, mixed>

getLinesOfCode()

public getLinesOfCode() : array<string|int, mixed>
Return values
array<string|int, mixed>

getTraits()

public getTraits() : array<string|int, mixed>
Tags
since

Method available since Release 1.1.0

Return values
array<string|int, mixed>

key()

public key() : int
Return values
int

next()

public next() : mixed
Return values
mixed

offsetExists()

public offsetExists(int $offset) : bool
Parameters
$offset : int
Return values
bool

offsetGet()

public offsetGet(int $offset) : mixed
Parameters
$offset : int
Tags
throws
OutOfBoundsException
Return values
mixed

offsetSet()

public offsetSet(int $offset, mixed $value) : mixed
Parameters
$offset : int
$value : mixed
Return values
mixed

offsetUnset()

public offsetUnset(int $offset) : mixed
Parameters
$offset : int
Tags
throws
OutOfBoundsException
Return values
mixed

rewind()

public rewind() : mixed
Return values
mixed

seek()

Seek to an absolute position.

public seek(int $position) : mixed
Parameters
$position : int
Tags
throws
OutOfBoundsException
Return values
mixed

valid()

public valid() : bool
Return values
bool

parse()

protected parse() : mixed
Return values
mixed

scan()

Scans the source for sequences of characters and converts them into a stream of tokens.

protected scan(string $sourceCode) : mixed
Parameters
$sourceCode : string
Return values
mixed

addFunctionToMap()

private addFunctionToMap(string $name, int $startLine, int $endLine) : mixed
Parameters
$name : string
$startLine : int
$endLine : int
Return values
mixed

Search results