@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public static function getAliases($statement, $database) |
27 | 27 | { |
28 | - if (! ($statement instanceof SelectStatement) || empty($statement->expr) || empty($statement->from)) { |
|
28 | + if (!($statement instanceof SelectStatement) || empty($statement->expr) || empty($statement->from)) { |
|
29 | 29 | return []; |
30 | 30 | } |
31 | 31 | |
@@ -42,28 +42,28 @@ discard block |
||
42 | 42 | $expressions = $statement->from; |
43 | 43 | |
44 | 44 | // Adding expressions from JOIN. |
45 | - if (! empty($statement->join)) { |
|
45 | + if (!empty($statement->join)) { |
|
46 | 46 | foreach ($statement->join as $join) { |
47 | 47 | $expressions[] = $join->expr; |
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | 51 | foreach ($expressions as $expr) { |
52 | - if (! isset($expr->table) || ($expr->table === '')) { |
|
52 | + if (!isset($expr->table) || ($expr->table === '')) { |
|
53 | 53 | continue; |
54 | 54 | } |
55 | 55 | |
56 | 56 | $thisDb = isset($expr->database) && ($expr->database !== '') ? |
57 | 57 | $expr->database : $database; |
58 | 58 | |
59 | - if (! isset($retval[$thisDb])) { |
|
59 | + if (!isset($retval[$thisDb])) { |
|
60 | 60 | $retval[$thisDb] = [ |
61 | 61 | 'alias' => null, |
62 | 62 | 'tables' => [], |
63 | 63 | ]; |
64 | 64 | } |
65 | 65 | |
66 | - if (! isset($retval[$thisDb]['tables'][$expr->table])) { |
|
66 | + if (!isset($retval[$thisDb]['tables'][$expr->table])) { |
|
67 | 67 | $retval[$thisDb]['tables'][$expr->table] = [ |
68 | 68 | 'alias' => isset($expr->alias) && ($expr->alias !== '') ? |
69 | 69 | $expr->alias : null, |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | ]; |
72 | 72 | } |
73 | 73 | |
74 | - if (! isset($tables[$thisDb])) { |
|
74 | + if (!isset($tables[$thisDb])) { |
|
75 | 75 | $tables[$thisDb] = []; |
76 | 76 | } |
77 | 77 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | foreach ($statement->expr as $expr) { |
82 | - if (! isset($expr->column, $expr->alias) || ($expr->column === '') || ($expr->alias === '')) { |
|
82 | + if (!isset($expr->column, $expr->alias) || ($expr->column === '') || ($expr->alias === '')) { |
|
83 | 83 | continue; |
84 | 84 | } |
85 | 85 |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | |
471 | 471 | // Checking if it is a known statement that can be parsed. |
472 | 472 | if (empty(static::$STATEMENT_PARSERS[$token->keyword])) { |
473 | - if (! isset(static::$STATEMENT_PARSERS[$token->keyword])) { |
|
473 | + if (!isset(static::$STATEMENT_PARSERS[$token->keyword])) { |
|
474 | 474 | // A statement is considered recognized if the parser |
475 | 475 | // is aware that it is a statement, but it does not have |
476 | 476 | // a parser for it yet. |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | |
511 | 511 | // Handles unions. |
512 | 512 | if ( |
513 | - ! empty($unionType) |
|
513 | + !empty($unionType) |
|
514 | 514 | && ($lastStatement instanceof SelectStatement) |
515 | 515 | && ($statement instanceof SelectStatement) |
516 | 516 | ) { |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | switch ($this->type) { |
223 | 223 | case self::TYPE_KEYWORD: |
224 | 224 | $this->keyword = strtoupper($this->token); |
225 | - if (! ($this->flags & self::FLAG_KEYWORD_RESERVED)) { |
|
225 | + if (!($this->flags & self::FLAG_KEYWORD_RESERVED)) { |
|
226 | 226 | // Unreserved keywords should stay the way they are because they |
227 | 227 | // might represent field names. |
228 | 228 | return $this->token; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | } |
248 | 248 | } elseif (($this->flags & self::FLAG_NUMBER_APPROXIMATE) || ($this->flags & self::FLAG_NUMBER_FLOAT)) { |
249 | 249 | $ret = (float) $ret; |
250 | - } elseif (! ($this->flags & self::FLAG_NUMBER_BINARY)) { |
|
250 | + } elseif (!($this->flags & self::FLAG_NUMBER_BINARY)) { |
|
251 | 251 | $ret = (int) $ret; |
252 | 252 | } |
253 | 253 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | // in PHP 5.3- the `null` parameter isn't handled correctly. |
283 | 283 | $str = mb_substr( |
284 | 284 | $str, |
285 | - ! empty($str[1]) && ($str[1] === '@') ? 2 : 1, |
|
285 | + !empty($str[1]) && ($str[1] === '@') ? 2 : 1, |
|
286 | 286 | mb_strlen($str), |
287 | 287 | 'UTF-8' |
288 | 288 | ); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | use function strlen; |
22 | 22 | use function substr; |
23 | 23 | |
24 | -if (! defined('USE_UTF_STRINGS')) { |
|
24 | +if (!defined('USE_UTF_STRINGS')) { |
|
25 | 25 | // NOTE: In previous versions of PHP (5.5 and older) the default |
26 | 26 | // internal encoding is "ISO-8859-1". |
27 | 27 | // All `mb_` functions must specify the correct encoding, which is |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | // For multi-byte strings, a new instance of `UtfString` is |
178 | 178 | // initialized (only if `UtfString` usage is forced. |
179 | - if (! $str instanceof UtfString && USE_UTF_STRINGS && $len !== mb_strlen($str, 'UTF-8')) { |
|
179 | + if (!$str instanceof UtfString && USE_UTF_STRINGS && $len !== mb_strlen($str, 'UTF-8')) { |
|
180 | 180 | $str = new UtfString($str); |
181 | 181 | } |
182 | 182 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $this->strict = $strict; |
187 | 187 | |
188 | 188 | // Setting the delimiter. |
189 | - $this->setDelimiter(! empty($delimiter) ? $delimiter : static::$DEFAULT_DELIMITER); |
|
189 | + $this->setDelimiter(!empty($delimiter) ? $delimiter : static::$DEFAULT_DELIMITER); |
|
190 | 190 | |
191 | 191 | $this->lex(); |
192 | 192 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $delimiterLen = 0; |
311 | 311 | while ( |
312 | 312 | ++$this->last < $this->len |
313 | - && ! Context::isWhitespace($this->str[$this->last]) |
|
313 | + && !Context::isWhitespace($this->str[$this->last]) |
|
314 | 314 | && $delimiterLen < 15 |
315 | 315 | ) { |
316 | 316 | $this->delimiter .= $this->str[$this->last]; |
@@ -370,8 +370,8 @@ discard block |
||
370 | 370 | } |
371 | 371 | |
372 | 372 | if ( |
373 | - ($next->type !== Token::TYPE_KEYWORD || ! in_array($next->value, ['FROM', 'USING'], true)) |
|
374 | - && ($next->type !== Token::TYPE_OPERATOR || ! in_array($next->value, [',', ')'], true)) |
|
373 | + ($next->type !== Token::TYPE_KEYWORD || !in_array($next->value, ['FROM', 'USING'], true)) |
|
374 | + && ($next->type !== Token::TYPE_OPERATOR || !in_array($next->value, [',', ')'], true)) |
|
375 | 375 | ) { |
376 | 376 | continue; |
377 | 377 | } |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | $token .= $this->str[$this->last]; |
451 | 451 | $flags = Context::isKeyword($token); |
452 | 452 | |
453 | - if (($this->last + 1 !== $this->len && ! Context::isSeparator($this->str[$this->last + 1])) || ! $flags) { |
|
453 | + if (($this->last + 1 !== $this->len && !Context::isSeparator($this->str[$this->last + 1])) || !$flags) { |
|
454 | 454 | continue; |
455 | 455 | } |
456 | 456 | |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | $token .= $this->str[$this->last]; |
543 | 543 | $flags = Context::isOperator($token); |
544 | 544 | |
545 | - if (! $flags) { |
|
545 | + if (!$flags) { |
|
546 | 546 | continue; |
547 | 547 | } |
548 | 548 | |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | { |
565 | 565 | $token = $this->str[$this->last]; |
566 | 566 | |
567 | - if (! Context::isWhitespace($token)) { |
|
567 | + if (!Context::isWhitespace($token)) { |
|
568 | 568 | return null; |
569 | 569 | } |
570 | 570 | |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | } elseif ($state === 2) { |
805 | 805 | $flags |= Token::FLAG_NUMBER_HEX; |
806 | 806 | if ( |
807 | - ! ( |
|
807 | + !( |
|
808 | 808 | ($this->str[$this->last] >= '0' && $this->str[$this->last] <= '9') |
809 | 809 | || ($this->str[$this->last] >= 'A' && $this->str[$this->last] <= 'F') |
810 | 810 | || ($this->str[$this->last] >= 'a' && $this->str[$this->last] <= 'f') |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | $token = $this->str[$this->last]; |
908 | 908 | $flags = Context::isString($token); |
909 | 909 | |
910 | - if (! $flags && $token !== $quote) { |
|
910 | + if (!$flags && $token !== $quote) { |
|
911 | 911 | return null; |
912 | 912 | } |
913 | 913 | |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | $token = $this->str[$this->last]; |
960 | 960 | $flags = Context::isSymbol($token); |
961 | 961 | |
962 | - if (! $flags) { |
|
962 | + if (!$flags) { |
|
963 | 963 | return null; |
964 | 964 | } |
965 | 965 | |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | return null; |
1011 | 1011 | } |
1012 | 1012 | |
1013 | - while (++$this->last < $this->len && ! Context::isSeparator($this->str[$this->last])) { |
|
1013 | + while (++$this->last < $this->len && !Context::isSeparator($this->str[$this->last])) { |
|
1014 | 1014 | $token .= $this->str[$this->last]; |
1015 | 1015 | |
1016 | 1016 | // Test if end of token equals the current delimiter. If so, remove it from the token. |
@@ -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 |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | public function build() |
377 | 377 | { |
378 | 378 | $fields = ''; |
379 | - if (! empty($this->fields)) { |
|
379 | + if (!empty($this->fields)) { |
|
380 | 380 | if (is_array($this->fields)) { |
381 | 381 | $fields = CreateDefinition::build($this->fields) . ' '; |
382 | 382 | } elseif ($this->fields instanceof ArrayObj) { |
@@ -408,23 +408,23 @@ discard block |
||
408 | 408 | |
409 | 409 | $partition = ''; |
410 | 410 | |
411 | - if (! empty($this->partitionBy)) { |
|
411 | + if (!empty($this->partitionBy)) { |
|
412 | 412 | $partition .= "\nPARTITION BY " . $this->partitionBy; |
413 | 413 | } |
414 | 414 | |
415 | - if (! empty($this->partitionsNum)) { |
|
415 | + if (!empty($this->partitionsNum)) { |
|
416 | 416 | $partition .= "\nPARTITIONS " . $this->partitionsNum; |
417 | 417 | } |
418 | 418 | |
419 | - if (! empty($this->subpartitionBy)) { |
|
419 | + if (!empty($this->subpartitionBy)) { |
|
420 | 420 | $partition .= "\nSUBPARTITION BY " . $this->subpartitionBy; |
421 | 421 | } |
422 | 422 | |
423 | - if (! empty($this->subpartitionsNum)) { |
|
423 | + if (!empty($this->subpartitionsNum)) { |
|
424 | 424 | $partition .= "\nSUBPARTITIONS " . $this->subpartitionsNum; |
425 | 425 | } |
426 | 426 | |
427 | - if (! empty($this->partitions)) { |
|
427 | + if (!empty($this->partitions)) { |
|
428 | 428 | $partition .= "\n" . PartitionDefinition::build($this->partitions); |
429 | 429 | } |
430 | 430 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | . OptionsArray::build($this->options) . ' ' |
440 | 440 | . Expression::build($this->name) . ' ' |
441 | 441 | . $fields . ' AS ' . ($this->select ? $this->select->build() : '') |
442 | - . (! empty($this->body) ? TokensList::build($this->body) : '') . ' ' |
|
442 | + . (!empty($this->body) ? TokensList::build($this->body) : '') . ' ' |
|
443 | 443 | . OptionsArray::build($this->entityOptions); |
444 | 444 | } elseif ($this->options->has('TRIGGER')) { |
445 | 445 | return 'CREATE ' |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | ] |
493 | 493 | ); |
494 | 494 | |
495 | - if (! isset($this->name) || ($this->name === '')) { |
|
495 | + if (!isset($this->name) || ($this->name === '')) { |
|
496 | 496 | $parser->error('The name of the entity was expected.', $list->tokens[$list->idx]); |
497 | 497 | } else { |
498 | 498 | ++$list->idx; // Skipping field. |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | $token = $list->getNextOfType(Token::TYPE_NUMBER); |
601 | 601 | --$list->idx; // `getNextOfType` also advances one position. |
602 | 602 | $this->subpartitionsNum = $token->value; |
603 | - } elseif (! empty($field)) { |
|
603 | + } elseif (!empty($field)) { |
|
604 | 604 | /* |
605 | 605 | * Handling the content of `PARTITION BY` and `SUBPARTITION BY`. |
606 | 606 | */ |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | $field = null; |
630 | 630 | } |
631 | 631 | } elseif (($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) { |
632 | - if (! empty($this->partitionBy)) { |
|
632 | + if (!empty($this->partitionBy)) { |
|
633 | 633 | $this->partitions = ArrayObj::parse( |
634 | 634 | $parser, |
635 | 635 | $list, |
@@ -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 |