public static function match(Token $token, array $pattern)
    {
        // Token.
        if (isset($pattern['token'])
            && ($pattern['token'] !== $token->token)
        ) {
            return false;
        }

        // Value.
        if (isset($pattern['value'])
            && ($pattern['value'] !== $token->value)
        ) {
            return false;
        }

        if (isset($pattern['value_str'])
            && strcasecmp($pattern['value_str'], (string) $token->value)
        ) {
            return false;
        }

        // Type.
        if (isset($pattern['type'])
            && ($pattern['type'] !== $token->type)
        ) {
            return false;
        }

        // Flags.
        if (isset($pattern['flags'])
            && (($pattern['flags'] & $token->flags) === 0)
        ) {
            return false;
        }

        return true;
    }
public static function match(Token $token, array $pattern)
    {
        // Token.
        if (isset($pattern['token'])
            && ($pattern['token'] !== $token->token)
        ) {
            return false;
        }

        // Value.
        if (isset($pattern['value'])
            && ($pattern['value'] !== $token->value)
        ) {
            return false;
        }

        if (isset($pattern['value_str'])
            && strcasecmp($pattern['value_str'], (string) $token->value)
        ) {
            return false;
        }

        // Type.
        if (isset($pattern['type'])
            && ($pattern['type'] !== $token->type)
        ) {
            return false;
        }

        // Flags.
        if (isset($pattern['flags'])
            && (($pattern['flags'] & $token->flags) === 0)
        ) {
            return false;
        }

        return true;
    }
public static function match ( Token $ token , array $ pattern ) { // Token. if ( isset ( $ pattern [ 'token' ] ) && ( $ pattern [ 'token' ] !== $ token -> token ) ) { return false ; } // Value. if ( isset ( $ pattern [ 'value' ] ) && ( $ pattern [ 'value' ] !== $ token -> value ) ) { return false ; } if ( isset ( $ pattern [ 'value_str' ] ) && strcasecmp ( $ pattern [ 'value_str' ] , ( string ) $ token -> value ) ) { return false ; } // Type. if ( isset ( $ pattern [ 'type' ] ) && ( $ pattern [ 'type' ] !== $ token -> type ) ) { return false ; } // Flags. if ( isset ( $ pattern [ 'flags' ] ) && ( ( $ pattern [ 'flags' ] & $ token -> flags ) === 0 ) ) { return false ; } return true ; }
Checks if a pattern is a match for the specified token.

@param Token $token   the token to be matched
@param array $pattern the pattern to be matches

@return bool
Checks if a pattern is a match for the specified token .