@@ -49,7 +49,7 @@ |
||
49 | 49 | * |
50 | 50 | * @return ArrayObj|Component[] |
51 | 51 | */ |
52 | - public static function parse(Parser $parser, TokensList $list, array $options = []): ArrayObj|array |
|
52 | + public static function parse(Parser $parser, TokensList $list, array $options = []): ArrayObj | array |
|
53 | 53 | { |
54 | 54 | $ret = empty($options['type']) ? new static() : []; |
55 | 55 |
@@ -47,7 +47,7 @@ |
||
47 | 47 | |
48 | 48 | public function build(): string |
49 | 49 | { |
50 | - if (! isset($this->statement)) { |
|
50 | + if (!isset($this->statement)) { |
|
51 | 51 | throw new RuntimeException('No statement inside WITH'); |
52 | 52 | } |
53 | 53 |
@@ -261,7 +261,7 @@ |
||
261 | 261 | public function build(): string |
262 | 262 | { |
263 | 263 | if ($this->dest instanceof Expression) { |
264 | - $columns = ! empty($this->columns) ? '(`' . implode('`, `', $this->columns) . '`)' : ''; |
|
264 | + $columns = !empty($this->columns) ? '(`' . implode('`, `', $this->columns) . '`)' : ''; |
|
265 | 265 | |
266 | 266 | return $this->dest . $columns; |
267 | 267 | } |
@@ -142,7 +142,7 @@ |
||
142 | 142 | public function build(): string |
143 | 143 | { |
144 | 144 | $tmp = ''; |
145 | - if (! empty($this->inOut)) { |
|
145 | + if (!empty($this->inOut)) { |
|
146 | 146 | $tmp .= $this->inOut . ' '; |
147 | 147 | } |
148 | 148 |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | if ($lastOption === null) { |
110 | 110 | $upper = strtoupper($token->token); |
111 | - if (! isset($options[$upper])) { |
|
111 | + if (!isset($options[$upper])) { |
|
112 | 112 | // There is no option to be processed. |
113 | 113 | break; |
114 | 114 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | } |
146 | 146 | |
147 | 147 | if ($state === 0) { |
148 | - if (! is_array($lastOption)) { |
|
148 | + if (!is_array($lastOption)) { |
|
149 | 149 | // This is a just keyword option without any value. |
150 | 150 | // This is the beginning and the end of it. |
151 | 151 | $ret->options[$lastOptionId] = $token->value; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $ret->options[$lastOptionId]['expr'] .= $token->token; |
223 | 223 | |
224 | 224 | if ( |
225 | - ! (($token->token === '(') && ($brackets === 1) |
|
225 | + !(($token->token === '(') && ($brackets === 1) |
|
226 | 226 | || (($token->token === ')') && ($brackets === 0))) |
227 | 227 | ) { |
228 | 228 | // First pair of brackets is being skipped. |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | |
275 | 275 | $options = []; |
276 | 276 | foreach ($this->options as $option) { |
277 | - if (! is_array($option)) { |
|
277 | + if (!is_array($option)) { |
|
278 | 278 | $options[] = $option; |
279 | 279 | } else { |
280 | 280 | $options[] = $option['name'] |
281 | - . (! empty($option['equals']) ? '=' : ' ') |
|
282 | - . (! empty($option['expr']) ? $option['expr'] : $option['value']); |
|
281 | + . (!empty($option['equals']) ? '=' : ' ') |
|
282 | + . (!empty($option['expr']) ? $option['expr'] : $option['value']); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | { |
300 | 300 | foreach ($this->options as $option) { |
301 | 301 | if (is_array($option)) { |
302 | - if (! strcasecmp($key, $option['name'])) { |
|
302 | + if (!strcasecmp($key, $option['name'])) { |
|
303 | 303 | return $getExpr ? $option['expr'] : $option['value']; |
304 | 304 | } |
305 | - } elseif (! strcasecmp($key, $option)) { |
|
305 | + } elseif (!strcasecmp($key, $option)) { |
|
306 | 306 | return true; |
307 | 307 | } |
308 | 308 | } |
@@ -321,12 +321,12 @@ discard block |
||
321 | 321 | { |
322 | 322 | foreach ($this->options as $idx => $option) { |
323 | 323 | if (is_array($option)) { |
324 | - if (! strcasecmp($key, $option['name'])) { |
|
324 | + if (!strcasecmp($key, $option['name'])) { |
|
325 | 325 | unset($this->options[$idx]); |
326 | 326 | |
327 | 327 | return true; |
328 | 328 | } |
329 | - } elseif (! strcasecmp($key, $option)) { |
|
329 | + } elseif (!strcasecmp($key, $option)) { |
|
330 | 330 | unset($this->options[$idx]); |
331 | 331 | |
332 | 332 | return true; |
@@ -233,7 +233,7 @@ |
||
233 | 233 | return trim( |
234 | 234 | 'PARTITION ' . $this->name |
235 | 235 | . (empty($this->type) ? '' : ' VALUES ' . $this->type . ' ' . $this->expr . ' ') |
236 | - . (! empty($this->options) && ! empty($this->type) ? '' : ' ') |
|
236 | + . (!empty($this->options) && !empty($this->type) ? '' : ' ') |
|
237 | 237 | . $this->options . $subpartitions |
238 | 238 | ); |
239 | 239 | } |
@@ -358,13 +358,13 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @param bool $isReserved checks if the keyword is reserved |
360 | 360 | */ |
361 | - public static function isKeyword(string $string, bool $isReserved = false): int|null |
|
361 | + public static function isKeyword(string $string, bool $isReserved = false): int | null |
|
362 | 362 | { |
363 | 363 | $upperString = strtoupper($string); |
364 | 364 | |
365 | 365 | if ( |
366 | - ! isset(static::$keywords[$upperString]) |
|
367 | - || ($isReserved && ! (static::$keywords[$upperString] & Token::FLAG_KEYWORD_RESERVED)) |
|
366 | + !isset(static::$keywords[$upperString]) |
|
367 | + || ($isReserved && !(static::$keywords[$upperString] & Token::FLAG_KEYWORD_RESERVED)) |
|
368 | 368 | ) { |
369 | 369 | return null; |
370 | 370 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | /** |
376 | 376 | * Checks if the given string is an operator and returns the appropriate flag for the operator. |
377 | 377 | */ |
378 | - public static function isOperator(string $string): int|null |
|
378 | + public static function isOperator(string $string): int | null |
|
379 | 379 | { |
380 | 380 | return static::$operators[$string] ?? null; |
381 | 381 | } |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * |
394 | 394 | * @return int|null the appropriate flag for the comment type |
395 | 395 | */ |
396 | - public static function isComment(string $string, bool $end = false): int|null |
|
396 | + public static function isComment(string $string, bool $end = false): int | null |
|
397 | 397 | { |
398 | 398 | if ($string === '') { |
399 | 399 | return null; |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | * |
457 | 457 | * @return int|null the appropriate flag for the symbol type |
458 | 458 | */ |
459 | - public static function isSymbol(string $string): int|null |
|
459 | + public static function isSymbol(string $string): int | null |
|
460 | 460 | { |
461 | 461 | if ($string === '') { |
462 | 462 | return null; |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | * |
485 | 485 | * @return int|null the appropriate flag for the string type |
486 | 486 | */ |
487 | - public static function isString(string $string): int|null |
|
487 | + public static function isString(string $string): int | null |
|
488 | 488 | { |
489 | 489 | if ($string === '') { |
490 | 490 | return null; |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | $context = self::$contextPrefix . $context; |
539 | 539 | } |
540 | 540 | |
541 | - if (! class_exists($context)) { |
|
541 | + if (!class_exists($context)) { |
|
542 | 542 | return false; |
543 | 543 | } |
544 | 544 | |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | * |
561 | 561 | * @return string|null The loaded context. `null` if no context was loaded. |
562 | 562 | */ |
563 | - public static function loadClosest(string $context = ''): string|null |
|
563 | + public static function loadClosest(string $context = ''): string | null |
|
564 | 564 | { |
565 | 565 | $length = strlen($context); |
566 | 566 | for ($i = $length; $i > 0;) { |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | $i -= 2; |
575 | 575 | $part = substr($context, $i, 2); |
576 | 576 | /* No more numeric parts to strip */ |
577 | - if (! is_numeric($part)) { |
|
577 | + if (!is_numeric($part)) { |
|
578 | 578 | break 2; |
579 | 579 | } |
580 | 580 | } while (intval($part) === 0 && $i > 0); |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | public static function escape(string $str, string $quote = '`'): string |
676 | 676 | { |
677 | 677 | if ( |
678 | - (static::$mode & self::SQL_MODE_NO_ENCLOSING_QUOTES) && ! ( |
|
678 | + (static::$mode & self::SQL_MODE_NO_ENCLOSING_QUOTES) && !( |
|
679 | 679 | static::isKeyword($str, true) || self::doesIdentifierRequireQuoting($str) |
680 | 680 | ) |
681 | 681 | ) { |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | * |
723 | 723 | * @return bool false on empty param, true/false on given constant/int value |
724 | 724 | */ |
725 | - public static function hasMode(int|null $flag = null): bool |
|
725 | + public static function hasMode(int | null $flag = null): bool |
|
726 | 726 | { |
727 | 727 | if (empty($flag)) { |
728 | 728 | return false; |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | $list->idx = $lastIdx; |
489 | 489 | } elseif (empty(self::STATEMENT_PARSERS[$token->keyword])) { |
490 | 490 | // Checking if it is a known statement that can be parsed. |
491 | - if (! isset(self::STATEMENT_PARSERS[$token->keyword])) { |
|
491 | + if (!isset(self::STATEMENT_PARSERS[$token->keyword])) { |
|
492 | 492 | // A statement is considered recognized if the parser |
493 | 493 | // is aware that it is a statement, but it does not have |
494 | 494 | // a parser for it yet. |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | |
529 | 529 | // Handles unions. |
530 | 530 | if ( |
531 | - ! empty($unionType) |
|
531 | + !empty($unionType) |
|
532 | 532 | && ($lastStatement instanceof SelectStatement) |
533 | 533 | && ($statement instanceof SelectStatement) |
534 | 534 | ) { |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | * |
616 | 616 | * @throws ParserException throws the exception, if strict mode is enabled. |
617 | 617 | */ |
618 | - public function error($msg, Token|null $token = null, $code = 0): void |
|
618 | + public function error($msg, Token | null $token = null, $code = 0): void |
|
619 | 619 | { |
620 | 620 | $error = new ParserException( |
621 | 621 | Translator::gettext($msg), |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param Parser|null $parser the instance that requests parsing |
89 | 89 | * @param TokensList|null $list the list of tokens to be parsed |
90 | 90 | */ |
91 | - public function __construct(Parser|null $parser = null, TokensList|null $list = null) |
|
91 | + public function __construct(Parser | null $parser = null, TokensList | null $list = null) |
|
92 | 92 | { |
93 | 93 | if (($parser === null) || ($list === null)) { |
94 | 94 | return; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | // Checking if this field was already built. |
167 | 167 | if ($type & 1) { |
168 | - if (! empty($built[$field])) { |
|
168 | + if (!empty($built[$field])) { |
|
169 | 169 | continue; |
170 | 170 | } |
171 | 171 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | } |
179 | 179 | |
180 | 180 | // Checking if the result of the builder should be added. |
181 | - if (! ($type & 1)) { |
|
181 | + if (!($type & 1)) { |
|
182 | 182 | continue; |
183 | 183 | } |
184 | 184 | |
@@ -304,8 +304,8 @@ discard block |
||
304 | 304 | $options = []; |
305 | 305 | |
306 | 306 | // Looking for duplicated clauses. |
307 | - if (! empty(Parser::KEYWORD_PARSERS[$token->value]) || ! empty(Parser::STATEMENT_PARSERS[$token->value])) { |
|
308 | - if (! empty($parsedClauses[$token->value])) { |
|
307 | + if (!empty(Parser::KEYWORD_PARSERS[$token->value]) || !empty(Parser::STATEMENT_PARSERS[$token->value])) { |
|
308 | + if (!empty($parsedClauses[$token->value])) { |
|
309 | 309 | $parser->error('This type of clause was previously parsed.', $token); |
310 | 310 | break; |
311 | 311 | } |
@@ -318,18 +318,18 @@ discard block |
||
318 | 318 | // but it might be the beginning of a statement of truncate, |
319 | 319 | // so let the value use the keyword field for truncate type. |
320 | 320 | $tokenValue = in_array($token->keyword, ['TRUNCATE']) ? $token->keyword : $token->value; |
321 | - if (! empty(Parser::KEYWORD_PARSERS[$tokenValue]) && $list->idx < $list->count) { |
|
321 | + if (!empty(Parser::KEYWORD_PARSERS[$tokenValue]) && $list->idx < $list->count) { |
|
322 | 322 | $class = Parser::KEYWORD_PARSERS[$tokenValue]['class']; |
323 | 323 | $field = Parser::KEYWORD_PARSERS[$tokenValue]['field']; |
324 | - if (! empty(Parser::KEYWORD_PARSERS[$tokenValue]['options'])) { |
|
324 | + if (!empty(Parser::KEYWORD_PARSERS[$tokenValue]['options'])) { |
|
325 | 325 | $options = Parser::KEYWORD_PARSERS[$tokenValue]['options']; |
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
329 | 329 | // Checking if this is the beginning of the statement. |
330 | - if (! empty(Parser::STATEMENT_PARSERS[$token->keyword])) { |
|
330 | + if (!empty(Parser::STATEMENT_PARSERS[$token->keyword])) { |
|
331 | 331 | if ( |
332 | - ! empty(static::$clauses) // Undefined for some statements. |
|
332 | + !empty(static::$clauses) // Undefined for some statements. |
|
333 | 333 | && empty(static::$clauses[$token->value]) |
334 | 334 | ) { |
335 | 335 | // Some keywords (e.g. `SET`) may be the beginning of a |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | break; |
345 | 345 | } |
346 | 346 | |
347 | - if (! $parsedOptions) { |
|
347 | + if (!$parsedOptions) { |
|
348 | 348 | if (empty(static::$statementOptions[$token->value])) { |
349 | 349 | // Skipping keyword because if it is not a option. |
350 | 350 | ++$list->idx; |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | if ($minJoin === 0 && stripos($clauseType, 'JOIN')) { |
518 | 518 | // First JOIN clause is detected |
519 | 519 | $minJoin = $maxJoin = $clauseStartIdx; |
520 | - } elseif ($minJoin !== 0 && ! stripos($clauseType, 'JOIN')) { |
|
520 | + } elseif ($minJoin !== 0 && !stripos($clauseType, 'JOIN')) { |
|
521 | 521 | // After a previous JOIN clause, a non-JOIN clause has been detected |
522 | 522 | $maxJoin = $lastIdx; |
523 | 523 | } elseif ($maxJoin < $clauseStartIdx && stripos($clauseType, 'JOIN')) { |