PHP Class SqlParser\Utils\Formatter

Mostra file Open project: phpmyadmin/sql-parser Class Usage Examples

Public Properties

Property Type Description
$INLINE_CLAUSES array These clauses usually are short and it's nicer to have them inline.
$options array The formatting options.

Public Methods

Method Description
__construct ( array $options = [] ) Constructor.
escapeConsole ( $string )
format ( string $query, array $options = [] ) : string Formats a query.
formatList ( TokensList $list ) : string Formats the given list of tokens.
getGroupLength ( TokensList $list ) : integer Computes the length of a group.
isClause ( Token $token ) : integer | boolean Checks if a token is a statement or a clause inside a statement.
toString ( Token $token ) : string Tries to print the query and returns the result.

Method Details

__construct() public method

Constructor.
public __construct ( array $options = [] )
$options array The formatting options.

escapeConsole() public method

public escapeConsole ( $string )

format() public static method

Formats a query.
public static format ( string $query, array $options = [] ) : string
$query string The query to be formatted
$options array The formatting options.
return string The formatted string.

formatList() public method

Formats the given list of tokens.
public formatList ( TokensList $list ) : string
$list SqlParser\TokensList The list of tokens.
return string

getGroupLength() public static method

A group is delimited by a pair of brackets.
public static getGroupLength ( TokensList $list ) : integer
$list SqlParser\TokensList The list of tokens.
return integer

isClause() public static method

Checks if a token is a statement or a clause inside a statement.
public static isClause ( Token $token ) : integer | boolean
$token SqlParser\Token The token to be checked.
return integer | boolean

toString() public method

Tries to print the query and returns the result.
public toString ( Token $token ) : string
$token SqlParser\Token The token to be printed.
return string

Property Details

$INLINE_CLAUSES public_oe static_oe property

These clauses usually are short and it's nicer to have them inline.
public static array $INLINE_CLAUSES
return array

$options public_oe property

The formatting options.
public array $options
return array