PHP Class lithium\analysis\Parser

Inheritance: extends lithium\core\StaticObject
Afficher le fichier Open project: unionofrad/lithium Class Usage Examples

Méthodes publiques

Méthode 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.

Méthodes protégées

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

Method Details

_prepareMatchParams() protected static méthode

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.
Résultat array Normalized parameters.

find() public static méthode

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
Résultat array

match() public static méthode

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.
Résultat array Array of matching tokens.

matchToken() public static méthode

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

token() public static méthode

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
Résultat mixed

tokenize() public static méthode

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