@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * Gets the next token. Skips any irrelevant token (whitespaces and |
95 | 95 | * comments). |
96 | 96 | */ |
97 | - public function getNext(): Token|null |
|
97 | + public function getNext(): Token | null |
|
98 | 98 | { |
99 | 99 | for (; $this->idx < $this->count; ++$this->idx) { |
100 | 100 | if ( |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * Gets the previous token. Skips any irrelevant token (whitespaces and |
113 | 113 | * comments). |
114 | 114 | */ |
115 | - public function getPrevious(): Token|null |
|
115 | + public function getPrevious(): Token | null |
|
116 | 116 | { |
117 | 117 | for (; $this->idx >= 0; --$this->idx) { |
118 | 118 | if ( |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @param int|int[] $type the type |
133 | 133 | */ |
134 | - public function getPreviousOfType($type): Token|null |
|
134 | + public function getPreviousOfType($type): Token | null |
|
135 | 135 | { |
136 | - if (! is_array($type)) { |
|
136 | + if (!is_array($type)) { |
|
137 | 137 | $type = [$type]; |
138 | 138 | } |
139 | 139 | |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @param int|int[] $type the type |
153 | 153 | */ |
154 | - public function getNextOfType($type): Token|null |
|
154 | + public function getNextOfType($type): Token | null |
|
155 | 155 | { |
156 | - if (! is_array($type)) { |
|
156 | + if (!is_array($type)) { |
|
157 | 157 | $type = [$type]; |
158 | 158 | } |
159 | 159 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @param int $type the type of the token |
173 | 173 | * @param string $value the value of the token |
174 | 174 | */ |
175 | - public function getNextOfTypeAndValue($type, $value): Token|null |
|
175 | + public function getNextOfTypeAndValue($type, $value): Token | null |
|
176 | 176 | { |
177 | 177 | for (; $this->idx < $this->count; ++$this->idx) { |
178 | 178 | if (($this->tokens[$this->idx]->type === $type) && ($this->tokens[$this->idx]->value === $value)) { |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * @param int $type the type of the token |
190 | 190 | * @param int $flag the flag of the token |
191 | 191 | */ |
192 | - public function getNextOfTypeAndFlag(int $type, int $flag): Token|null |
|
192 | + public function getNextOfTypeAndFlag(int $type, int $flag): Token | null |
|
193 | 193 | { |
194 | 194 | for (; $this->idx < $this->count; ++$this->idx) { |
195 | 195 | if (($this->tokens[$this->idx]->type === $type) && ($this->tokens[$this->idx]->flags === $flag)) { |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @param int $offset the offset to be returned |
222 | 222 | */ |
223 | - public function offsetGet($offset): Token|null |
|
223 | + public function offsetGet($offset): Token | null |
|
224 | 224 | { |
225 | 225 | return $offset < $this->count ? $this->tokens[$offset] : null; |
226 | 226 | } |
@@ -65,7 +65,7 @@ |
||
65 | 65 | */ |
66 | 66 | public static function gettext($msgid): string |
67 | 67 | { |
68 | - if (! class_exists(Loader::class, true)) { |
|
68 | + if (!class_exists(Loader::class, true)) { |
|
69 | 69 | return $msgid; |
70 | 70 | } |
71 | 71 |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @param TokensList $list the list of tokens that are being parsed |
95 | 95 | * @param array<string, mixed> $options parameters for parsing |
96 | 96 | */ |
97 | - public static function parse(Parser $parser, TokensList $list, array $options = []): DataType|null |
|
97 | + public static function parse(Parser $parser, TokensList $list, array $options = []): DataType | null |
|
98 | 98 | { |
99 | 99 | $ret = new static(); |
100 | 100 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | if ($state === 0) { |
126 | 126 | $ret->name = strtoupper((string) $token->value); |
127 | - if (($token->type !== Token::TYPE_KEYWORD) || (! ($token->flags & Token::FLAG_KEYWORD_DATA_TYPE))) { |
|
127 | + if (($token->type !== Token::TYPE_KEYWORD) || (!($token->flags & Token::FLAG_KEYWORD_DATA_TYPE))) { |
|
128 | 128 | $parser->error('Unrecognized data type.', $token); |
129 | 129 | } |
130 | 130 |
@@ -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 |
@@ -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; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $len = $str instanceof UtfString ? $str->length() : strlen($str); |
175 | 175 | |
176 | 176 | // For multi-byte strings, a new instance of `UtfString` is initialized. |
177 | - if (! $str instanceof UtfString && $len !== mb_strlen($str, 'UTF-8')) { |
|
177 | + if (!$str instanceof UtfString && $len !== mb_strlen($str, 'UTF-8')) { |
|
178 | 178 | $str = new UtfString($str); |
179 | 179 | } |
180 | 180 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | $this->strict = $strict; |
185 | 185 | |
186 | 186 | // Setting the delimiter. |
187 | - $this->setDelimiter(! empty($delimiter) ? $delimiter : static::$defaultDelimiter); |
|
187 | + $this->setDelimiter(!empty($delimiter) ? $delimiter : static::$defaultDelimiter); |
|
188 | 188 | |
189 | 189 | $this->lex(); |
190 | 190 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | $delimiterLen = 0; |
309 | 309 | while ( |
310 | 310 | ++$this->last < $this->len |
311 | - && ! Context::isWhitespace($this->str[$this->last]) |
|
311 | + && !Context::isWhitespace($this->str[$this->last]) |
|
312 | 312 | && $delimiterLen < 15 |
313 | 313 | ) { |
314 | 314 | $this->delimiter .= $this->str[$this->last]; |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | } |
368 | 368 | |
369 | 369 | if ( |
370 | - ($next->type !== Token::TYPE_KEYWORD || ! in_array($next->value, ['FROM', 'USING'], true)) |
|
371 | - && ($next->type !== Token::TYPE_OPERATOR || ! in_array($next->value, [',', ')'], true)) |
|
370 | + ($next->type !== Token::TYPE_KEYWORD || !in_array($next->value, ['FROM', 'USING'], true)) |
|
371 | + && ($next->type !== Token::TYPE_OPERATOR || !in_array($next->value, [',', ')'], true)) |
|
372 | 372 | ) { |
373 | 373 | continue; |
374 | 374 | } |
@@ -406,10 +406,10 @@ discard block |
||
406 | 406 | $next = $this->list->getNext(); |
407 | 407 | if ( |
408 | 408 | ($next->type !== Token::TYPE_KEYWORD |
409 | - || ! in_array($next->value, self::KEYWORD_NAME_INDICATORS, true) |
|
409 | + || !in_array($next->value, self::KEYWORD_NAME_INDICATORS, true) |
|
410 | 410 | ) |
411 | 411 | && ($next->type !== Token::TYPE_OPERATOR |
412 | - || ! in_array($next->value, self::OPERATOR_NAME_INDICATORS, true) |
|
412 | + || !in_array($next->value, self::OPERATOR_NAME_INDICATORS, true) |
|
413 | 413 | ) |
414 | 414 | && ($next->value !== null) |
415 | 415 | ) { |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | /** |
449 | 449 | * Parses a keyword. |
450 | 450 | */ |
451 | - public function parseKeyword(): Token|null |
|
451 | + public function parseKeyword(): Token | null |
|
452 | 452 | { |
453 | 453 | $token = ''; |
454 | 454 | |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | $token .= $this->str[$this->last]; |
489 | 489 | $flags = Context::isKeyword($token); |
490 | 490 | |
491 | - if (($this->last + 1 !== $this->len && ! Context::isSeparator($this->str[$this->last + 1])) || ! $flags) { |
|
491 | + if (($this->last + 1 !== $this->len && !Context::isSeparator($this->str[$this->last + 1])) || !$flags) { |
|
492 | 492 | continue; |
493 | 493 | } |
494 | 494 | |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | /** |
509 | 509 | * Parses a label. |
510 | 510 | */ |
511 | - public function parseLabel(): Token|null |
|
511 | + public function parseLabel(): Token | null |
|
512 | 512 | { |
513 | 513 | $token = ''; |
514 | 514 | |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | /** |
553 | 553 | * Parses an operator. |
554 | 554 | */ |
555 | - public function parseOperator(): Token|null |
|
555 | + public function parseOperator(): Token | null |
|
556 | 556 | { |
557 | 557 | $token = ''; |
558 | 558 | |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | $token .= $this->str[$this->last]; |
573 | 573 | $flags = Context::isOperator($token); |
574 | 574 | |
575 | - if (! $flags) { |
|
575 | + if (!$flags) { |
|
576 | 576 | continue; |
577 | 577 | } |
578 | 578 | |
@@ -588,11 +588,11 @@ discard block |
||
588 | 588 | /** |
589 | 589 | * Parses a whitespace. |
590 | 590 | */ |
591 | - public function parseWhitespace(): Token|null |
|
591 | + public function parseWhitespace(): Token | null |
|
592 | 592 | { |
593 | 593 | $token = $this->str[$this->last]; |
594 | 594 | |
595 | - if (! Context::isWhitespace($token)) { |
|
595 | + if (!Context::isWhitespace($token)) { |
|
596 | 596 | return null; |
597 | 597 | } |
598 | 598 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | /** |
609 | 609 | * Parses a comment. |
610 | 610 | */ |
611 | - public function parseComment(): Token|null |
|
611 | + public function parseComment(): Token | null |
|
612 | 612 | { |
613 | 613 | $iBak = $this->last; |
614 | 614 | $token = $this->str[$this->last]; |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | /** |
726 | 726 | * Parses a boolean. |
727 | 727 | */ |
728 | - public function parseBool(): Token|null |
|
728 | + public function parseBool(): Token | null |
|
729 | 729 | { |
730 | 730 | if ($this->last + 3 >= $this->len) { |
731 | 731 | // At least `min(strlen('TRUE'), strlen('FALSE'))` characters are |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | /** |
757 | 757 | * Parses a number. |
758 | 758 | */ |
759 | - public function parseNumber(): Token|null |
|
759 | + public function parseNumber(): Token | null |
|
760 | 760 | { |
761 | 761 | // A rudimentary state machine is being used to parse numbers due to |
762 | 762 | // the various forms of their notation. |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | } elseif ($state === 2) { |
827 | 827 | $flags |= Token::FLAG_NUMBER_HEX; |
828 | 828 | if ( |
829 | - ! ( |
|
829 | + !( |
|
830 | 830 | ($this->str[$this->last] >= '0' && $this->str[$this->last] <= '9') |
831 | 831 | || ($this->str[$this->last] >= 'A' && $this->str[$this->last] <= 'F') |
832 | 832 | || ($this->str[$this->last] >= 'a' && $this->str[$this->last] <= 'f') |
@@ -922,12 +922,12 @@ discard block |
||
922 | 922 | * |
923 | 923 | * @throws LexerException |
924 | 924 | */ |
925 | - public function parseString($quote = ''): Token|null |
|
925 | + public function parseString($quote = ''): Token | null |
|
926 | 926 | { |
927 | 927 | $token = $this->str[$this->last]; |
928 | 928 | $flags = Context::isString($token); |
929 | 929 | |
930 | - if (! $flags && $token !== $quote) { |
|
930 | + if (!$flags && $token !== $quote) { |
|
931 | 931 | return null; |
932 | 932 | } |
933 | 933 | |
@@ -972,12 +972,12 @@ discard block |
||
972 | 972 | * |
973 | 973 | * @throws LexerException |
974 | 974 | */ |
975 | - public function parseSymbol(): Token|null |
|
975 | + public function parseSymbol(): Token | null |
|
976 | 976 | { |
977 | 977 | $token = $this->str[$this->last]; |
978 | 978 | $flags = Context::isSymbol($token); |
979 | 979 | |
980 | - if (! $flags) { |
|
980 | + if (!$flags) { |
|
981 | 981 | return null; |
982 | 982 | } |
983 | 983 | |
@@ -1019,14 +1019,14 @@ discard block |
||
1019 | 1019 | /** |
1020 | 1020 | * Parses unknown parts of the query. |
1021 | 1021 | */ |
1022 | - public function parseUnknown(): Token|null |
|
1022 | + public function parseUnknown(): Token | null |
|
1023 | 1023 | { |
1024 | 1024 | $token = $this->str[$this->last]; |
1025 | 1025 | if (Context::isSeparator($token)) { |
1026 | 1026 | return null; |
1027 | 1027 | } |
1028 | 1028 | |
1029 | - while (++$this->last < $this->len && ! Context::isSeparator($this->str[$this->last])) { |
|
1029 | + while (++$this->last < $this->len && !Context::isSeparator($this->str[$this->last])) { |
|
1030 | 1030 | $token .= $this->str[$this->last]; |
1031 | 1031 | |
1032 | 1032 | // Test if end of token equals the current delimiter. If so, remove it from the token. |
@@ -1045,7 +1045,7 @@ discard block |
||
1045 | 1045 | /** |
1046 | 1046 | * Parses the delimiter of the query. |
1047 | 1047 | */ |
1048 | - public function parseDelimiter(): Token|null |
|
1048 | + public function parseDelimiter(): Token | null |
|
1049 | 1049 | { |
1050 | 1050 | $idx = 0; |
1051 | 1051 |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | // The options of a clause should stay on the same line and everything that follows. |
435 | 435 | if ( |
436 | 436 | $this->options['parts_newline'] |
437 | - && ! $formattedOptions |
|
437 | + && !$formattedOptions |
|
438 | 438 | && empty(self::$inlineClauses[$lastClause]) |
439 | 439 | && ( |
440 | 440 | $curr->type !== Token::TYPE_KEYWORD |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | end($blocksLineEndings) === true |
492 | 492 | || ( |
493 | 493 | empty(self::$inlineClauses[$lastClause]) |
494 | - && ! $shortGroup |
|
494 | + && !$shortGroup |
|
495 | 495 | && $this->options['parts_newline'] |
496 | 496 | ) |
497 | 497 | ) { |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | $lineEnded = false; |
528 | 528 | } elseif ( |
529 | 529 | $prev->keyword === 'DELIMITER' |
530 | - || ! ( |
|
530 | + || !( |
|
531 | 531 | ($prev->type === Token::TYPE_OPERATOR && ($prev->value === '.' || $prev->value === '(')) |
532 | 532 | // No space after . ( |
533 | 533 | || ($curr->type === Token::TYPE_OPERATOR |
@@ -641,12 +641,12 @@ discard block |
||
641 | 641 | static $prev; |
642 | 642 | |
643 | 643 | foreach ($this->options['formats'] as $format) { |
644 | - if ($token->type !== $format['type'] || ! (($token->flags & $format['flags']) === $format['flags'])) { |
|
644 | + if ($token->type !== $format['type'] || !(($token->flags & $format['flags']) === $format['flags'])) { |
|
645 | 645 | continue; |
646 | 646 | } |
647 | 647 | |
648 | 648 | // Running transformation function. |
649 | - if (! empty($format['function'])) { |
|
649 | + if (!empty($format['function'])) { |
|
650 | 650 | $func = $format['function']; |
651 | 651 | $text = $func($text); |
652 | 652 | } |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | * |
756 | 756 | * @psalm-return 1|2|false |
757 | 757 | */ |
758 | - public static function isClause($token): int|false |
|
758 | + public static function isClause($token): int | false |
|
759 | 759 | { |
760 | 760 | if ( |
761 | 761 | ($token->type === Token::TYPE_KEYWORD && isset(Parser::STATEMENT_PARSERS[$token->keyword])) |
@@ -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), |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | - if (! empty($expr->type)) { |
|
191 | + if (!empty($expr->type)) { |
|
192 | 192 | $ret[] = $expr; |
193 | 193 | } |
194 | 194 | |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | $ret = []; |
214 | 214 | foreach ($component as $c) { |
215 | 215 | $ret[] = array_search($c->type, self::JOINS) . ' ' . $c->expr |
216 | - . (! empty($c->on) |
|
216 | + . (!empty($c->on) |
|
217 | 217 | ? ' ON ' . Condition::buildAll($c->on) : '') |
218 | - . (! empty($c->using) |
|
218 | + . (!empty($c->using) |
|
219 | 219 | ? ' USING ' . ArrayObj::build($c->using) : ''); |
220 | 220 | } |
221 | 221 |