PHP Class lithium\analysis\Parser

Inheritance: extends lithium\core\StaticObject
Exibir arquivo Open project: unionofrad/lithium Class Usage Examples

Public Methods

Method Description
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.

Protected Methods

Method Description
_prepareMatchParams ( array | string $parameters ) : array Helper function to normalize parameters for token matching.

Method Details

_prepareMatchParams() protected static method

Helper function to normalize parameters for token matching.
See also: lithium\analysis\Parser::match()
protected static _prepareMatchParams ( array | string $parameters ) : array
$parameters array | string Params to be normalized.
return array Normalized parameters.

find() public static method

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
return array

match() public static method

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.
return array Array of matching tokens.

matchToken() public static method

Compares two PHP language tokens.
public static matchToken ( array $pattern, array $token ) : boolean
$pattern array Pattern token.
$token array Token to be compared.
return boolean Match result.

token() public static method

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
return mixed

tokenize() public static method

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.
return array An array of tokens in the supplied source code.