@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | ) { |
| 95 | 95 | $expr->type = $token->keyword; |
| 96 | 96 | } elseif (($token->type === Token::TYPE_OPERATOR) && ($token->value === ',')) { |
| 97 | - if (! empty($expr->expr)) { |
|
| 97 | + if (!empty($expr->expr)) { |
|
| 98 | 98 | $ret[] = $expr; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | // Last iteration was not processed. |
| 110 | - if (! empty($expr->expr)) { |
|
| 110 | + if (!empty($expr->expr)) { |
|
| 111 | 111 | $ret[] = $expr; |
| 112 | 112 | } |
| 113 | 113 | |
@@ -284,8 +284,8 @@ discard block |
||
| 284 | 284 | } elseif (($token->value === ',') && ($brackets === 0)) { |
| 285 | 285 | break; |
| 286 | 286 | } |
| 287 | - } elseif (! self::checkIfTokenQuotedSymbol($token)) { |
|
| 288 | - if (! empty(Parser::$STATEMENT_PARSERS[$token->value])) { |
|
| 287 | + } elseif (!self::checkIfTokenQuotedSymbol($token)) { |
|
| 288 | + if (!empty(Parser::$STATEMENT_PARSERS[$token->value])) { |
|
| 289 | 289 | // We want to get the next non-comment and non-space token after $token |
| 290 | 290 | // therefore, the first getNext call will start with the current $idx which's $token, |
| 291 | 291 | // will return it and increase $idx by 1, which's not guaranteed to be non-comment |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | } elseif ( |
| 319 | 319 | (array_key_exists($arrayKey, self::$DB_OPTIONS) |
| 320 | 320 | || array_key_exists($arrayKey, self::$TABLE_OPTIONS)) |
| 321 | - && ! self::checkIfColumnDefinitionKeyword($arrayKey) |
|
| 321 | + && !self::checkIfColumnDefinitionKeyword($arrayKey) |
|
| 322 | 322 | ) { |
| 323 | 323 | // This alter operation has finished, which means a comma |
| 324 | 324 | // was missing before start of new alter operation |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public static function getForeignKeys($statement) |
| 28 | 28 | { |
| 29 | - if (empty($statement->fields) || (! is_array($statement->fields)) || (! $statement->options->has('TABLE'))) { |
|
| 29 | + if (empty($statement->fields) || (!is_array($statement->fields)) || (!$statement->options->has('TABLE'))) { |
|
| 30 | 30 | return []; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $columns = []; |
| 41 | 41 | foreach ($field->key->columns as $column) { |
| 42 | - if (! isset($column['name'])) { |
|
| 42 | + if (!isset($column['name'])) { |
|
| 43 | 43 | continue; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | 'index_list' => $columns, |
| 52 | 52 | ]; |
| 53 | 53 | |
| 54 | - if (! empty($field->references)) { |
|
| 54 | + if (!empty($field->references)) { |
|
| 55 | 55 | $tmp['ref_db_name'] = $field->references->table->database; |
| 56 | 56 | $tmp['ref_table_name'] = $field->references->table->table; |
| 57 | 57 | $tmp['ref_index_list'] = $field->references->columns; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public static function getFields($statement) |
| 86 | 86 | { |
| 87 | - if (empty($statement->fields) || (! is_array($statement->fields)) || (! $statement->options->has('TABLE'))) { |
|
| 87 | + if (empty($statement->fields) || (!is_array($statement->fields)) || (!$statement->options->has('TABLE'))) { |
|
| 88 | 88 | return []; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | 'timestamp_not_null' => false, |
| 102 | 102 | ]; |
| 103 | 103 | |
| 104 | - if (! $field->options) { |
|
| 104 | + if (!$field->options) { |
|
| 105 | 105 | continue; |
| 106 | 106 | } |
| 107 | 107 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | $option = $field->options->has('AS'); |
| 130 | 130 | |
| 131 | - if (! $option) { |
|
| 131 | + if (!$option) { |
|
| 132 | 132 | continue; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -163,9 +163,9 @@ discard block |
||
| 163 | 163 | } elseif ($state === 1) { |
| 164 | 164 | if (($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) { |
| 165 | 165 | $positionBeforeSearch = $list->idx; |
| 166 | - $list->idx++;// Ignore the current token "(" or the search condition will always be true |
|
| 166 | + $list->idx++; // Ignore the current token "(" or the search condition will always be true |
|
| 167 | 167 | $nextToken = $list->getNext(); |
| 168 | - $list->idx = $positionBeforeSearch;// Restore the position |
|
| 168 | + $list->idx = $positionBeforeSearch; // Restore the position |
|
| 169 | 169 | |
| 170 | 170 | if ($nextToken !== null && $nextToken->value === '(') { |
| 171 | 171 | // Switch to expression mode |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $state = 3; |
| 183 | 183 | } elseif (($token->value === ',') || ($token->value === ')')) { |
| 184 | 184 | $state = $token->value === ',' ? 2 : 4; |
| 185 | - if (! empty($lastColumn)) { |
|
| 185 | + if (!empty($lastColumn)) { |
|
| 186 | 186 | $ret->columns[] = $lastColumn; |
| 187 | 187 | $lastColumn = []; |
| 188 | 188 | } |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | if ($token->type === Token::TYPE_OPERATOR) { |
| 215 | 215 | // This got back to here and we reached the end of the expression |
| 216 | 216 | if ($token->value === ')') { |
| 217 | - $state = 4;// go back to state 4 to fetch options |
|
| 217 | + $state = 4; // go back to state 4 to fetch options |
|
| 218 | 218 | continue; |
| 219 | 219 | } |
| 220 | 220 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | public static function build($component, array $options = []) |
| 257 | 257 | { |
| 258 | 258 | $ret = $component->type . ' '; |
| 259 | - if (! empty($component->name)) { |
|
| 259 | + if (!empty($component->name)) { |
|
| 260 | 260 | $ret .= Context::escape($component->name) . ' '; |
| 261 | 261 | } |
| 262 | 262 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | $this->byteIdx = 0; |
| 191 | 191 | $this->charIdx = 0; |
| 192 | 192 | $this->byteLen = mb_strlen($str, '8bit'); |
| 193 | - if (! mb_check_encoding($str, 'UTF-8')) { |
|
| 193 | + if (!mb_check_encoding($str, 'UTF-8')) { |
|
| 194 | 194 | $this->charLen = 0; |
| 195 | 195 | } else { |
| 196 | 196 | $this->charLen = mb_strlen($str, 'UTF-8'); |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | // Use the default ASCII map as queries are mostly ASCII chars |
| 299 | 299 | // ord($byte) has a performance cost |
| 300 | 300 | |
| 301 | - if (! isset(static::$asciiMap[$byte])) { |
|
| 301 | + if (!isset(static::$asciiMap[$byte])) { |
|
| 302 | 302 | // Complete the cache with missing items |
| 303 | 303 | static::$asciiMap[$byte] = ord($byte); |
| 304 | 304 | } |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | public function build() |
| 418 | 418 | { |
| 419 | 419 | $fields = ''; |
| 420 | - if (! empty($this->fields)) { |
|
| 420 | + if (!empty($this->fields)) { |
|
| 421 | 421 | if (is_array($this->fields)) { |
| 422 | 422 | $fields = CreateDefinition::build($this->fields) . ' '; |
| 423 | 423 | } elseif ($this->fields instanceof ArrayObj) { |
@@ -449,23 +449,23 @@ discard block |
||
| 449 | 449 | |
| 450 | 450 | $partition = ''; |
| 451 | 451 | |
| 452 | - if (! empty($this->partitionBy)) { |
|
| 452 | + if (!empty($this->partitionBy)) { |
|
| 453 | 453 | $partition .= "\nPARTITION BY " . $this->partitionBy; |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - if (! empty($this->partitionsNum)) { |
|
| 456 | + if (!empty($this->partitionsNum)) { |
|
| 457 | 457 | $partition .= "\nPARTITIONS " . $this->partitionsNum; |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - if (! empty($this->subpartitionBy)) { |
|
| 460 | + if (!empty($this->subpartitionBy)) { |
|
| 461 | 461 | $partition .= "\nSUBPARTITION BY " . $this->subpartitionBy; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - if (! empty($this->subpartitionsNum)) { |
|
| 464 | + if (!empty($this->subpartitionsNum)) { |
|
| 465 | 465 | $partition .= "\nSUBPARTITIONS " . $this->subpartitionsNum; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - if (! empty($this->partitions)) { |
|
| 468 | + if (!empty($this->partitions)) { |
|
| 469 | 469 | $partition .= "\n" . PartitionDefinition::build($this->partitions); |
| 470 | 470 | } |
| 471 | 471 | |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | . OptionsArray::build($this->options) . ' ' |
| 488 | 488 | . Expression::build($this->name) . ' ' |
| 489 | 489 | . $fields . ' AS ' . $builtStatement |
| 490 | - . (! empty($this->body) ? TokensList::build($this->body) : '') . ' ' |
|
| 490 | + . (!empty($this->body) ? TokensList::build($this->body) : '') . ' ' |
|
| 491 | 491 | . OptionsArray::build($this->entityOptions); |
| 492 | 492 | } elseif ($this->options->has('TRIGGER')) { |
| 493 | 493 | return 'CREATE ' |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | ] |
| 542 | 542 | ); |
| 543 | 543 | |
| 544 | - if (! isset($this->name) || ($this->name === '')) { |
|
| 544 | + if (!isset($this->name) || ($this->name === '')) { |
|
| 545 | 545 | $parser->error('The name of the entity was expected.', $list->tokens[$list->idx]); |
| 546 | 546 | } else { |
| 547 | 547 | ++$list->idx; // Skipping field. |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | $token = $list->getNextOfType(Token::TYPE_NUMBER); |
| 658 | 658 | --$list->idx; // `getNextOfType` also advances one position. |
| 659 | 659 | $this->subpartitionsNum = $token->value; |
| 660 | - } elseif (! empty($field)) { |
|
| 660 | + } elseif (!empty($field)) { |
|
| 661 | 661 | /* |
| 662 | 662 | * Handling the content of `PARTITION BY` and `SUBPARTITION BY`. |
| 663 | 663 | */ |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | $field = null; |
| 687 | 687 | } |
| 688 | 688 | } elseif (($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) { |
| 689 | - if (! empty($this->partitionBy)) { |
|
| 689 | + if (!empty($this->partitionBy)) { |
|
| 690 | 690 | $this->partitions = ArrayObj::parse( |
| 691 | 691 | $parser, |
| 692 | 692 | $list, |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | break; |
| 128 | 128 | } |
| 129 | 129 | } elseif ($state === 2) { |
| 130 | - if (! ($token->type === Token::TYPE_KEYWORD && $token->keyword === 'AS')) { |
|
| 130 | + if (!($token->type === Token::TYPE_KEYWORD && $token->keyword === 'AS')) { |
|
| 131 | 131 | $parser->error('AS keyword was expected.', $token); |
| 132 | 132 | break; |
| 133 | 133 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | $list->getNext(); |
| 144 | 144 | $nextKeyword = $list->getNext(); |
| 145 | 145 | |
| 146 | - if (! ($token->value === '(' && ($nextKeyword && $nextKeyword->value === 'SELECT'))) { |
|
| 146 | + if (!($token->value === '(' && ($nextKeyword && $nextKeyword->value === 'SELECT'))) { |
|
| 147 | 147 | $parser->error('Subquery of the CTE was expected.', $token); |
| 148 | 148 | $list->idx = $idxBeforeGetNext; |
| 149 | 149 | break; |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | ++$list->idx; |
| 286 | - if (! isset($list->tokens[$list->idx])) { |
|
| 286 | + if (!isset($list->tokens[$list->idx])) { |
|
| 287 | 287 | break; |
| 288 | 288 | } |
| 289 | 289 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | // The code below extracts only the relevant information. |
| 83 | 83 | |
| 84 | 84 | // Extracting lexer's errors. |
| 85 | - if (! empty($lexer->errors)) { |
|
| 85 | + if (!empty($lexer->errors)) { |
|
| 86 | 86 | /** @var LexerException $err */ |
| 87 | 87 | foreach ($lexer->errors as $err) { |
| 88 | 88 | $lexerErrors[] = [ |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // Extracting parser's errors. |
| 100 | - if (! empty($parser->errors)) { |
|
| 100 | + if (!empty($parser->errors)) { |
|
| 101 | 101 | /** @var ParserException $err */ |
| 102 | 102 | foreach ($parser->errors as $err) { |
| 103 | 103 | $parserErrors[] = [ |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | public static function build($type, $input, $output, $debug = null, $ansi = false) |
| 138 | 138 | { |
| 139 | 139 | // Support query types: `lexer` / `parser`. |
| 140 | - if (! in_array($type, ['lexer', 'parser'])) { |
|
| 140 | + if (!in_array($type, ['lexer', 'parser'])) { |
|
| 141 | 141 | throw new Exception('Unknown test type (expected `lexer` or `parser`).'); |
| 142 | 142 | } |
| 143 | 143 | |
@@ -223,11 +223,11 @@ discard block |
||
| 223 | 223 | if (is_dir($inputFile)) { |
| 224 | 224 | // Creating required directories to maintain the structure. |
| 225 | 225 | // Ignoring errors if the folder structure exists already. |
| 226 | - if (! is_dir($outputFile)) { |
|
| 226 | + if (!is_dir($outputFile)) { |
|
| 227 | 227 | mkdir($outputFile); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - if (($debug !== null) && (! is_dir($debugFile))) { |
|
| 230 | + if (($debug !== null) && (!is_dir($debugFile))) { |
|
| 231 | 231 | mkdir($debugFile); |
| 232 | 232 | } |
| 233 | 233 | |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | // Building the test. |
| 245 | - if (! file_exists($outputFile)) { |
|
| 245 | + if (!file_exists($outputFile)) { |
|
| 246 | 246 | echo sprintf("Building test for %s...\n", $inputFile); |
| 247 | 247 | static::build( |
| 248 | 248 | str_contains($inputFile, 'lex') ? 'lexer' : 'parser', |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | } else { |
| 490 | 490 | // Checking if it is a known statement that can be parsed. |
| 491 | 491 | if (empty(static::$STATEMENT_PARSERS[$token->keyword])) { |
| 492 | - if (! isset(static::$STATEMENT_PARSERS[$token->keyword])) { |
|
| 492 | + if (!isset(static::$STATEMENT_PARSERS[$token->keyword])) { |
|
| 493 | 493 | // A statement is considered recognized if the parser |
| 494 | 494 | // is aware that it is a statement, but it does not have |
| 495 | 495 | // a parser for it yet. |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | |
| 531 | 531 | // Handles unions. |
| 532 | 532 | if ( |
| 533 | - ! empty($unionType) |
|
| 533 | + !empty($unionType) |
|
| 534 | 534 | && ($lastStatement instanceof SelectStatement) |
| 535 | 535 | && ($statement instanceof SelectStatement) |
| 536 | 536 | ) { |