Completed
Push — master ( c8a83a...930656 )
by William
17s queued 15s
created
src/Utils/Table.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
128 128
 
129 129
             $option = $field->options->has('AS');
130 130
 
131
-            if (! $option) {
131
+            if (!$option) {
132 132
                 continue;
133 133
             }
134 134
 
Please login to merge, or discard this patch.
src/Components/Key.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/UtfString.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Statements/CreateStatement.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,
Please login to merge, or discard this patch.
src/Statements/WithStatement.php 2 patches
Indentation   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,7 +22,6 @@  discard block
 block discarded – undo
22 22
 
23 23
 /**
24 24
  * `WITH` statement.
25
-
26 25
  *  WITH [RECURSIVE] query_name [ (column_name [,...]) ] AS (SELECT ...) [, ...]
27 26
  */
28 27
 final class WithStatement extends Statement
@@ -263,9 +262,9 @@  discard block
 block discarded – undo
263 262
 
264 263
         // 5 is the only valid end state
265 264
         if ($state !== 5) {
266
-             /**
267
-             * Token parsed at this moment.
268
-             */
265
+                /**
266
+                 * Token parsed at this moment.
267
+                 */
269 268
             $token = $list->tokens[$list->idx];
270 269
 
271 270
             $parser->error('Unexpected end of the WITH CTE.', $token);
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
                     break;
134 134
                 }
135 135
             } elseif ($state === 2) {
136
-                if (! ($token->type === Token::TYPE_KEYWORD && $token->keyword === 'AS')) {
136
+                if (!($token->type === Token::TYPE_KEYWORD && $token->keyword === 'AS')) {
137 137
                     $parser->error('AS keyword was expected.', $token);
138 138
                     break;
139 139
                 }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                 $list->idx++; // Ignore the current token
146 146
                 $nextKeyword = $list->getNext();
147 147
 
148
-                if (! ($token->value === '(' && ($nextKeyword && $nextKeyword->value === 'SELECT'))) {
148
+                if (!($token->value === '(' && ($nextKeyword && $nextKeyword->value === 'SELECT'))) {
149 149
                     $parser->error('Subquery of the CTE was expected.', $token);
150 150
                     $list->idx = $idxBeforeGetNext;
151 151
                     break;
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
             }
314 314
 
315 315
             ++$list->idx;
316
-            if (! isset($list->tokens[$list->idx])) {
316
+            if (!isset($list->tokens[$list->idx])) {
317 317
                 break;
318 318
             }
319 319
 
Please login to merge, or discard this patch.
src/Tools/TestGenerator.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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',
Please login to merge, or discard this patch.
src/Parser.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
             ) {
Please login to merge, or discard this patch.
src/Lexer.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 use function strlen;
16 16
 use function substr;
17 17
 
18
-if (! defined('USE_UTF_STRINGS')) {
18
+if (!defined('USE_UTF_STRINGS')) {
19 19
     // NOTE: In previous versions of PHP (5.5 and older) the default
20 20
     // internal encoding is "ISO-8859-1".
21 21
     // All `mb_` functions must specify the correct encoding, which is
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 
200 200
         // For multi-byte strings, a new instance of `UtfString` is
201 201
         // initialized (only if `UtfString` usage is forced.
202
-        if (! $str instanceof UtfString && USE_UTF_STRINGS && $len !== mb_strlen($str, 'UTF-8')) {
202
+        if (!$str instanceof UtfString && USE_UTF_STRINGS && $len !== mb_strlen($str, 'UTF-8')) {
203 203
             $str = new UtfString($str);
204 204
         }
205 205
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         $this->strict = $strict;
210 210
 
211 211
         // Setting the delimiter.
212
-        $this->setDelimiter(! empty($delimiter) ? $delimiter : static::$DEFAULT_DELIMITER);
212
+        $this->setDelimiter(!empty($delimiter) ? $delimiter : static::$DEFAULT_DELIMITER);
213 213
 
214 214
         $this->lex();
215 215
     }
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
                 $delimiterLen = 0;
338 338
                 while (
339 339
                     ++$this->last < $this->len
340
-                    && ! Context::isWhitespace($this->str[$this->last])
340
+                    && !Context::isWhitespace($this->str[$this->last])
341 341
                     && $delimiterLen < 15
342 342
                 ) {
343 343
                     $this->delimiter .= $this->str[$this->last];
@@ -396,8 +396,8 @@  discard block
 block discarded – undo
396 396
             }
397 397
 
398 398
             if (
399
-                ($next->type !== Token::TYPE_KEYWORD || ! in_array($next->value, ['FROM', 'USING'], true))
400
-                && ($next->type !== Token::TYPE_OPERATOR || ! in_array($next->value, [',', ')'], true))
399
+                ($next->type !== Token::TYPE_KEYWORD || !in_array($next->value, ['FROM', 'USING'], true))
400
+                && ($next->type !== Token::TYPE_OPERATOR || !in_array($next->value, [',', ')'], true))
401 401
             ) {
402 402
                 continue;
403 403
             }
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
             $next = $this->list->getNext();
436 436
             if (
437 437
                 ($next->type !== Token::TYPE_KEYWORD
438
-                    || ! in_array($next->value, $this->KEYWORD_NAME_INDICATORS, true)
438
+                    || !in_array($next->value, $this->KEYWORD_NAME_INDICATORS, true)
439 439
                 )
440 440
                 && ($next->type !== Token::TYPE_OPERATOR
441
-                    || ! in_array($next->value, $this->OPERATOR_NAME_INDICATORS, true)
441
+                    || !in_array($next->value, $this->OPERATOR_NAME_INDICATORS, true)
442 442
                 )
443 443
                 && ($next->value !== null)
444 444
             ) {
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
             $token .= $this->str[$this->last];
522 522
             $flags = Context::isKeyword($token);
523 523
 
524
-            if (($this->last + 1 !== $this->len && ! Context::isSeparator($this->str[$this->last + 1])) || ! $flags) {
524
+            if (($this->last + 1 !== $this->len && !Context::isSeparator($this->str[$this->last + 1])) || !$flags) {
525 525
                 continue;
526 526
             }
527 527
 
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
             $token .= $this->str[$this->last];
610 610
             $flags = Context::isOperator($token);
611 611
 
612
-            if (! $flags) {
612
+            if (!$flags) {
613 613
                 continue;
614 614
             }
615 615
 
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
     {
632 632
         $token = $this->str[$this->last];
633 633
 
634
-        if (! Context::isWhitespace($token)) {
634
+        if (!Context::isWhitespace($token)) {
635 635
             return null;
636 636
         }
637 637
 
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
             } elseif ($state === 2) {
872 872
                 $flags |= Token::FLAG_NUMBER_HEX;
873 873
                 if (
874
-                    ! (
874
+                    !(
875 875
                         ($this->str[$this->last] >= '0' && $this->str[$this->last] <= '9')
876 876
                         || ($this->str[$this->last] >= 'A' && $this->str[$this->last] <= 'F')
877 877
                         || ($this->str[$this->last] >= 'a' && $this->str[$this->last] <= 'f')
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
         $token = $this->str[$this->last];
975 975
         $flags = Context::isString($token);
976 976
 
977
-        if (! $flags && $token !== $quote) {
977
+        if (!$flags && $token !== $quote) {
978 978
             return null;
979 979
         }
980 980
 
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
         $token = $this->str[$this->last];
1027 1027
         $flags = Context::isSymbol($token);
1028 1028
 
1029
-        if (! $flags) {
1029
+        if (!$flags) {
1030 1030
             return null;
1031 1031
         }
1032 1032
 
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
             return null;
1078 1078
         }
1079 1079
 
1080
-        while (++$this->last < $this->len && ! Context::isSeparator($this->str[$this->last])) {
1080
+        while (++$this->last < $this->len && !Context::isSeparator($this->str[$this->last])) {
1081 1081
             $token .= $this->str[$this->last];
1082 1082
 
1083 1083
             // Test if end of token equals the current delimiter. If so, remove it from the token.
Please login to merge, or discard this patch.
tests/Tools/ContextGeneratorTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
         $this->assertEquals([
43 43
             Token::TYPE_KEYWORD | Token::FLAG_KEYWORD_RESERVED => [
44 44
                 8 => ['RESERVED'],
45
-                9 => ['RESERVED2','RESERVED3','RESERVED4','RESERVED5'],
45
+                9 => ['RESERVED2', 'RESERVED3', 'RESERVED4', 'RESERVED5'],
46 46
             ],
47 47
             Token::TYPE_KEYWORD | Token::FLAG_KEYWORD_FUNCTION => [8 => ['FUNCTION']],
48 48
             Token::TYPE_KEYWORD | Token::FLAG_KEYWORD_DATA_TYPE => [8 => ['DATATYPE']],
Please login to merge, or discard this patch.