@@ -83,64 +83,64 @@ protected function __construct(protected FormattingOptions $options = new Format
8383 * The styles used for HTML formatting.
8484 * [$type, $flags, $span, $callback].
8585 *
86- * @return list<array{type: int , flags: int, html: string, cli: string, function: callable|''}>
86+ * @return list<array{type: TokenType , flags: int, html: string, cli: string, function: callable|''}>
8787 */
8888 protected function getDefaultFormats (): array
8989 {
9090 return [
9191 [
92- 'type ' => TokenType::Keyword-> value ,
92+ 'type ' => TokenType::Keyword,
9393 'flags ' => Token::FLAG_KEYWORD_RESERVED ,
94- 'html ' => 'class=" sql-reserved" ' ,
94+ 'html ' => 'sql-reserved ' ,
9595 'cli ' => "\x1b[35m " ,
9696 'function ' => strtoupper (...),
9797 ],
9898 [
99- 'type ' => TokenType::Keyword-> value ,
99+ 'type ' => TokenType::Keyword,
100100 'flags ' => 0 ,
101- 'html ' => 'class=" sql-keyword" ' ,
101+ 'html ' => 'sql-keyword ' ,
102102 'cli ' => "\x1b[95m " ,
103103 'function ' => strtoupper (...),
104104 ],
105105 [
106- 'type ' => TokenType::Comment-> value ,
106+ 'type ' => TokenType::Comment,
107107 'flags ' => 0 ,
108- 'html ' => 'class=" sql-comment" ' ,
108+ 'html ' => 'sql-comment ' ,
109109 'cli ' => "\x1b[37m " ,
110110 'function ' => '' ,
111111 ],
112112 [
113- 'type ' => TokenType::Bool-> value ,
113+ 'type ' => TokenType::Bool,
114114 'flags ' => 0 ,
115- 'html ' => 'class=" sql-atom" ' ,
115+ 'html ' => 'sql-atom ' ,
116116 'cli ' => "\x1b[36m " ,
117117 'function ' => strtoupper (...),
118118 ],
119119 [
120- 'type ' => TokenType::Number-> value ,
120+ 'type ' => TokenType::Number,
121121 'flags ' => 0 ,
122- 'html ' => 'class=" sql-number" ' ,
122+ 'html ' => 'sql-number ' ,
123123 'cli ' => "\x1b[92m " ,
124124 'function ' => strtolower (...),
125125 ],
126126 [
127- 'type ' => TokenType::String-> value ,
127+ 'type ' => TokenType::String,
128128 'flags ' => 0 ,
129- 'html ' => 'class=" sql-string" ' ,
129+ 'html ' => 'sql-string ' ,
130130 'cli ' => "\x1b[91m " ,
131131 'function ' => '' ,
132132 ],
133133 [
134- 'type ' => TokenType::Symbol-> value ,
134+ 'type ' => TokenType::Symbol,
135135 'flags ' => Token::FLAG_SYMBOL_PARAMETER ,
136- 'html ' => 'class=" sql-parameter" ' ,
136+ 'html ' => 'sql-parameter ' ,
137137 'cli ' => "\x1b[31m " ,
138138 'function ' => '' ,
139139 ],
140140 [
141- 'type ' => TokenType::Symbol-> value ,
141+ 'type ' => TokenType::Symbol,
142142 'flags ' => 0 ,
143- 'html ' => 'class=" sql-variable" ' ,
143+ 'html ' => 'sql-variable ' ,
144144 'cli ' => "\x1b[36m " ,
145145 'function ' => '' ,
146146 ],
@@ -454,21 +454,16 @@ public function toString(Token $token): string
454454 static $ prev ;
455455
456456 foreach ($ this ->getDefaultFormats () as $ format ) {
457- if (
458- $ token ->type ->value !== $ format ['type ' ] || ! (($ token ->flags & $ format ['flags ' ]) === $ format ['flags ' ])
459- ) {
457+ if ($ token ->type !== $ format ['type ' ] || ! (($ token ->flags & $ format ['flags ' ]) === $ format ['flags ' ])) {
460458 continue ;
461459 }
462460
463- // Running transformation function.
464461 if ($ format ['function ' ] !== '' ) {
465- $ func = $ format ['function ' ];
466- $ text = $ func ($ text );
462+ $ text = $ format ['function ' ]($ text );
467463 }
468464
469- // Formatting HTML.
470465 if ($ this ->options ->type === 'html ' ) {
471- return '<span ' . $ format ['html ' ] . '> ' . htmlspecialchars ($ text , ENT_NOQUOTES ) . '</span> ' ;
466+ return '<span class=" ' . $ format ['html ' ] . '" > ' . htmlspecialchars ($ text , ENT_NOQUOTES ) . '</span> ' ;
472467 }
473468
474469 if ($ this ->options ->type === 'cli ' ) {
0 commit comments