public static function match($code, $parameters, array $options = []) {
		$defaults = ['ignore' => ['T_WHITESPACE'], 'return' => true];
		$options += $defaults;
		$parameters = static::_prepareMatchParams($parameters);

		$tokens = is_array($code) ? $code : static::tokenize($code, $options);
		$results = [];

		foreach ($tokens as $i => $token) {
			if (!array_key_exists($token['name'], $parameters)) {
				if (!in_array('*', $parameters)) {
					continue;
				}
			}
			$param = $parameters[$token['name']];

			if (isset($param['before']) && $i > 0) {
				if (!in_array($tokens[$i - 1]['name'], (array) $param['before'])) {
					continue;
				}
			}

			if (isset($param['after']) && $i + 1 < count($tokens)) {
				 if (!in_array($tokens[$i + 1]['name'], (array) $param['after'])) {
					continue;
				}
			}
			$results[] = isset($token[$options['return']]) ? $token[$options['return']] : $token;
		}
		return $results;
	}
public static function match($code, $parameters, array $options = []) {
		$defaults = ['ignore' => ['T_WHITESPACE'], 'return' => true];
		$options += $defaults;
		$parameters = static::_prepareMatchParams($parameters);

		$tokens = is_array($code) ? $code : static::tokenize($code, $options);
		$results = [];

		foreach ($tokens as $i => $token) {
			if (!array_key_exists($token['name'], $parameters)) {
				if (!in_array('*', $parameters)) {
					continue;
				}
			}
			$param = $parameters[$token['name']];

			if (isset($param['before']) && $i > 0) {
				if (!in_array($tokens[$i - 1]['name'], (array) $param['before'])) {
					continue;
				}
			}

			if (isset($param['after']) && $i + 1 < count($tokens)) {
				 if (!in_array($tokens[$i + 1]['name'], (array) $param['after'])) {
					continue;
				}
			}
			$results[] = isset($token[$options['return']]) ? $token[$options['return']] : $token;
		}
		return $results;
	}
public static function match ( $ code , $ parameters , array $ options = [ ] ) { $ defaults = [ 'ignore' => [ 'T_WHITESPACE' ] , 'return' => true ] ; $ options += $ defaults ; $ parameters = static :: _prepareMatchParams ( $ parameters ) ; $ tokens = is_array ( $ code ) ? $ code : static :: tokenize ( $ code , $ options ) ; $ results = [ ] ; foreach ( $ tokens as $ i => $ token ) { if ( ! array_key_exists ( $ token [ 'name' ] , $ parameters ) ) { if ( ! in_array ( '*' , $ parameters ) ) { continue ; } } $ param = $ parameters [ $ token [ 'name' ] ] ; if ( isset ( $ param [ 'before' ] ) && $ i > 0 ) { if ( ! in_array ( $ tokens [ $ i - 1 ] [ 'name' ] , ( array ) $ param [ 'before' ] ) ) { continue ; } } if ( isset ( $ param [ 'after' ] ) && $ i + 1 < count ( $ tokens ) ) { if ( ! in_array ( $ tokens [ $ i + 1 ] [ 'name' ] , ( array ) $ param [ 'after' ] ) ) { continue ; } } $ results [ ] = isset ( $ token [ $ options [ 'return' ] ] ) ? $ token [ $ options [ 'return' ] ] : $ token ; } return $ results ; }
Token pattern matching.

@param string $code Source code to be analyzed.
@param string $parameters An array containing token patterns to be matched.
@param array $options 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.
Token pattern matching .