@@ -150,11 +150,11 @@ discard block |
||
| 150 | 150 | * @param Reference|null $references references |
| 151 | 151 | */ |
| 152 | 152 | public function __construct( |
| 153 | - string|null $name = null, |
|
| 154 | - OptionsArray|null $options = null, |
|
| 155 | - DataType|Key|null $type = null, |
|
| 153 | + string | null $name = null, |
|
| 154 | + OptionsArray | null $options = null, |
|
| 155 | + DataType | Key | null $type = null, |
|
| 156 | 156 | bool $isConstraint = false, |
| 157 | - Reference|null $references = null, |
|
| 157 | + Reference | null $references = null, |
|
| 158 | 158 | ) { |
| 159 | 159 | $this->name = $name; |
| 160 | 160 | $this->options = $options; |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | $state = 4; |
| 237 | 237 | } elseif ($token->type === TokenType::Symbol || $token->type === TokenType::None) { |
| 238 | 238 | $expr->name = $token->value; |
| 239 | - if (! $expr->isConstraint) { |
|
| 239 | + if (!$expr->isConstraint) { |
|
| 240 | 240 | $state = 2; |
| 241 | 241 | } |
| 242 | 242 | } elseif ($token->type === TokenType::Keyword) { |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | |
| 278 | 278 | $state = 5; |
| 279 | 279 | } elseif ($state === 5) { |
| 280 | - if (! empty($expr->type) || ! empty($expr->key)) { |
|
| 280 | + if (!empty($expr->type) || !empty($expr->key)) { |
|
| 281 | 281 | $ret[] = $expr; |
| 282 | 282 | } |
| 283 | 283 | |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | // Last iteration was not saved. |
| 300 | - if (! empty($expr->type) || ! empty($expr->key)) { |
|
| 300 | + if (!empty($expr->type) || !empty($expr->key)) { |
|
| 301 | 301 | $ret[] = $expr; |
| 302 | 302 | } |
| 303 | 303 | |
@@ -322,16 +322,16 @@ discard block |
||
| 322 | 322 | $tmp .= Context::escape($this->name) . ' '; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - if (! empty($this->type)) { |
|
| 325 | + if (!empty($this->type)) { |
|
| 326 | 326 | $this->type->lowercase = true; |
| 327 | 327 | $tmp .= $this->type->build() . ' '; |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - if (! empty($this->key)) { |
|
| 330 | + if (!empty($this->key)) { |
|
| 331 | 331 | $tmp .= $this->key . ' '; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - if (! empty($this->references)) { |
|
| 334 | + if (!empty($this->references)) { |
|
| 335 | 335 | $tmp .= 'REFERENCES ' . $this->references . ' '; |
| 336 | 336 | } |
| 337 | 337 | |
@@ -264,9 +264,9 @@ discard block |
||
| 264 | 264 | * @param Token[] $unknown unparsed tokens found at the end of operation |
| 265 | 265 | */ |
| 266 | 266 | public function __construct( |
| 267 | - OptionsArray|null $options = null, |
|
| 268 | - Expression|string|null $field = null, |
|
| 269 | - array|null $partitions = null, |
|
| 267 | + OptionsArray | null $options = null, |
|
| 268 | + Expression | string | null $field = null, |
|
| 269 | + array | null $partitions = null, |
|
| 270 | 270 | public array $unknown = [], |
| 271 | 271 | ) { |
| 272 | 272 | $this->partitions = $partitions; |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | } elseif (($token->value === ',') && ($brackets === 0)) { |
| 402 | 402 | break; |
| 403 | 403 | } |
| 404 | - } elseif (! self::checkIfTokenQuotedSymbol($token) && $token->type !== TokenType::String) { |
|
| 404 | + } elseif (!self::checkIfTokenQuotedSymbol($token) && $token->type !== TokenType::String) { |
|
| 405 | 405 | if (isset(Parser::STATEMENT_PARSERS[$arrayKey]) && Parser::STATEMENT_PARSERS[$arrayKey] !== '') { |
| 406 | 406 | $list->idx++; // Ignore the current token |
| 407 | 407 | $nextToken = $list->getNext(); |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | } elseif ( |
| 425 | 425 | (array_key_exists($arrayKey, self::DATABASE_OPTIONS) |
| 426 | 426 | || array_key_exists($arrayKey, self::TABLE_OPTIONS)) |
| 427 | - && ! self::checkIfColumnDefinitionKeyword($arrayKey) |
|
| 427 | + && !self::checkIfColumnDefinitionKeyword($arrayKey) |
|
| 428 | 428 | ) { |
| 429 | 429 | // This alter operation has finished, which means a comma |
| 430 | 430 | // was missing before start of new alter operation |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | /** |
| 68 | 68 | * The string to be parsed. |
| 69 | 69 | */ |
| 70 | - public string|UtfString $str = ''; |
|
| 70 | + public string | UtfString $str = ''; |
|
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * The length of `$str`. |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * Statements delimiter. |
| 97 | 97 | * This may change during lexing. |
| 98 | 98 | */ |
| 99 | - public string|null $delimiter; |
|
| 99 | + public string | null $delimiter; |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * The length of the delimiter. |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * enabled or not |
| 114 | 114 | * @param string $delimiter the delimiter to be used |
| 115 | 115 | */ |
| 116 | - public function __construct(string|UtfString $str, bool $strict = false, string|null $delimiter = null) |
|
| 116 | + public function __construct(string | UtfString $str, bool $strict = false, string | null $delimiter = null) |
|
| 117 | 117 | { |
| 118 | 118 | if (Context::$keywords === []) { |
| 119 | 119 | Context::load(); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $len = $str instanceof UtfString ? $str->length() : strlen($str); |
| 125 | 125 | |
| 126 | 126 | // For multi-byte strings, a new instance of `UtfString` is initialized. |
| 127 | - if (! $str instanceof UtfString && $len !== mb_strlen($str, 'UTF-8')) { |
|
| 127 | + if (!$str instanceof UtfString && $len !== mb_strlen($str, 'UTF-8')) { |
|
| 128 | 128 | $str = new UtfString($str); |
| 129 | 129 | } |
| 130 | 130 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | $this->strict = $strict; |
| 135 | 135 | |
| 136 | 136 | // Setting the delimiter. |
| 137 | - $this->setDelimiter(! empty($delimiter) ? $delimiter : static::$defaultDelimiter); |
|
| 137 | + $this->setDelimiter(!empty($delimiter) ? $delimiter : static::$defaultDelimiter); |
|
| 138 | 138 | |
| 139 | 139 | $this->lex(); |
| 140 | 140 | } |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | $delimiterLen = 0; |
| 244 | 244 | while ( |
| 245 | 245 | ++$this->last < $this->len |
| 246 | - && ! Context::isWhitespace($this->str[$this->last]) |
|
| 246 | + && !Context::isWhitespace($this->str[$this->last]) |
|
| 247 | 247 | && $delimiterLen < 15 |
| 248 | 248 | ) { |
| 249 | 249 | $this->delimiter .= $this->str[$this->last]; |
@@ -302,8 +302,8 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | if ( |
| 305 | - ($next->type !== TokenType::Keyword || ! in_array($next->value, ['FROM', 'USING'], true)) |
|
| 306 | - && ($next->type !== TokenType::Operator || ! in_array($next->value, [',', ')'], true)) |
|
| 305 | + ($next->type !== TokenType::Keyword || !in_array($next->value, ['FROM', 'USING'], true)) |
|
| 306 | + && ($next->type !== TokenType::Operator || !in_array($next->value, [',', ')'], true)) |
|
| 307 | 307 | ) { |
| 308 | 308 | continue; |
| 309 | 309 | } |
@@ -341,10 +341,10 @@ discard block |
||
| 341 | 341 | $next = $this->list->getNext(); |
| 342 | 342 | if ( |
| 343 | 343 | ($next->type !== TokenType::Keyword |
| 344 | - || ! in_array($next->value, self::KEYWORD_NAME_INDICATORS, true) |
|
| 344 | + || !in_array($next->value, self::KEYWORD_NAME_INDICATORS, true) |
|
| 345 | 345 | ) |
| 346 | 346 | && ($next->type !== TokenType::Operator |
| 347 | - || ! in_array($next->value, self::OPERATOR_NAME_INDICATORS, true) |
|
| 347 | + || !in_array($next->value, self::OPERATOR_NAME_INDICATORS, true) |
|
| 348 | 348 | ) |
| 349 | 349 | && ($next->value !== null) |
| 350 | 350 | ) { |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | /** |
| 389 | 389 | * Parses a keyword. |
| 390 | 390 | */ |
| 391 | - public function parseKeyword(): Token|null |
|
| 391 | + public function parseKeyword(): Token | null |
|
| 392 | 392 | { |
| 393 | 393 | $token = ''; |
| 394 | 394 | |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | $token .= $this->str[$this->last]; |
| 429 | 429 | $flags = Context::isKeyword($token); |
| 430 | 430 | |
| 431 | - if (($this->last + 1 !== $this->len && ! Context::isSeparator($this->str[$this->last + 1])) || ! $flags) { |
|
| 431 | + if (($this->last + 1 !== $this->len && !Context::isSeparator($this->str[$this->last + 1])) || !$flags) { |
|
| 432 | 432 | continue; |
| 433 | 433 | } |
| 434 | 434 | |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | /** |
| 449 | 449 | * Parses a label. |
| 450 | 450 | */ |
| 451 | - public function parseLabel(): Token|null |
|
| 451 | + public function parseLabel(): Token | null |
|
| 452 | 452 | { |
| 453 | 453 | $token = ''; |
| 454 | 454 | |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | /** |
| 493 | 493 | * Parses an operator. |
| 494 | 494 | */ |
| 495 | - public function parseOperator(): Token|null |
|
| 495 | + public function parseOperator(): Token | null |
|
| 496 | 496 | { |
| 497 | 497 | $token = ''; |
| 498 | 498 | |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | $token .= $this->str[$this->last]; |
| 513 | 513 | $flags = Context::isOperator($token); |
| 514 | 514 | |
| 515 | - if (! $flags) { |
|
| 515 | + if (!$flags) { |
|
| 516 | 516 | continue; |
| 517 | 517 | } |
| 518 | 518 | |
@@ -528,11 +528,11 @@ discard block |
||
| 528 | 528 | /** |
| 529 | 529 | * Parses a whitespace. |
| 530 | 530 | */ |
| 531 | - public function parseWhitespace(): Token|null |
|
| 531 | + public function parseWhitespace(): Token | null |
|
| 532 | 532 | { |
| 533 | 533 | $token = $this->str[$this->last]; |
| 534 | 534 | |
| 535 | - if (! Context::isWhitespace($token)) { |
|
| 535 | + if (!Context::isWhitespace($token)) { |
|
| 536 | 536 | return null; |
| 537 | 537 | } |
| 538 | 538 | |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | /** |
| 549 | 549 | * Parses a comment. |
| 550 | 550 | */ |
| 551 | - public function parseComment(): Token|null |
|
| 551 | + public function parseComment(): Token | null |
|
| 552 | 552 | { |
| 553 | 553 | $iBak = $this->last; |
| 554 | 554 | $token = $this->str[$this->last]; |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | /** |
| 666 | 666 | * Parses a boolean. |
| 667 | 667 | */ |
| 668 | - public function parseBool(): Token|null |
|
| 668 | + public function parseBool(): Token | null |
|
| 669 | 669 | { |
| 670 | 670 | if ($this->last + 3 >= $this->len) { |
| 671 | 671 | // At least `min(strlen('TRUE'), strlen('FALSE'))` characters are |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | /** |
| 697 | 697 | * Parses a number. |
| 698 | 698 | */ |
| 699 | - public function parseNumber(): Token|null |
|
| 699 | + public function parseNumber(): Token | null |
|
| 700 | 700 | { |
| 701 | 701 | // A rudimentary state machine is being used to parse numbers due to |
| 702 | 702 | // the various forms of their notation. |
@@ -763,7 +763,7 @@ discard block |
||
| 763 | 763 | } elseif ($state === 2) { |
| 764 | 764 | $flags |= Token::FLAG_NUMBER_HEX; |
| 765 | 765 | if ( |
| 766 | - ! ( |
|
| 766 | + !( |
|
| 767 | 767 | ($this->str[$this->last] >= '0' && $this->str[$this->last] <= '9') |
| 768 | 768 | || ($this->str[$this->last] >= 'A' && $this->str[$this->last] <= 'F') |
| 769 | 769 | || ($this->str[$this->last] >= 'a' && $this->str[$this->last] <= 'f') |
@@ -859,12 +859,12 @@ discard block |
||
| 859 | 859 | * |
| 860 | 860 | * @throws LexerException |
| 861 | 861 | */ |
| 862 | - public function parseString(string $quote = ''): Token|null |
|
| 862 | + public function parseString(string $quote = ''): Token | null |
|
| 863 | 863 | { |
| 864 | 864 | $token = $this->str[$this->last]; |
| 865 | 865 | $flags = Context::isString($token); |
| 866 | 866 | |
| 867 | - if (! $flags && $token !== $quote) { |
|
| 867 | + if (!$flags && $token !== $quote) { |
|
| 868 | 868 | return null; |
| 869 | 869 | } |
| 870 | 870 | |
@@ -909,12 +909,12 @@ discard block |
||
| 909 | 909 | * |
| 910 | 910 | * @throws LexerException |
| 911 | 911 | */ |
| 912 | - public function parseSymbol(): Token|null |
|
| 912 | + public function parseSymbol(): Token | null |
|
| 913 | 913 | { |
| 914 | 914 | $token = $this->str[$this->last]; |
| 915 | 915 | $flags = Context::isSymbol($token); |
| 916 | 916 | |
| 917 | - if (! $flags) { |
|
| 917 | + if (!$flags) { |
|
| 918 | 918 | return null; |
| 919 | 919 | } |
| 920 | 920 | |
@@ -940,7 +940,7 @@ discard block |
||
| 940 | 940 | if ($str === null) { |
| 941 | 941 | $str = $this->parseUnknown(); |
| 942 | 942 | |
| 943 | - if ($str === null && ! ($flags & Token::FLAG_SYMBOL_PARAMETER)) { |
|
| 943 | + if ($str === null && !($flags & Token::FLAG_SYMBOL_PARAMETER)) { |
|
| 944 | 944 | $this->error('Variable name was expected.', $this->str[$this->last], $this->last); |
| 945 | 945 | } |
| 946 | 946 | } |
@@ -956,14 +956,14 @@ discard block |
||
| 956 | 956 | /** |
| 957 | 957 | * Parses unknown parts of the query. |
| 958 | 958 | */ |
| 959 | - public function parseUnknown(): Token|null |
|
| 959 | + public function parseUnknown(): Token | null |
|
| 960 | 960 | { |
| 961 | 961 | $token = $this->str[$this->last]; |
| 962 | 962 | if (Context::isSeparator($token)) { |
| 963 | 963 | return null; |
| 964 | 964 | } |
| 965 | 965 | |
| 966 | - while (++$this->last < $this->len && ! Context::isSeparator($this->str[$this->last])) { |
|
| 966 | + while (++$this->last < $this->len && !Context::isSeparator($this->str[$this->last])) { |
|
| 967 | 967 | $token .= $this->str[$this->last]; |
| 968 | 968 | |
| 969 | 969 | // Test if end of token equals the current delimiter. If so, remove it from the token. |
@@ -982,7 +982,7 @@ discard block |
||
| 982 | 982 | /** |
| 983 | 983 | * Parses the delimiter of the query. |
| 984 | 984 | */ |
| 985 | - public function parseDelimiter(): Token|null |
|
| 985 | + public function parseDelimiter(): Token | null |
|
| 986 | 986 | { |
| 987 | 987 | $idx = 0; |
| 988 | 988 | |
@@ -999,7 +999,7 @@ discard block |
||
| 999 | 999 | return new Token($this->delimiter, TokenType::Delimiter); |
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | - private function parse(): Token|null |
|
| 1002 | + private function parse(): Token | null |
|
| 1003 | 1003 | { |
| 1004 | 1004 | // It is best to put the parsers in order of their complexity |
| 1005 | 1005 | // (ascending) and their occurrence rate (descending). |