Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uppercasing reserved words #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/SqlFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ class SqlFormatter
// This flag tells us if queries need to be enclosed in <pre> tags
public static $use_pre = true;

// This flag determines if keywords should be uppercased
public static $uppercase = false;

// This flag tells us if SqlFormatted has been initialized
protected static $init;

Expand Down Expand Up @@ -684,6 +687,13 @@ public static function format($string, $highlight=true)
}
}

// Uppercase reserved words
if(self::$uppercase && in_array($token[self::TOKEN_TYPE],array(self::TOKEN_TYPE_RESERVED,self::TOKEN_TYPE_RESERVED_NEWLINE,self::TOKEN_TYPE_RESERVED_TOPLEVEL))){
$highlighted = strtoupper($highlighted);
}



// If the token shouldn't have a space before it
if ($token[self::TOKEN_VALUE] === '.' || $token[self::TOKEN_VALUE] === ',' || $token[self::TOKEN_VALUE] === ';') {
$return = rtrim($return, ' ');
Expand Down