PHP Класс lithium\analysis\Parser

Наследование: extends lithium\core\StaticObject
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
find ( string $code, string $pattern, array $options = [] ) : array Finds a pattern in a block of code.
match ( string $code, string $parameters, array $options = [] ) : array Token pattern matching.
matchToken ( array $pattern, array $token ) : boolean Compares two PHP language tokens.
token ( string $string, array $options = [] ) : mixed Convenience method to get the token name of a PHP code string. If multiple tokens are present in the string, only the first is returned.
tokenize ( string $code, array $options = [] ) : array Splits the provided $code into PHP language tokens.

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

Метод Описание
_prepareMatchParams ( array | string $parameters ) : array Helper function to normalize parameters for token matching.

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

_prepareMatchParams() защищенный статический Метод

Helper function to normalize parameters for token matching.
См. также: lithium\analysis\Parser::match()
protected static _prepareMatchParams ( array | string $parameters ) : array
$parameters array | string Params to be normalized.
Результат array Normalized parameters.

find() публичный статический Метод

Finds a pattern in a block of code.
public static find ( string $code, string $pattern, array $options = [] ) : array
$code string
$pattern string
$options array The list of options to be used when parsing / matching `$code`: - 'ignore': An array of token names to ignore while parsing, defaults to `array('T_WHITESPACE')` - 'lineBreaks': If true, all tokens in a single pattern match must appear on the same line of code, defaults to false - 'startOfLine': If true, the pattern must match starting with the beginning of the line of code to be matched, defaults to false
Результат array

match() публичный статический Метод

Token pattern matching.
public static match ( string $code, string $parameters, array $options = [] ) : array
$code string Source code to be analyzed.
$parameters string An array containing token patterns to be matched.
$options array The list of options to be used when matching `$code`: - 'ignore': An array of language tokens to ignore. - 'return': If set to 'content' returns an array of matching tokens.
Результат array Array of matching tokens.

matchToken() публичный статический Метод

Compares two PHP language tokens.
public static matchToken ( array $pattern, array $token ) : boolean
$pattern array Pattern token.
$token array Token to be compared.
Результат boolean Match result.

token() публичный статический Метод

Convenience method to get the token name of a PHP code string. If multiple tokens are present in the string, only the first is returned.
public static token ( string $string, array $options = [] ) : mixed
$string string String of PHP code to get the token name of, i.e. `'=>'` or `'static'`.
$options array
Результат mixed

tokenize() публичный статический Метод

Splits the provided $code into PHP language tokens.
public static tokenize ( string $code, array $options = [] ) : array
$code string Source code to be tokenized.
$options array Options consists of: -'wrap': Boolean indicating whether or not to wrap the supplied code in PHP tags. -'ignore': An array containing PHP language tokens to ignore. -'include': If supplied, an array of the only language tokens to include in the output.
Результат array An array of tokens in the supplied source code.