@@ -43,7 +43,7 @@ |
||
43 | 43 | $this->assertEquals([ |
44 | 44 | TokenType::Keyword->value | Token::FLAG_KEYWORD_RESERVED => [ |
45 | 45 | 8 => ['RESERVED'], |
46 | - 9 => ['RESERVED2','RESERVED3','RESERVED4','RESERVED5'], |
|
46 | + 9 => ['RESERVED2', 'RESERVED3', 'RESERVED4', 'RESERVED5'], |
|
47 | 47 | ], |
48 | 48 | TokenType::Keyword->value | Token::FLAG_KEYWORD_FUNCTION => [8 => ['FUNCTION']], |
49 | 49 | TokenType::Keyword->value | Token::FLAG_KEYWORD_DATA_TYPE => [8 => ['DATATYPE']], |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | switch ($this->type) { |
129 | 129 | case TokenType::Keyword: |
130 | 130 | $this->keyword = strtoupper($this->token); |
131 | - if (! ($this->flags & self::FLAG_KEYWORD_RESERVED)) { |
|
131 | + if (!($this->flags & self::FLAG_KEYWORD_RESERVED)) { |
|
132 | 132 | // Unreserved keywords should stay the way they are because they |
133 | 133 | // might represent field names. |
134 | 134 | return $this->token; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | } |
154 | 154 | } elseif (($this->flags & self::FLAG_NUMBER_APPROXIMATE) || ($this->flags & self::FLAG_NUMBER_FLOAT)) { |
155 | 155 | $ret = (float) $ret; |
156 | - } elseif (! ($this->flags & self::FLAG_NUMBER_BINARY)) { |
|
156 | + } elseif (!($this->flags & self::FLAG_NUMBER_BINARY)) { |
|
157 | 157 | $ret = (int) $ret; |
158 | 158 | } |
159 | 159 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | // in PHP 5.3- the `null` parameter isn't handled correctly. |
189 | 189 | $str = mb_substr( |
190 | 190 | $str, |
191 | - ! empty($str[1]) && ($str[1] === '@') ? 2 : 1, |
|
191 | + !empty($str[1]) && ($str[1] === '@') ? 2 : 1, |
|
192 | 192 | mb_strlen($str), |
193 | 193 | 'UTF-8' |
194 | 194 | ); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | ) { |
89 | 89 | $expr->type = $token->keyword; |
90 | 90 | } elseif (($token->type === TokenType::Operator) && ($token->value === ',')) { |
91 | - if (! empty($expr->expr)) { |
|
91 | + if (!empty($expr->expr)) { |
|
92 | 92 | $ret[] = $expr; |
93 | 93 | } |
94 | 94 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | // Last iteration was not processed. |
104 | - if (! empty($expr->expr)) { |
|
104 | + if (!empty($expr->expr)) { |
|
105 | 105 | $ret[] = $expr; |
106 | 106 | } |
107 | 107 |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } else { |
152 | 152 | // The expression ended. |
153 | 153 | $expr->expr = trim($expr->expr); |
154 | - if (! empty($expr->expr)) { |
|
154 | + if (!empty($expr->expr)) { |
|
155 | 155 | $ret[] = $expr; |
156 | 156 | } |
157 | 157 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | if ( |
170 | 170 | ($token->type === TokenType::Keyword) |
171 | 171 | && ($token->flags & Token::FLAG_KEYWORD_RESERVED) |
172 | - && ! ($token->flags & Token::FLAG_KEYWORD_FUNCTION) |
|
172 | + && !($token->flags & Token::FLAG_KEYWORD_FUNCTION) |
|
173 | 173 | ) { |
174 | 174 | if ($token->value === 'BETWEEN') { |
175 | 175 | $betweenBefore = true; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | |
213 | 213 | // Last iteration was not processed. |
214 | 214 | $expr->expr = trim($expr->expr); |
215 | - if (! empty($expr->expr)) { |
|
215 | + if (!empty($expr->expr)) { |
|
216 | 216 | $ret[] = $expr; |
217 | 217 | } |
218 | 218 |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @param TokensList $list the list of tokens that are being parsed |
96 | 96 | * @param array<string, mixed> $options parameters for parsing |
97 | 97 | */ |
98 | - public static function parse(Parser $parser, TokensList $list, array $options = []): DataType|null |
|
98 | + public static function parse(Parser $parser, TokensList $list, array $options = []): DataType | null |
|
99 | 99 | { |
100 | 100 | $ret = new static(); |
101 | 101 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | if ($state === 0) { |
127 | 127 | $ret->name = strtoupper((string) $token->value); |
128 | - if (($token->type !== TokenType::Keyword) || (! ($token->flags & Token::FLAG_KEYWORD_DATA_TYPE))) { |
|
128 | + if (($token->type !== TokenType::Keyword) || (!($token->flags & Token::FLAG_KEYWORD_DATA_TYPE))) { |
|
129 | 129 | $parser->error('Unrecognized data type.', $token); |
130 | 130 | } |
131 | 131 |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | |
200 | 200 | // Handle optional AS keyword before alias |
201 | 201 | if ($token->type === TokenType::Keyword && $token->keyword === 'AS') { |
202 | - if ($asFound || ! empty($ret->alias)) { |
|
202 | + if ($asFound || !empty($ret->alias)) { |
|
203 | 203 | $parser->error('Potential duplicate alias of CASE expression.', $token); |
204 | 204 | break; |
205 | 205 | } |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | if ( |
222 | 222 | $asFound |
223 | 223 | || $token->type === TokenType::String |
224 | - || ($token->type === TokenType::Symbol && ! $token->flags & Token::FLAG_SYMBOL_VARIABLE) |
|
224 | + || ($token->type === TokenType::Symbol && !$token->flags & Token::FLAG_SYMBOL_VARIABLE) |
|
225 | 225 | || $token->type === TokenType::None |
226 | 226 | ) { |
227 | 227 | // An alias is expected (the keyword `AS` was previously found). |
228 | - if (! empty($ret->alias)) { |
|
228 | + if (!empty($ret->alias)) { |
|
229 | 229 | $parser->error('An alias was previously found.', $token); |
230 | 230 | break; |
231 | 231 | } |
@@ -87,7 +87,7 @@ |
||
87 | 87 | if ($token->type === TokenType::Operator && $token->value === '(') { |
88 | 88 | --$list->idx; // ArrayObj needs to start with `(` |
89 | 89 | $state = 1; |
90 | - continue;// do not add this token to the name |
|
90 | + continue; // do not add this token to the name |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | $ret->name .= $token->value; |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $state = 4; |
244 | 244 | } elseif ($token->type === TokenType::Symbol || $token->type === TokenType::None) { |
245 | 245 | $expr->name = $token->value; |
246 | - if (! $expr->isConstraint) { |
|
246 | + if (!$expr->isConstraint) { |
|
247 | 247 | $state = 2; |
248 | 248 | } |
249 | 249 | } elseif ($token->type === TokenType::Keyword) { |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | |
285 | 285 | $state = 5; |
286 | 286 | } elseif ($state === 5) { |
287 | - if (! empty($expr->type) || ! empty($expr->key)) { |
|
287 | + if (!empty($expr->type) || !empty($expr->key)) { |
|
288 | 288 | $ret[] = $expr; |
289 | 289 | } |
290 | 290 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | } |
305 | 305 | |
306 | 306 | // Last iteration was not saved. |
307 | - if (! empty($expr->type) || ! empty($expr->key)) { |
|
307 | + if (!empty($expr->type) || !empty($expr->key)) { |
|
308 | 308 | $ret[] = $expr; |
309 | 309 | } |
310 | 310 | |
@@ -332,16 +332,16 @@ discard block |
||
332 | 332 | $tmp .= Context::escape($component->name) . ' '; |
333 | 333 | } |
334 | 334 | |
335 | - if (! empty($component->type)) { |
|
335 | + if (!empty($component->type)) { |
|
336 | 336 | $component->type->lowercase = true; |
337 | 337 | $tmp .= DataType::build($component->type) . ' '; |
338 | 338 | } |
339 | 339 | |
340 | - if (! empty($component->key)) { |
|
340 | + if (!empty($component->key)) { |
|
341 | 341 | $tmp .= $component->key . ' '; |
342 | 342 | } |
343 | 343 | |
344 | - if (! empty($component->references)) { |
|
344 | + if (!empty($component->references)) { |
|
345 | 345 | $tmp .= 'REFERENCES ' . $component->references . ' '; |
346 | 346 | } |
347 | 347 |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @throws ParserException |
159 | 159 | */ |
160 | - public static function parse(Parser $parser, TokensList $list, array $options = []): Expression|null |
|
160 | + public static function parse(Parser $parser, TokensList $list, array $options = []): Expression | null |
|
161 | 161 | { |
162 | 162 | $ret = new static(); |
163 | 163 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | ]; |
201 | 201 | |
202 | 202 | // When a field is parsed, no parentheses are expected. |
203 | - if (! empty($options['parseField'])) { |
|
203 | + if (!empty($options['parseField'])) { |
|
204 | 204 | $options['breakOnParentheses'] = true; |
205 | 205 | $options['field'] = $options['parseField']; |
206 | 206 | } |
@@ -227,14 +227,14 @@ discard block |
||
227 | 227 | } |
228 | 228 | |
229 | 229 | if ($token->type === TokenType::Keyword) { |
230 | - if (($brackets > 0) && empty($ret->subquery) && ! empty(Parser::$statementParsers[$token->keyword])) { |
|
230 | + if (($brackets > 0) && empty($ret->subquery) && !empty(Parser::$statementParsers[$token->keyword])) { |
|
231 | 231 | // A `(` was previously found and this keyword is the |
232 | 232 | // beginning of a statement, so this is a subquery. |
233 | 233 | $ret->subquery = $token->keyword; |
234 | 234 | } elseif ( |
235 | 235 | ($token->flags & Token::FLAG_KEYWORD_FUNCTION) |
236 | 236 | && (empty($options['parseField']) |
237 | - && ! $alias) |
|
237 | + && !$alias) |
|
238 | 238 | ) { |
239 | 239 | $isExpr = true; |
240 | 240 | } elseif (($token->flags & Token::FLAG_KEYWORD_RESERVED) && ($brackets === 0)) { |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | } |
247 | 247 | |
248 | 248 | if ($token->keyword === 'AS') { |
249 | - if (! empty($options['breakOnAlias'])) { |
|
249 | + if (!empty($options['breakOnAlias'])) { |
|
250 | 250 | break; |
251 | 251 | } |
252 | 252 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | } |
270 | 270 | |
271 | 271 | $isExpr = true; |
272 | - } elseif ($brackets === 0 && strlen((string) $ret->expr) > 0 && ! $alias) { |
|
272 | + } elseif ($brackets === 0 && strlen((string) $ret->expr) > 0 && !$alias) { |
|
273 | 273 | /* End of expression */ |
274 | 274 | break; |
275 | 275 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | || (($token->type === TokenType::Operator) |
286 | 286 | && ($token->value !== '.')) |
287 | 287 | ) { |
288 | - if (! empty($options['parseField'])) { |
|
288 | + if (!empty($options['parseField'])) { |
|
289 | 289 | break; |
290 | 290 | } |
291 | 291 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | } |
296 | 296 | |
297 | 297 | if ($token->type === TokenType::Operator) { |
298 | - if (! empty($options['breakOnParentheses']) && (($token->value === '(') || ($token->value === ')'))) { |
|
298 | + if (!empty($options['breakOnParentheses']) && (($token->value === '(') || ($token->value === ')'))) { |
|
299 | 299 | // No brackets were expected. |
300 | 300 | break; |
301 | 301 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | |
320 | 320 | --$brackets; |
321 | 321 | if ($brackets === 0) { |
322 | - if (! empty($options['parenthesesDelimited'])) { |
|
322 | + if (!empty($options['parenthesesDelimited'])) { |
|
323 | 323 | // The current token is the last bracket, the next |
324 | 324 | // one will be outside the expression. |
325 | 325 | $ret->expr .= $token->token; |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | |
346 | 346 | if ($alias) { |
347 | 347 | // An alias is expected (the keyword `AS` was previously found). |
348 | - if (! empty($ret->alias)) { |
|
348 | + if (!empty($ret->alias)) { |
|
349 | 349 | $parser->error('An alias was previously found.', $token); |
350 | 350 | break; |
351 | 351 | } |
@@ -359,14 +359,14 @@ discard block |
||
359 | 359 | && ($prev[0] === null |
360 | 360 | || (($prev[0]->type !== TokenType::Operator || $prev[0]->token === ')') |
361 | 361 | && ($prev[0]->type !== TokenType::Keyword |
362 | - || ! ($prev[0]->flags & Token::FLAG_KEYWORD_RESERVED)))) |
|
362 | + || !($prev[0]->flags & Token::FLAG_KEYWORD_RESERVED)))) |
|
363 | 363 | && (($prev[1]->type === TokenType::String) |
364 | 364 | || ($prev[1]->type === TokenType::Symbol |
365 | - && ! ($prev[1]->flags & Token::FLAG_SYMBOL_VARIABLE)) |
|
365 | + && !($prev[1]->flags & Token::FLAG_SYMBOL_VARIABLE)) |
|
366 | 366 | || ($prev[1]->type === TokenType::None |
367 | 367 | && $prev[1]->token !== 'OVER')) |
368 | 368 | ) { |
369 | - if (! empty($ret->alias)) { |
|
369 | + if (!empty($ret->alias)) { |
|
370 | 370 | $parser->error('An alias was previously found.', $token); |
371 | 371 | break; |
372 | 372 | } |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | // Found a `.` which means we expect a column name and |
398 | 398 | // the column name we parsed is actually the table name |
399 | 399 | // and the table name is actually a database name. |
400 | - if (! empty($ret->database) || $dot) { |
|
400 | + if (!empty($ret->database) || $dot) { |
|
401 | 401 | $parser->error('Unexpected dot.', $token); |
402 | 402 | } |
403 | 403 | |
@@ -414,11 +414,11 @@ discard block |
||
414 | 414 | $dot = false; |
415 | 415 | } else { |
416 | 416 | // No alias is expected. |
417 | - if (! empty($options['breakOnAlias'])) { |
|
417 | + if (!empty($options['breakOnAlias'])) { |
|
418 | 418 | break; |
419 | 419 | } |
420 | 420 | |
421 | - if (! empty($ret->alias)) { |
|
421 | + if (!empty($ret->alias)) { |
|
422 | 422 | $parser->error('An alias was previously found.', $token); |
423 | 423 | break; |
424 | 424 | } |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | $ret = implode('.', Context::escapeAll($fields)); |
470 | 470 | } |
471 | 471 | |
472 | - if (! empty($component->alias)) { |
|
472 | + if (!empty($component->alias)) { |
|
473 | 473 | $ret .= ' AS ' . Context::escape($component->alias); |
474 | 474 | } |
475 | 475 |