@@ -31,6 +31,9 @@ final class SqlFormatter
3131 private readonly Highlighter $ highlighter ;
3232 private readonly Tokenizer $ tokenizer ;
3333
34+ private const INDENT_TYPE_BLOCK = 'block ' ;
35+ private const INDENT_TYPE_SPECIAL = 'special ' ;
36+
3437 public function __construct (Highlighter |null $ highlighter = null )
3538 {
3639 $ this ->tokenizer = new Tokenizer ();
@@ -77,14 +80,14 @@ public function format(string $string, string $indentString = ' '): string
7780 if ($ increaseSpecialIndent ) {
7881 $ indentLevel ++;
7982 $ increaseSpecialIndent = false ;
80- array_unshift ($ indentTypes , ' special ' );
83+ array_unshift ($ indentTypes , self :: INDENT_TYPE_SPECIAL );
8184 }
8285
8386 // If we are increasing the block indent level now
8487 if ($ increaseBlockIndent ) {
8588 $ indentLevel ++;
8689 $ increaseBlockIndent = false ;
87- array_unshift ($ indentTypes , ' block ' );
90+ array_unshift ($ indentTypes , self :: INDENT_TYPE_BLOCK );
8891 }
8992
9093 // If we need a new line before the token
@@ -207,7 +210,7 @@ public function format(string $string, string $indentString = ' '): string
207210
208211 // Reset indent level
209212 while ($ j = array_shift ($ indentTypes )) {
210- if ($ j !== ' special ' ) {
213+ if ($ j !== self :: INDENT_TYPE_SPECIAL ) {
211214 break ;
212215 }
213216
@@ -230,9 +233,9 @@ public function format(string $string, string $indentString = ' '): string
230233 // Top level reserved words start a new line and increase the special indent level
231234 $ increaseSpecialIndent = true ;
232235
233- // If the last indent type was 'special' , decrease the special indent for this round
236+ // If the last indent type was self::INDENT_TYPE_SPECIAL , decrease the special indent for this round
234237 reset ($ indentTypes );
235- if (current ($ indentTypes ) === ' special ' ) {
238+ if (current ($ indentTypes ) === self :: INDENT_TYPE_SPECIAL ) {
236239 $ indentLevel --;
237240 array_shift ($ indentTypes );
238241 }
@@ -341,7 +344,7 @@ public function format(string $string, string $indentString = ' '): string
341344 }
342345
343346 // If there are unmatched parentheses
344- if (array_search (' block ' , $ indentTypes ) !== false ) {
347+ if (array_search (self :: INDENT_TYPE_BLOCK , $ indentTypes ) !== false ) {
345348 $ return = rtrim ($ return , ' ' );
346349 $ return .= $ this ->highlighter ->highlightErrorMessage (
347350 'WARNING: unclosed parentheses or section ' ,
0 commit comments