메소드 | 설명 | |
---|---|---|
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. |
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 |
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. |
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. |