@@ -357,13 +357,13 @@ discard block |
||
| 357 | 357 | * |
| 358 | 358 | * @param bool $isReserved checks if the keyword is reserved |
| 359 | 359 | */ |
| 360 | - public static function isKeyword(string $string, bool $isReserved = false): int|null |
|
| 360 | + public static function isKeyword(string $string, bool $isReserved = false): int | null |
|
| 361 | 361 | { |
| 362 | 362 | $upperString = strtoupper($string); |
| 363 | 363 | |
| 364 | 364 | if ( |
| 365 | - ! isset(static::$keywords[$upperString]) |
|
| 366 | - || ($isReserved && ! (static::$keywords[$upperString] & Token::FLAG_KEYWORD_RESERVED)) |
|
| 365 | + !isset(static::$keywords[$upperString]) |
|
| 366 | + || ($isReserved && !(static::$keywords[$upperString] & Token::FLAG_KEYWORD_RESERVED)) |
|
| 367 | 367 | ) { |
| 368 | 368 | return null; |
| 369 | 369 | } |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | /** |
| 375 | 375 | * Checks if the given string is an operator and returns the appropriate flag for the operator. |
| 376 | 376 | */ |
| 377 | - public static function isOperator(string $string): int|null |
|
| 377 | + public static function isOperator(string $string): int | null |
|
| 378 | 378 | { |
| 379 | 379 | return static::$operators[$string] ?? null; |
| 380 | 380 | } |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | * |
| 393 | 393 | * @return int|null the appropriate flag for the comment type |
| 394 | 394 | */ |
| 395 | - public static function isComment(string $string, bool $end = false): int|null |
|
| 395 | + public static function isComment(string $string, bool $end = false): int | null |
|
| 396 | 396 | { |
| 397 | 397 | if ($string === '') { |
| 398 | 398 | return null; |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | * |
| 456 | 456 | * @return int|null the appropriate flag for the symbol type |
| 457 | 457 | */ |
| 458 | - public static function isSymbol(string $string): int|null |
|
| 458 | + public static function isSymbol(string $string): int | null |
|
| 459 | 459 | { |
| 460 | 460 | if ($string === '') { |
| 461 | 461 | return null; |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | * |
| 484 | 484 | * @return int|null the appropriate flag for the string type |
| 485 | 485 | */ |
| 486 | - public static function isString(string $string): int|null |
|
| 486 | + public static function isString(string $string): int | null |
|
| 487 | 487 | { |
| 488 | 488 | if ($string === '') { |
| 489 | 489 | return null; |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | $context = self::$contextPrefix . $context; |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | - if (! class_exists($context)) { |
|
| 540 | + if (!class_exists($context)) { |
|
| 541 | 541 | return false; |
| 542 | 542 | } |
| 543 | 543 | |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | * |
| 560 | 560 | * @return string|null The loaded context. `null` if no context was loaded. |
| 561 | 561 | */ |
| 562 | - public static function loadClosest(string $context = ''): string|null |
|
| 562 | + public static function loadClosest(string $context = ''): string | null |
|
| 563 | 563 | { |
| 564 | 564 | $length = strlen($context); |
| 565 | 565 | for ($i = $length; $i > 0;) { |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | $i -= 2; |
| 574 | 574 | $part = substr($context, $i, 2); |
| 575 | 575 | /* No more numeric parts to strip */ |
| 576 | - if (! is_numeric($part)) { |
|
| 576 | + if (!is_numeric($part)) { |
|
| 577 | 577 | break 2; |
| 578 | 578 | } |
| 579 | 579 | } while (intval($part) === 0 && $i > 0); |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | return $str; |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | - if ((static::$mode & self::SQL_MODE_NO_ENCLOSING_QUOTES) && (! static::isKeyword($str, true))) { |
|
| 751 | + if ((static::$mode & self::SQL_MODE_NO_ENCLOSING_QUOTES) && (!static::isKeyword($str, true))) { |
|
| 752 | 752 | return $str; |
| 753 | 753 | } |
| 754 | 754 | |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | * |
| 777 | 777 | * @return bool false on empty param, true/false on given constant/int value |
| 778 | 778 | */ |
| 779 | - public static function hasMode(int|null $flag = null): bool |
|
| 779 | + public static function hasMode(int | null $flag = null): bool |
|
| 780 | 780 | { |
| 781 | 781 | if (empty($flag)) { |
| 782 | 782 | return false; |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | } else { |
| 500 | 500 | // Checking if it is a known statement that can be parsed. |
| 501 | 501 | if (empty(static::$statementParsers[$token->keyword])) { |
| 502 | - if (! isset(static::$statementParsers[$token->keyword])) { |
|
| 502 | + if (!isset(static::$statementParsers[$token->keyword])) { |
|
| 503 | 503 | // A statement is considered recognized if the parser |
| 504 | 504 | // is aware that it is a statement, but it does not have |
| 505 | 505 | // a parser for it yet. |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | |
| 541 | 541 | // Handles unions. |
| 542 | 542 | if ( |
| 543 | - ! empty($unionType) |
|
| 543 | + !empty($unionType) |
|
| 544 | 544 | && ($lastStatement instanceof SelectStatement) |
| 545 | 545 | && ($statement instanceof SelectStatement) |
| 546 | 546 | ) { |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | * |
| 630 | 630 | * @throws ParserException throws the exception, if strict mode is enabled. |
| 631 | 631 | */ |
| 632 | - public function error($msg, Token|null $token = null, $code = 0) |
|
| 632 | + public function error($msg, Token | null $token = null, $code = 0) |
|
| 633 | 633 | { |
| 634 | 634 | $error = new ParserException( |
| 635 | 635 | Translator::gettext($msg), |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * @param Token $token the token that produced this exception |
| 25 | 25 | * @param int $code the code of this error |
| 26 | 26 | */ |
| 27 | - public function __construct($msg = '', Token|null $token = null, $code = 0) |
|
| 27 | + public function __construct($msg = '', Token | null $token = null, $code = 0) |
|
| 28 | 28 | { |
| 29 | 29 | parent::__construct($msg, $code); |
| 30 | 30 | $this->token = $token; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | * Gets the previous token. Skips any irrelevant token (whitespaces and |
| 119 | 119 | * comments). |
| 120 | 120 | */ |
| 121 | - public function getPrevious(): Token|null |
|
| 121 | + public function getPrevious(): Token | null |
|
| 122 | 122 | { |
| 123 | 123 | for (; $this->idx >= 0; --$this->idx) { |
| 124 | 124 | if ( |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | public function getPreviousOfType($type) |
| 143 | 143 | { |
| 144 | - if (! is_array($type)) { |
|
| 144 | + if (!is_array($type)) { |
|
| 145 | 145 | $type = [$type]; |
| 146 | 146 | } |
| 147 | 147 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public function getNextOfType($type) |
| 165 | 165 | { |
| 166 | - if (! is_array($type)) { |
|
| 166 | + if (!is_array($type)) { |
|
| 167 | 167 | $type = [$type]; |
| 168 | 168 | } |
| 169 | 169 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @param int $type the type of the token |
| 202 | 202 | * @param int $flag the flag of the token |
| 203 | 203 | */ |
| 204 | - public function getNextOfTypeAndFlag(int $type, int $flag): Token|null |
|
| 204 | + public function getNextOfTypeAndFlag(int $type, int $flag): Token | null |
|
| 205 | 205 | { |
| 206 | 206 | for (; $this->idx < $this->count; ++$this->idx) { |
| 207 | 207 | if (($this->tokens[$this->idx]->type === $type) && ($this->tokens[$this->idx]->flags === $flag)) { |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | { |
| 40 | 40 | foreach ($longopts as $value) { |
| 41 | 41 | $value = rtrim($value, ':'); |
| 42 | - if (! isset($params[$value])) { |
|
| 42 | + if (!isset($params[$value])) { |
|
| 43 | 43 | continue; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * |
| 63 | 63 | * @return string[]|false[]|false |
| 64 | 64 | */ |
| 65 | - public function getopt($opt, $long): array|false |
|
| 65 | + public function getopt($opt, $long): array | false |
|
| 66 | 66 | { |
| 67 | 67 | return getopt($opt, $long); |
| 68 | 68 | } |
@@ -84,11 +84,11 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | $this->mergeLongOpts($params, $longopts); |
| 87 | - if (! isset($params['f'])) { |
|
| 87 | + if (!isset($params['f'])) { |
|
| 88 | 88 | $params['f'] = 'cli'; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - if (! in_array($params['f'], ['html', 'cli', 'text'])) { |
|
| 91 | + if (!in_array($params['f'], ['html', 'cli', 'text'])) { |
|
| 92 | 92 | echo "ERROR: Invalid value for format!\n"; |
| 93 | 93 | |
| 94 | 94 | return false; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | return 0; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - if (! isset($params['q'])) { |
|
| 116 | + if (!isset($params['q'])) { |
|
| 117 | 117 | $stdIn = $this->readStdin(); |
| 118 | 118 | |
| 119 | 119 | if ($stdIn) { |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | Context::load($params['c']); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - if (! isset($params['q'])) { |
|
| 190 | + if (!isset($params['q'])) { |
|
| 191 | 191 | $stdIn = $this->readStdin(); |
| 192 | 192 | |
| 193 | 193 | if ($stdIn) { |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | return 0; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - if (! isset($params['q'])) { |
|
| 264 | + if (!isset($params['q'])) { |
|
| 265 | 265 | $stdIn = $this->readStdin(); |
| 266 | 266 | |
| 267 | 267 | if ($stdIn) { |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | return 1; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - public function readStdin(): string|false|null |
|
| 300 | + public function readStdin(): string | false | null |
|
| 301 | 301 | { |
| 302 | 302 | $read = [STDIN]; |
| 303 | 303 | $write = []; |
@@ -124,7 +124,7 @@ |
||
| 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 | |
@@ -179,9 +179,9 @@ discard block |
||
| 179 | 179 | } elseif ($state === 1) { |
| 180 | 180 | if (($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) { |
| 181 | 181 | $positionBeforeSearch = $list->idx; |
| 182 | - $list->idx++;// Ignore the current token "(" or the search condition will always be true |
|
| 182 | + $list->idx++; // Ignore the current token "(" or the search condition will always be true |
|
| 183 | 183 | $nextToken = $list->getNext(); |
| 184 | - $list->idx = $positionBeforeSearch;// Restore the position |
|
| 184 | + $list->idx = $positionBeforeSearch; // Restore the position |
|
| 185 | 185 | |
| 186 | 186 | if ($nextToken !== null && $nextToken->value === '(') { |
| 187 | 187 | // Switch to expression mode |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | if ($token->type === Token::TYPE_OPERATOR) { |
| 231 | 231 | // This got back to here and we reached the end of the expression |
| 232 | 232 | if ($token->value === ')') { |
| 233 | - $state = 4;// go back to state 4 to fetch options |
|
| 233 | + $state = 4; // go back to state 4 to fetch options |
|
| 234 | 234 | continue; |
| 235 | 235 | } |
| 236 | 236 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | public static function build($component, array $options = []): string |
| 271 | 271 | { |
| 272 | 272 | $ret = $component->type . ' '; |
| 273 | - if (! empty($component->name)) { |
|
| 273 | + if (!empty($component->name)) { |
|
| 274 | 274 | $ret .= Context::escape($component->name) . ' '; |
| 275 | 275 | } |
| 276 | 276 | |
@@ -300,23 +300,23 @@ discard block |
||
| 300 | 300 | $flags['distinct'] = true; |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | - if (! empty($statement->group) || ! empty($statement->having)) { |
|
| 303 | + if (!empty($statement->group) || !empty($statement->having)) { |
|
| 304 | 304 | $flags['is_group'] = true; |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - if (! empty($statement->into) && ($statement->into->type === 'OUTFILE')) { |
|
| 307 | + if (!empty($statement->into) && ($statement->into->type === 'OUTFILE')) { |
|
| 308 | 308 | $flags['is_export'] = true; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | $expressions = $statement->expr; |
| 312 | - if (! empty($statement->join)) { |
|
| 312 | + if (!empty($statement->join)) { |
|
| 313 | 313 | foreach ($statement->join as $join) { |
| 314 | 314 | $expressions[] = $join->expr; |
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | foreach ($expressions as $expr) { |
| 319 | - if (! empty($expr->function)) { |
|
| 319 | + if (!empty($expr->function)) { |
|
| 320 | 320 | if ($expr->function === 'COUNT') { |
| 321 | 321 | $flags['is_count'] = true; |
| 322 | 322 | } elseif (in_array($expr->function, static::$functions)) { |
@@ -331,15 +331,15 @@ discard block |
||
| 331 | 331 | $flags['is_subquery'] = true; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - if (! empty($statement->procedure) && ($statement->procedure->name === 'ANALYSE')) { |
|
| 334 | + if (!empty($statement->procedure) && ($statement->procedure->name === 'ANALYSE')) { |
|
| 335 | 335 | $flags['is_analyse'] = true; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - if (! empty($statement->group)) { |
|
| 338 | + if (!empty($statement->group)) { |
|
| 339 | 339 | $flags['group'] = true; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - if (! empty($statement->having)) { |
|
| 342 | + if (!empty($statement->having)) { |
|
| 343 | 343 | $flags['having'] = true; |
| 344 | 344 | } |
| 345 | 345 | |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | $flags['union'] = true; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - if (! empty($statement->join)) { |
|
| 350 | + if (!empty($statement->join)) { |
|
| 351 | 351 | $flags['join'] = true; |
| 352 | 352 | } |
| 353 | 353 | |
@@ -438,11 +438,11 @@ discard block |
||
| 438 | 438 | || ($statement instanceof UpdateStatement) |
| 439 | 439 | || ($statement instanceof DeleteStatement) |
| 440 | 440 | ) { |
| 441 | - if (! empty($statement->limit)) { |
|
| 441 | + if (!empty($statement->limit)) { |
|
| 442 | 442 | $flags['limit'] = true; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if (! empty($statement->order)) { |
|
| 445 | + if (!empty($statement->order)) { |
|
| 446 | 446 | $flags['order'] = true; |
| 447 | 447 | } |
| 448 | 448 | } |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | // Finding tables' aliases and their associated real names. |
| 493 | 493 | $tableAliases = []; |
| 494 | 494 | foreach ($statement->from as $expr) { |
| 495 | - if (! isset($expr->table, $expr->alias) || ($expr->table === '') || ($expr->alias === '')) { |
|
| 495 | + if (!isset($expr->table, $expr->alias) || ($expr->table === '') || ($expr->alias === '')) { |
|
| 496 | 496 | continue; |
| 497 | 497 | } |
| 498 | 498 | |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | ]; |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - if (! in_array($arr, $ret['select_tables'])) { |
|
| 520 | + if (!in_array($arr, $ret['select_tables'])) { |
|
| 521 | 521 | $ret['select_tables'][] = $arr; |
| 522 | 522 | } |
| 523 | 523 | } else { |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | // extracted from the FROM clause. |
| 531 | 531 | if (empty($ret['select_tables'])) { |
| 532 | 532 | foreach ($statement->from as $expr) { |
| 533 | - if (! isset($expr->table) || ($expr->table === '')) { |
|
| 533 | + if (!isset($expr->table) || ($expr->table === '')) { |
|
| 534 | 534 | continue; |
| 535 | 535 | } |
| 536 | 536 | |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | } elseif (($statement instanceof AlterStatement) || ($statement instanceof TruncateStatement)) { |
| 572 | 572 | $expressions = [$statement->table]; |
| 573 | 573 | } elseif ($statement instanceof DropStatement) { |
| 574 | - if (! $statement->options->has('TABLE')) { |
|
| 574 | + if (!$statement->options->has('TABLE')) { |
|
| 575 | 575 | // No tables are dropped. |
| 576 | 576 | return []; |
| 577 | 577 | } |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | |
| 850 | 850 | $statement .= $token->token; |
| 851 | 851 | |
| 852 | - if (($token->type === Token::TYPE_DELIMITER) && ! empty($token->token)) { |
|
| 852 | + if (($token->type === Token::TYPE_DELIMITER) && !empty($token->token)) { |
|
| 853 | 853 | $delimiter = $token->token; |
| 854 | 854 | $fullStatement = true; |
| 855 | 855 | break; |
@@ -858,7 +858,7 @@ discard block |
||
| 858 | 858 | |
| 859 | 859 | // No statement was found so we return the entire query as being the |
| 860 | 860 | // remaining part. |
| 861 | - if (! $fullStatement) { |
|
| 861 | + if (!$fullStatement) { |
|
| 862 | 862 | return [ |
| 863 | 863 | null, |
| 864 | 864 | $query, |
@@ -391,28 +391,28 @@ discard block |
||
| 391 | 391 | $expressions = $this->from; |
| 392 | 392 | |
| 393 | 393 | // Adding expressions from JOIN. |
| 394 | - if (! empty($this->join)) { |
|
| 394 | + if (!empty($this->join)) { |
|
| 395 | 395 | foreach ($this->join as $join) { |
| 396 | 396 | $expressions[] = $join->expr; |
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | foreach ($expressions as $expr) { |
| 401 | - if (! isset($expr->table) || ($expr->table === '')) { |
|
| 401 | + if (!isset($expr->table) || ($expr->table === '')) { |
|
| 402 | 402 | continue; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | $thisDb = isset($expr->database) && ($expr->database !== '') ? |
| 406 | 406 | $expr->database : $database; |
| 407 | 407 | |
| 408 | - if (! isset($retval[$thisDb])) { |
|
| 408 | + if (!isset($retval[$thisDb])) { |
|
| 409 | 409 | $retval[$thisDb] = [ |
| 410 | 410 | 'alias' => null, |
| 411 | 411 | 'tables' => [], |
| 412 | 412 | ]; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - if (! isset($retval[$thisDb]['tables'][$expr->table])) { |
|
| 415 | + if (!isset($retval[$thisDb]['tables'][$expr->table])) { |
|
| 416 | 416 | $retval[$thisDb]['tables'][$expr->table] = [ |
| 417 | 417 | 'alias' => isset($expr->alias) && ($expr->alias !== '') ? |
| 418 | 418 | $expr->alias : null, |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | ]; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - if (! isset($tables[$thisDb])) { |
|
| 423 | + if (!isset($tables[$thisDb])) { |
|
| 424 | 424 | $tables[$thisDb] = []; |
| 425 | 425 | } |
| 426 | 426 | |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | foreach ($this->expr as $expr) { |
| 431 | - if (! isset($expr->column, $expr->alias) || ($expr->column === '') || ($expr->alias === '')) { |
|
| 431 | + if (!isset($expr->column, $expr->alias) || ($expr->column === '') || ($expr->alias === '')) { |
|
| 432 | 432 | continue; |
| 433 | 433 | } |
| 434 | 434 | |