summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Andersson <erik.andersson@2bra.se>2019-03-13 14:35:00 +0100
committerErik Andersson <erik.andersson@2bra.se>2019-03-13 14:35:00 +0100
commitccd2687b1a9f4b319d5d453615a73a996cce5129 (patch)
treec2a00fc6a0a329a3b278ede699059b4fd4945f46
parentdf24e356c204cd4f9c11572b1ac8babc0afc30e1 (diff)
downloadsql-formatter-master.zip
sql-formatter-master.tar.gz
sql-formatter-master.tar.bz2
Uppercasing reserved words #86HEADmaster
-rw-r--r--lib/SqlFormatter.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/SqlFormatter.php b/lib/SqlFormatter.php
index 5e4b8a4..6696961 100644
--- a/lib/SqlFormatter.php
+++ b/lib/SqlFormatter.php
@@ -139,6 +139,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 = true;
// This flag tells us if SqlFormatted has been initialized
protected static $init;
@@ -684,6 +687,11 @@ class SqlFormatter
}
}
+ // 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, ' ');