lithium\analysis\Parser::matchToken()

public static method

Compares two PHP language tokens.

Parameters

  • array $pattern

    Pattern token.

  • array $token

    Token to be compared.

Returns

boolean

Match result.

Source

	public static function matchToken($pattern, $token) {
		if ($pattern['name'] !== $token['name']) {
			return false;
		}

		if (!isset($pattern['content'])) {
			return true;
		}

		$match = $pattern['content'];
		$content = $token['content'];

		if ($pattern['name'] === 'T_VARIABLE') {
			$match = substr($match, 1);
			$content = substr($content, 1);
		}

		switch (true) {
			case ($match === '_' || $match === $content):
				return true;
		}
		return false;
	}