@@ -57,7 +57,7 @@ class CaseExpression extends Component
57
57
public $ else_result ;
58
58
59
59
/**
60
- * The alias of this CASE statement
60
+ * The alias of this CASE statement.
61
61
*
62
62
* @var string
63
63
*/
@@ -78,8 +78,8 @@ public function __construct()
78
78
}
79
79
80
80
/**
81
- * @param Parser $parser the parser that serves as context
82
- * @param TokensList $list the list of tokens that are being parsed
81
+ * @param Parser $parser the parser that serves as context
82
+ * @param TokensList $list the list of tokens that are being parsed
83
83
* @param array $options parameters for parsing
84
84
*
85
85
* @return CaseExpression
@@ -209,7 +209,6 @@ public static function parse(Parser $parser, TokensList $list, array $options =
209
209
$ list ->tokens [$ list ->idx - 1 ]
210
210
);
211
211
} else {
212
-
213
212
// Parse for alias of CASE expression
214
213
$ asFound = false ;
215
214
for (; $ list ->idx < $ list ->count ; ++$ list ->idx ) {
@@ -219,6 +218,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
219
218
if ($ token ->type === Token::TYPE_DELIMITER ) {
220
219
break ;
221
220
}
221
+
222
222
// Skipping whitespaces and comments.
223
223
if (($ token ->type === Token::TYPE_WHITESPACE )
224
224
|| ($ token ->type === Token::TYPE_COMMENT )
@@ -227,9 +227,8 @@ public static function parse(Parser $parser, TokensList $list, array $options =
227
227
}
228
228
229
229
// Handle optional AS keyword before alias
230
- if ($ token ->type === Token::TYPE_KEYWORD
231
- && $ token ->keyword === 'AS ' ){
232
-
230
+ if ($ token ->type === Token::TYPE_KEYWORD
231
+ && $ token ->keyword === 'AS ' ) {
233
232
if ($ asFound || !empty ($ ret ->alias )) {
234
233
$ parser ->error ('Potential duplicate alias of CASE expression. ' , $ token );
235
234
break ;
@@ -240,8 +239,8 @@ public static function parse(Parser $parser, TokensList $list, array $options =
240
239
241
240
if ($ asFound
242
241
&& $ token ->type === Token::TYPE_KEYWORD
243
- && ($ token ->flags & Token::FLAG_KEYWORD_RESERVED || $ token ->flags & Token::FLAG_KEYWORD_FUNCTION )){
244
- $ parser ->error ('An alias expected after AS but got ' . $ token ->value , $ token );
242
+ && ($ token ->flags & Token::FLAG_KEYWORD_RESERVED || $ token ->flags & Token::FLAG_KEYWORD_FUNCTION )) {
243
+ $ parser ->error ('An alias expected after AS but got ' . $ token ->value , $ token );
245
244
$ asFound = false ;
246
245
break ;
247
246
}
@@ -250,8 +249,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
250
249
|| $ token ->type === Token::TYPE_STRING
251
250
|| ($ token ->type === Token::TYPE_SYMBOL && !$ token ->flags & Token::FLAG_SYMBOL_VARIABLE )
252
251
|| $ token ->type === Token::TYPE_NONE
253
- ){
254
-
252
+ ) {
255
253
// An alias is expected (the keyword `AS` was previously found).
256
254
if (!empty ($ ret ->alias )) {
257
255
$ parser ->error ('An alias was previously found. ' , $ token );
@@ -269,7 +267,6 @@ public static function parse(Parser $parser, TokensList $list, array $options =
269
267
$ parser ->error ('An alias was expected after AS. ' , $ list ->tokens [$ list ->idx - 1 ]);
270
268
}
271
269
272
-
273
270
$ ret ->expr = self ::build ($ ret );
274
271
}
275
272
0 commit comments