@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | // The options of a clause should stay on the same line and everything that follows. |
| 436 | 436 | if ( |
| 437 | 437 | $this->options['parts_newline'] |
| 438 | - && ! $formattedOptions |
|
| 438 | + && !$formattedOptions |
|
| 439 | 439 | && empty(self::$inlineClauses[$lastClause]) |
| 440 | 440 | && ( |
| 441 | 441 | $curr->type !== TokenType::Keyword |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | end($blocksLineEndings) === true |
| 493 | 493 | || ( |
| 494 | 494 | empty(self::$inlineClauses[$lastClause]) |
| 495 | - && ! $shortGroup |
|
| 495 | + && !$shortGroup |
|
| 496 | 496 | && $this->options['parts_newline'] |
| 497 | 497 | ) |
| 498 | 498 | ) { |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | $lineEnded = false; |
| 529 | 529 | } elseif ( |
| 530 | 530 | $prev->keyword === 'DELIMITER' |
| 531 | - || ! ( |
|
| 531 | + || !( |
|
| 532 | 532 | ($prev->type === TokenType::Operator && ($prev->value === '.' || $prev->value === '(')) |
| 533 | 533 | // No space after . ( |
| 534 | 534 | || ($curr->type === TokenType::Operator |
@@ -643,13 +643,13 @@ discard block |
||
| 643 | 643 | |
| 644 | 644 | foreach ($this->options['formats'] as $format) { |
| 645 | 645 | if ( |
| 646 | - $token->type->value !== $format['type'] || ! (($token->flags & $format['flags']) === $format['flags']) |
|
| 646 | + $token->type->value !== $format['type'] || !(($token->flags & $format['flags']) === $format['flags']) |
|
| 647 | 647 | ) { |
| 648 | 648 | continue; |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | // Running transformation function. |
| 652 | - if (! empty($format['function'])) { |
|
| 652 | + if (!empty($format['function'])) { |
|
| 653 | 653 | $func = $format['function']; |
| 654 | 654 | $text = $func($text); |
| 655 | 655 | } |
@@ -758,7 +758,7 @@ discard block |
||
| 758 | 758 | * |
| 759 | 759 | * @psalm-return 1|2|false |
| 760 | 760 | */ |
| 761 | - public static function isClause($token): int|false |
|
| 761 | + public static function isClause($token): int | false |
|
| 762 | 762 | { |
| 763 | 763 | if ( |
| 764 | 764 | ($token->type === TokenType::Keyword && isset(Parser::STATEMENT_PARSERS[$token->keyword])) |
@@ -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 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @throws ParserException |
| 157 | 157 | */ |
| 158 | - public static function parse(Parser $parser, TokensList $list, array $options = []): Expression|null |
|
| 158 | + public static function parse(Parser $parser, TokensList $list, array $options = []): Expression | null |
|
| 159 | 159 | { |
| 160 | 160 | $ret = new static(); |
| 161 | 161 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | ]; |
| 199 | 199 | |
| 200 | 200 | // When a field is parsed, no parentheses are expected. |
| 201 | - if (! empty($options['parseField'])) { |
|
| 201 | + if (!empty($options['parseField'])) { |
|
| 202 | 202 | $options['breakOnParentheses'] = true; |
| 203 | 203 | $options['field'] = $options['parseField']; |
| 204 | 204 | } |
@@ -225,14 +225,14 @@ discard block |
||
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | if ($token->type === TokenType::Keyword) { |
| 228 | - if (($brackets > 0) && empty($ret->subquery) && ! empty(Parser::STATEMENT_PARSERS[$token->keyword])) { |
|
| 228 | + if (($brackets > 0) && empty($ret->subquery) && !empty(Parser::STATEMENT_PARSERS[$token->keyword])) { |
|
| 229 | 229 | // A `(` was previously found and this keyword is the |
| 230 | 230 | // beginning of a statement, so this is a subquery. |
| 231 | 231 | $ret->subquery = $token->keyword; |
| 232 | 232 | } elseif ( |
| 233 | 233 | ($token->flags & Token::FLAG_KEYWORD_FUNCTION) |
| 234 | 234 | && (empty($options['parseField']) |
| 235 | - && ! $alias) |
|
| 235 | + && !$alias) |
|
| 236 | 236 | ) { |
| 237 | 237 | $isExpr = true; |
| 238 | 238 | } elseif (($token->flags & Token::FLAG_KEYWORD_RESERVED) && ($brackets === 0)) { |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | if ($token->keyword === 'AS') { |
| 247 | - if (! empty($options['breakOnAlias'])) { |
|
| 247 | + if (!empty($options['breakOnAlias'])) { |
|
| 248 | 248 | break; |
| 249 | 249 | } |
| 250 | 250 | |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | $isExpr = true; |
| 270 | - } elseif ($brackets === 0 && strlen((string) $ret->expr) > 0 && ! $alias) { |
|
| 270 | + } elseif ($brackets === 0 && strlen((string) $ret->expr) > 0 && !$alias) { |
|
| 271 | 271 | /* End of expression */ |
| 272 | 272 | break; |
| 273 | 273 | } |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | || (($token->type === TokenType::Operator) |
| 284 | 284 | && ($token->value !== '.')) |
| 285 | 285 | ) { |
| 286 | - if (! empty($options['parseField'])) { |
|
| 286 | + if (!empty($options['parseField'])) { |
|
| 287 | 287 | break; |
| 288 | 288 | } |
| 289 | 289 | |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | if ($token->type === TokenType::Operator) { |
| 296 | - if (! empty($options['breakOnParentheses']) && (($token->value === '(') || ($token->value === ')'))) { |
|
| 296 | + if (!empty($options['breakOnParentheses']) && (($token->value === '(') || ($token->value === ')'))) { |
|
| 297 | 297 | // No brackets were expected. |
| 298 | 298 | break; |
| 299 | 299 | } |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | |
| 318 | 318 | --$brackets; |
| 319 | 319 | if ($brackets === 0) { |
| 320 | - if (! empty($options['parenthesesDelimited'])) { |
|
| 320 | + if (!empty($options['parenthesesDelimited'])) { |
|
| 321 | 321 | // The current token is the last bracket, the next |
| 322 | 322 | // one will be outside the expression. |
| 323 | 323 | $ret->expr .= $token->token; |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | |
| 344 | 344 | if ($alias) { |
| 345 | 345 | // An alias is expected (the keyword `AS` was previously found). |
| 346 | - if (! empty($ret->alias)) { |
|
| 346 | + if (!empty($ret->alias)) { |
|
| 347 | 347 | $parser->error('An alias was previously found.', $token); |
| 348 | 348 | break; |
| 349 | 349 | } |
@@ -357,14 +357,14 @@ discard block |
||
| 357 | 357 | && ($prev[0] === null |
| 358 | 358 | || (($prev[0]->type !== TokenType::Operator || $prev[0]->token === ')') |
| 359 | 359 | && ($prev[0]->type !== TokenType::Keyword |
| 360 | - || ! ($prev[0]->flags & Token::FLAG_KEYWORD_RESERVED)))) |
|
| 360 | + || !($prev[0]->flags & Token::FLAG_KEYWORD_RESERVED)))) |
|
| 361 | 361 | && (($prev[1]->type === TokenType::String) |
| 362 | 362 | || ($prev[1]->type === TokenType::Symbol |
| 363 | - && ! ($prev[1]->flags & Token::FLAG_SYMBOL_VARIABLE)) |
|
| 363 | + && !($prev[1]->flags & Token::FLAG_SYMBOL_VARIABLE)) |
|
| 364 | 364 | || ($prev[1]->type === TokenType::None |
| 365 | 365 | && $prev[1]->token !== 'OVER')) |
| 366 | 366 | ) { |
| 367 | - if (! empty($ret->alias)) { |
|
| 367 | + if (!empty($ret->alias)) { |
|
| 368 | 368 | $parser->error('An alias was previously found.', $token); |
| 369 | 369 | break; |
| 370 | 370 | } |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | // Found a `.` which means we expect a column name and |
| 396 | 396 | // the column name we parsed is actually the table name |
| 397 | 397 | // and the table name is actually a database name. |
| 398 | - if (! empty($ret->database) || $dot) { |
|
| 398 | + if (!empty($ret->database) || $dot) { |
|
| 399 | 399 | $parser->error('Unexpected dot.', $token); |
| 400 | 400 | } |
| 401 | 401 | |
@@ -412,11 +412,11 @@ discard block |
||
| 412 | 412 | $dot = false; |
| 413 | 413 | } else { |
| 414 | 414 | // No alias is expected. |
| 415 | - if (! empty($options['breakOnAlias'])) { |
|
| 415 | + if (!empty($options['breakOnAlias'])) { |
|
| 416 | 416 | break; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - if (! empty($ret->alias)) { |
|
| 419 | + if (!empty($ret->alias)) { |
|
| 420 | 420 | $parser->error('An alias was previously found.', $token); |
| 421 | 421 | break; |
| 422 | 422 | } |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | $ret = implode('.', Context::escapeAll($fields)); |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | - if (! empty($this->alias)) { |
|
| 467 | + if (!empty($this->alias)) { |
|
| 468 | 468 | $ret .= ' AS ' . Context::escape($this->alias); |
| 469 | 469 | } |
| 470 | 470 | |
@@ -174,9 +174,9 @@ discard block |
||
| 174 | 174 | } elseif ($state === 1) { |
| 175 | 175 | if (($token->type === TokenType::Operator) && ($token->value === '(')) { |
| 176 | 176 | $positionBeforeSearch = $list->idx; |
| 177 | - $list->idx++;// Ignore the current token "(" or the search condition will always be true |
|
| 177 | + $list->idx++; // Ignore the current token "(" or the search condition will always be true |
|
| 178 | 178 | $nextToken = $list->getNext(); |
| 179 | - $list->idx = $positionBeforeSearch;// Restore the position |
|
| 179 | + $list->idx = $positionBeforeSearch; // Restore the position |
|
| 180 | 180 | |
| 181 | 181 | if ($nextToken !== null && $nextToken->value === '(') { |
| 182 | 182 | // Switch to expression mode |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | if ($token->type === TokenType::Operator) { |
| 226 | 226 | // This got back to here and we reached the end of the expression |
| 227 | 227 | if ($token->value === ')') { |
| 228 | - $state = 4;// go back to state 4 to fetch options |
|
| 228 | + $state = 4; // go back to state 4 to fetch options |
|
| 229 | 229 | continue; |
| 230 | 230 | } |
| 231 | 231 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | public function build(): string |
| 262 | 262 | { |
| 263 | 263 | $ret = $this->type . ' '; |
| 264 | - if (! empty($this->name)) { |
|
| 264 | + if (!empty($this->name)) { |
|
| 265 | 265 | $ret .= Context::escape($this->name) . ' '; |
| 266 | 266 | } |
| 267 | 267 | |
@@ -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 | |
@@ -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 |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | if ($state === 0) { |
| 115 | - if ($token->type !== TokenType::None || ! preg_match('/^[a-zA-Z0-9_$]+$/', $token->token)) { |
|
| 115 | + if ($token->type !== TokenType::None || !preg_match('/^[a-zA-Z0-9_$]+$/', $token->token)) { |
|
| 116 | 116 | $parser->error('The name of the CTE was expected.', $token); |
| 117 | 117 | break; |
| 118 | 118 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | break; |
| 137 | 137 | } |
| 138 | 138 | } elseif ($state === 2) { |
| 139 | - if (! ($token->type === TokenType::Keyword && $token->keyword === 'AS')) { |
|
| 139 | + if (!($token->type === TokenType::Keyword && $token->keyword === 'AS')) { |
|
| 140 | 140 | $parser->error('AS keyword was expected.', $token); |
| 141 | 141 | break; |
| 142 | 142 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | $list->idx++; // Ignore the current token |
| 149 | 149 | $nextKeyword = $list->getNext(); |
| 150 | 150 | |
| 151 | - if (! ($token->value === '(' && ($nextKeyword && $nextKeyword->value === 'SELECT'))) { |
|
| 151 | + if (!($token->value === '(' && ($nextKeyword && $nextKeyword->value === 'SELECT'))) { |
|
| 152 | 152 | $parser->error('Subquery of the CTE was expected.', $token); |
| 153 | 153 | $list->idx = $idxBeforeGetNext; |
| 154 | 154 | break; |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | /** |
| 296 | 296 | * Get tokens within the WITH expression to use them in another parser |
| 297 | 297 | */ |
| 298 | - private function getSubTokenList(TokensList $list): ParserException|TokensList |
|
| 298 | + private function getSubTokenList(TokensList $list): ParserException | TokensList |
|
| 299 | 299 | { |
| 300 | 300 | $idx = $list->idx; |
| 301 | 301 | $token = $list->tokens[$list->idx]; |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | ++$list->idx; |
| 314 | - if (! isset($list->tokens[$list->idx])) { |
|
| 314 | + if (!isset($list->tokens[$list->idx])) { |
|
| 315 | 315 | break; |
| 316 | 316 | } |
| 317 | 317 | |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | * Used by all `CREATE` statements. |
| 271 | 271 | */ |
| 272 | - public Expression|null $name = null; |
|
| 272 | + public Expression | null $name = null; |
|
| 273 | 273 | |
| 274 | 274 | /** |
| 275 | 275 | * The options of the entity (table, procedure, function, etc.). |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | public function build(): string |
| 399 | 399 | { |
| 400 | 400 | $fields = ''; |
| 401 | - if (! empty($this->fields)) { |
|
| 401 | + if (!empty($this->fields)) { |
|
| 402 | 402 | if (is_array($this->fields)) { |
| 403 | 403 | $fields = CreateDefinition::buildAll($this->fields) . ' '; |
| 404 | 404 | } elseif ($this->fields instanceof ArrayObj) { |
@@ -437,23 +437,23 @@ discard block |
||
| 437 | 437 | |
| 438 | 438 | $partition = ''; |
| 439 | 439 | |
| 440 | - if (! empty($this->partitionBy)) { |
|
| 440 | + if (!empty($this->partitionBy)) { |
|
| 441 | 441 | $partition .= "\nPARTITION BY " . $this->partitionBy; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - if (! empty($this->partitionsNum)) { |
|
| 444 | + if (!empty($this->partitionsNum)) { |
|
| 445 | 445 | $partition .= "\nPARTITIONS " . $this->partitionsNum; |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - if (! empty($this->subpartitionBy)) { |
|
| 448 | + if (!empty($this->subpartitionBy)) { |
|
| 449 | 449 | $partition .= "\nSUBPARTITION BY " . $this->subpartitionBy; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - if (! empty($this->subpartitionsNum)) { |
|
| 452 | + if (!empty($this->subpartitionsNum)) { |
|
| 453 | 453 | $partition .= "\nSUBPARTITIONS " . $this->subpartitionsNum; |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - if (! empty($this->partitions)) { |
|
| 456 | + if (!empty($this->partitions)) { |
|
| 457 | 457 | $partition .= "\n" . PartitionDefinition::buildAll($this->partitions); |
| 458 | 458 | } |
| 459 | 459 | |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | $token = $list->getNextOfType(TokenType::Number); |
| 648 | 648 | --$list->idx; // `getNextOfType` also advances one position. |
| 649 | 649 | $this->subpartitionsNum = $token->value; |
| 650 | - } elseif (! empty($field)) { |
|
| 650 | + } elseif (!empty($field)) { |
|
| 651 | 651 | /* |
| 652 | 652 | * Handling the content of `PARTITION BY` and `SUBPARTITION BY`. |
| 653 | 653 | */ |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | $field = null; |
| 677 | 677 | } |
| 678 | 678 | } elseif (($token->type === TokenType::Operator) && ($token->value === '(')) { |
| 679 | - if (! empty($this->partitionBy)) { |
|
| 679 | + if (!empty($this->partitionBy)) { |
|
| 680 | 680 | $this->partitions = ArrayObj::parse( |
| 681 | 681 | $parser, |
| 682 | 682 | $list, |