diff options
author | Jeremy Dorn <jeremy@jeremydorn.com> | 2013-09-02 10:19:28 -0700 |
---|---|---|
committer | Jeremy Dorn <jeremy@jeremydorn.com> | 2013-09-02 10:19:28 -0700 |
commit | 7045fde3163d5a4ea6ec32e409a7dcf00779e204 (patch) | |
tree | adc2e046f5032401603a2de39a6c0a954e751975 | |
parent | f258a98eb42c5566da277acf8e97c1e918e04771 (diff) | |
download | sql-formatter-7045fde3163d5a4ea6ec32e409a7dcf00779e204.zip sql-formatter-7045fde3163d5a4ea6ec32e409a7dcf00779e204.tar.gz sql-formatter-7045fde3163d5a4ea6ec32e409a7dcf00779e204.tar.bz2 |
A few PSR code fixes.
-rw-r--r-- | lib/SqlFormatter.php | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/SqlFormatter.php b/lib/SqlFormatter.php index 9b07e33..2a021ff 100644 --- a/lib/SqlFormatter.php +++ b/lib/SqlFormatter.php @@ -238,15 +238,15 @@ class SqlFormatter self::TOKEN_TYPE => ($string[0]==='`'? self::TOKEN_TYPE_BACKTICK_QUOTE : self::TOKEN_TYPE_QUOTE), self::TOKEN_VALUE => self::getQuotedString($string) ); - + // If a quote was opened, but doesn't have a closing quote, return the remaining string if ($return[self::TOKEN_VALUE] === null) { $return[self::TOKEN_VALUE] = $string; } - + return $return; } - + // User-defined Variable if ($string[0] === '@' && isset($string[1])) { // If the variable name is quoted @@ -331,7 +331,8 @@ class SqlFormatter ); } - protected static function getQuotedString($string) { + protected static function getQuotedString($string) + { // This checks for the following patterns: // 1. backtick quoted string using `` to escape // 2. double quoted string using "" or \" to escape @@ -339,6 +340,7 @@ class SqlFormatter if ( preg_match('/^(((`[^`]*($|`))+)|(("[^"\\\\]*(?:\\\\.[^"\\\\]*)*("|$))+)|((\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*(\'|$))+))/s', $string, $matches)) { return $matches[1]; } + return null; } @@ -993,7 +995,7 @@ class SqlFormatter return '<span ' . self::$word_attributes . '>' . $value . '</span>'; } } - + /** * Highlights a variable token * |