Passed
Push — master ( de2d27...d28f1e )
by Maurício
10:00 queued 06:30
created
src/TokensList.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      * Gets the next token. Skips any irrelevant token (whitespaces and
79 79
      * comments).
80 80
      */
81
-    public function getNext(): Token|null
81
+    public function getNext(): Token | null
82 82
     {
83 83
         for (; $this->idx < $this->count; ++$this->idx) {
84 84
             if (
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      * Gets the previous token. Skips any irrelevant token (whitespaces and
97 97
      * comments).
98 98
      */
99
-    public function getPrevious(): Token|null
99
+    public function getPrevious(): Token | null
100 100
     {
101 101
         for (; $this->idx >= 0; --$this->idx) {
102 102
             if (
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
      *
116 116
      * @param TokenType|TokenType[] $type the type
117 117
      */
118
-    public function getPreviousOfType(TokenType|array $type): Token|null
118
+    public function getPreviousOfType(TokenType | array $type): Token | null
119 119
     {
120
-        if (! is_array($type)) {
120
+        if (!is_array($type)) {
121 121
             $type = [$type];
122 122
         }
123 123
 
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
      *
136 136
      * @param TokenType|TokenType[] $type the type
137 137
      */
138
-    public function getNextOfType(TokenType|array $type): Token|null
138
+    public function getNextOfType(TokenType | array $type): Token | null
139 139
     {
140
-        if (! is_array($type)) {
140
+        if (!is_array($type)) {
141 141
             $type = [$type];
142 142
         }
143 143
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      * @param TokenType $type  the type of the token
157 157
      * @param string    $value the value of the token
158 158
      */
159
-    public function getNextOfTypeAndValue(TokenType $type, string $value): Token|null
159
+    public function getNextOfTypeAndValue(TokenType $type, string $value): Token | null
160 160
     {
161 161
         for (; $this->idx < $this->count; ++$this->idx) {
162 162
             if (($this->tokens[$this->idx]->type === $type) && ($this->tokens[$this->idx]->value === $value)) {
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
      * @param TokenType $type the type of the token
174 174
      * @param int       $flag the flag of the token
175 175
      */
176
-    public function getNextOfTypeAndFlag(TokenType $type, int $flag): Token|null
176
+    public function getNextOfTypeAndFlag(TokenType $type, int $flag): Token | null
177 177
     {
178 178
         for (; $this->idx < $this->count; ++$this->idx) {
179 179
             if (($this->tokens[$this->idx]->type === $type) && ($this->tokens[$this->idx]->flags === $flag)) {
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
      *
205 205
      * @param int $offset the offset to be returned
206 206
      */
207
-    public function offsetGet(mixed $offset): Token|null
207
+    public function offsetGet(mixed $offset): Token | null
208 208
     {
209 209
         return $offset < $this->count ? $this->tokens[$offset] : null;
210 210
     }
Please login to merge, or discard this patch.
src/Tools/ContextGenerator.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
             // Reserved, data types, keys, functions, etc. keywords.
172 172
             foreach (static::$labelsFlags as $label => $flags) {
173
-                if (! str_contains($value, $label)) {
173
+                if (!str_contains($value, $label)) {
174 174
                     continue;
175 175
                 }
176 176
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
             }
191 191
 
192 192
             $value = strtoupper($value);
193
-            if (! isset($types[$value])) {
193
+            if (!isset($types[$value])) {
194 194
                 $types[$value] = $type;
195 195
             } else {
196 196
                 $types[$value] |= $type;
@@ -200,11 +200,11 @@  discard block
 block discarded – undo
200 200
         $ret = [];
201 201
         foreach ($types as $word => $type) {
202 202
             $len = strlen($word);
203
-            if (! isset($ret[$type])) {
203
+            if (!isset($ret[$type])) {
204 204
                 $ret[$type] = [];
205 205
             }
206 206
 
207
-            if (! isset($ret[$type][$len])) {
207
+            if (!isset($ret[$type][$len])) {
208 208
                 $ret[$type][$len] = [];
209 209
             }
210 210
 
Please login to merge, or discard this patch.
src/Tools/TestGenerator.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         // The code below extracts only the relevant information.
84 84
 
85 85
         // Extracting lexer's errors.
86
-        if (! empty($lexer->errors)) {
86
+        if (!empty($lexer->errors)) {
87 87
             /** @var LexerException $err */
88 88
             foreach ($lexer->errors as $err) {
89 89
                 $lexerErrors[] = [
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         }
99 99
 
100 100
         // Extracting parser's errors.
101
-        if (! empty($parser->errors)) {
101
+        if (!empty($parser->errors)) {
102 102
             /** @var ParserException $err */
103 103
             foreach ($parser->errors as $err) {
104 104
                 $parserErrors[] = [
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
         string $type,
138 138
         string $input,
139 139
         string $output,
140
-        string|null $debug = null,
140
+        string | null $debug = null,
141 141
         bool $ansi = false,
142 142
     ): void {
143 143
         // Support query types: `lexer` / `parser`.
144
-        if (! in_array($type, ['lexer', 'parser'])) {
144
+        if (!in_array($type, ['lexer', 'parser'])) {
145 145
             throw new Exception('Unknown test type (expected `lexer` or `parser`).');
146 146
         }
147 147
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         );
187 187
 
188 188
         // Remove the project path from .out file, it changes for each dev
189
-        $projectFolder = dirname(__DIR__, 2);// Jump to root
189
+        $projectFolder = dirname(__DIR__, 2); // Jump to root
190 190
         $encoded = str_replace($projectFolder, '<project-root>', $encoded);
191 191
 
192 192
         file_put_contents($output, $encoded);
@@ -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/Utils/CLI.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     {
37 37
         foreach ($longopts as $value) {
38 38
             $value = rtrim($value, ':');
39
-            if (! isset($params[$value])) {
39
+            if (!isset($params[$value])) {
40 40
                 continue;
41 41
             }
42 42
 
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
      *
56 56
      * @return string[]|false[]|false
57 57
      */
58
-    public function getopt(string $opt, array $long): array|false
58
+    public function getopt(string $opt, array $long): array | false
59 59
     {
60 60
         return getopt($opt, $long);
61 61
     }
62 62
 
63 63
     /** @return string[]|false[]|false */
64
-    public function parseHighlight(): array|false
64
+    public function parseHighlight(): array | false
65 65
     {
66 66
         $longopts = [
67 67
             'help',
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
         }
76 76
 
77 77
         $this->mergeLongOpts($params, $longopts);
78
-        if (! isset($params['f'])) {
78
+        if (!isset($params['f'])) {
79 79
             $params['f'] = 'cli';
80 80
         }
81 81
 
82
-        if (! in_array($params['f'], ['html', 'cli', 'text'])) {
82
+        if (!in_array($params['f'], ['html', 'cli', 'text'])) {
83 83
             echo "ERROR: Invalid value for format!\n";
84 84
 
85 85
             return false;
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             return 0;
102 102
         }
103 103
 
104
-        if (! isset($params['q'])) {
104
+        if (!isset($params['q'])) {
105 105
             $stdIn = $this->readStdin();
106 106
 
107 107
             if ($stdIn) {
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
     }
137 137
 
138 138
     /** @return string[]|false[]|false */
139
-    public function parseLint(): array|false
139
+    public function parseLint(): array | false
140 140
     {
141 141
         $longopts = [
142 142
             'help',
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
             Context::load($params['c']);
172 172
         }
173 173
 
174
-        if (! isset($params['q'])) {
174
+        if (!isset($params['q'])) {
175 175
             $stdIn = $this->readStdin();
176 176
 
177 177
             if ($stdIn) {
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
     }
212 212
 
213 213
     /** @return string[]|false[]|false */
214
-    public function parseTokenize(): array|false
214
+    public function parseTokenize(): array | false
215 215
     {
216 216
         $longopts = [
217 217
             'help',
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
             return 0;
242 242
         }
243 243
 
244
-        if (! isset($params['q'])) {
244
+        if (!isset($params['q'])) {
245 245
             $stdIn = $this->readStdin();
246 246
 
247 247
             if ($stdIn) {
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
         return 1;
278 278
     }
279 279
 
280
-    public function readStdin(): string|false|null
280
+    public function readStdin(): string | false | null
281 281
     {
282 282
         $read = [STDIN];
283 283
         $write = [];
Please login to merge, or discard this patch.
src/Components/IndexHint.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -19,17 +19,17 @@  discard block
 block discarded – undo
19 19
     /**
20 20
      * The type of hint (USE/FORCE/IGNORE)
21 21
      */
22
-    public string|null $type;
22
+    public string | null $type;
23 23
 
24 24
     /**
25 25
      * What the hint is for (INDEX/KEY)
26 26
      */
27
-    public string|null $indexOrKey;
27
+    public string | null $indexOrKey;
28 28
 
29 29
     /**
30 30
      * The clause for which this hint is (JOIN/ORDER BY/GROUP BY)
31 31
      */
32
-    public string|null $for;
32
+    public string | null $for;
33 33
 
34 34
     /**
35 35
      * List of indexes in this hint
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
      * @param Expression[] $indexes    List of indexes in this hint
46 46
      */
47 47
     public function __construct(
48
-        string|null $type = null,
49
-        string|null $indexOrKey = null,
50
-        string|null $for = null,
48
+        string | null $type = null,
49
+        string | null $indexOrKey = null,
50
+        string | null $for = null,
51 51
         array $indexes = [],
52 52
     ) {
53 53
         $this->type = $type;
Please login to merge, or discard this patch.
src/Context.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -347,13 +347,13 @@  discard block
 block discarded – undo
347 347
      *
348 348
      * @param bool $isReserved checks if the keyword is reserved
349 349
      */
350
-    public static function isKeyword(string $string, bool $isReserved = false): int|null
350
+    public static function isKeyword(string $string, bool $isReserved = false): int | null
351 351
     {
352 352
         $upperString = strtoupper($string);
353 353
 
354 354
         if (
355
-            ! isset(static::$keywords[$upperString])
356
-            || ($isReserved && ! (static::$keywords[$upperString] & Token::FLAG_KEYWORD_RESERVED))
355
+            !isset(static::$keywords[$upperString])
356
+            || ($isReserved && !(static::$keywords[$upperString] & Token::FLAG_KEYWORD_RESERVED))
357 357
         ) {
358 358
             return null;
359 359
         }
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
     /**
365 365
      * Checks if the given string is an operator and returns the appropriate flag for the operator.
366 366
      */
367
-    public static function isOperator(string $string): int|null
367
+    public static function isOperator(string $string): int | null
368 368
     {
369 369
         return static::$operators[$string] ?? null;
370 370
     }
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      *
383 383
      * @return int|null the appropriate flag for the comment type
384 384
      */
385
-    public static function isComment(string $string, bool $end = false): int|null
385
+    public static function isComment(string $string, bool $end = false): int | null
386 386
     {
387 387
         if ($string === '') {
388 388
             return null;
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
      *
446 446
      * @return int|null the appropriate flag for the symbol type
447 447
      */
448
-    public static function isSymbol(string $string): int|null
448
+    public static function isSymbol(string $string): int | null
449 449
     {
450 450
         if ($string === '') {
451 451
             return null;
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
      *
474 474
      * @return int|null the appropriate flag for the string type
475 475
      */
476
-    public static function isString(string $string): int|null
476
+    public static function isString(string $string): int | null
477 477
     {
478 478
         if ($string === '') {
479 479
             return null;
@@ -522,8 +522,8 @@  discard block
 block discarded – undo
522 522
             $context = ContextMySql50700::class;
523 523
         }
524 524
 
525
-        if (! class_exists($context)) {
526
-            if (! class_exists(self::$contextPrefix . $context)) {
525
+        if (!class_exists($context)) {
526
+            if (!class_exists(self::$contextPrefix . $context)) {
527 527
                 return false;
528 528
             }
529 529
 
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
      *
550 550
      * @return string|null The loaded context. `null` if no context was loaded.
551 551
      */
552
-    public static function loadClosest(string $context = ''): string|null
552
+    public static function loadClosest(string $context = ''): string | null
553 553
     {
554 554
         $length = strlen($context);
555 555
         for ($i = $length; $i > 0;) {
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
                 $i -= 2;
564 564
                 $part = substr($context, $i, 2);
565 565
                 /* No more numeric parts to strip */
566
-                if (! is_numeric($part)) {
566
+                if (!is_numeric($part)) {
567 567
                     break 2;
568 568
                 }
569 569
             } while (intval($part) === 0 && $i > 0);
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
     /**
595 595
      * Sets the SQL mode.
596 596
      */
597
-    public static function setMode(int|string $mode = self::SQL_MODE_NONE): void
597
+    public static function setMode(int | string $mode = self::SQL_MODE_NONE): void
598 598
     {
599 599
         if (is_int($mode)) {
600 600
             static::$mode = $mode;
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
     public static function escape(string $str, string $quote = '`'): string
661 661
     {
662 662
         if (
663
-            (static::$mode & self::SQL_MODE_NO_ENCLOSING_QUOTES) && ! (
663
+            (static::$mode & self::SQL_MODE_NO_ENCLOSING_QUOTES) && !(
664 664
                 static::isKeyword($str, true) || self::doesIdentifierRequireQuoting($str)
665 665
             )
666 666
         ) {
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
      *
698 698
      * @return bool false on empty param, true/false on given constant/int value
699 699
      */
700
-    public static function hasMode(int|null $flag = null): bool
700
+    public static function hasMode(int | null $flag = null): bool
701 701
     {
702 702
         if (empty($flag)) {
703 703
             return false;
Please login to merge, or discard this patch.
src/Exceptions/ParserException.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@
 block discarded – undo
15 15
     /**
16 16
      * The token that produced this error.
17 17
      */
18
-    public Token|null $token;
18
+    public Token | null $token;
19 19
 
20 20
     /**
21 21
      * @param string     $msg   the message of this exception
22 22
      * @param Token|null $token the token that produced this exception
23 23
      * @param int        $code  the code of this error
24 24
      */
25
-    public function __construct(string $msg, Token|null $token, int $code = 0)
25
+    public function __construct(string $msg, Token | null $token, int $code = 0)
26 26
     {
27 27
         parent::__construct($msg, $code);
28 28
 
Please login to merge, or discard this patch.
src/Utils/BufferedQuery.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     /**
63 63
      * The current status of the parser.
64 64
      */
65
-    public int|null $status = null;
65
+    public int | null $status = null;
66 66
 
67 67
     /**
68 68
      * The last incomplete query that was extracted.
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      *
110 110
      * @param bool $end whether the end of the buffer was reached
111 111
      */
112
-    public function extract(bool $end = false): string|false
112
+    public function extract(bool $end = false): string | false
113 113
     {
114 114
         /**
115 115
          * The last parsed position.
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 
302 302
                 // Parsing the delimiter.
303 303
                 $delimiter = '';
304
-                while (($i < $len) && (! Context::isWhitespace($this->query[$i]))) {
304
+                while (($i < $len) && (!Context::isWhitespace($this->query[$i]))) {
305 305
                     $delimiter .= $this->query[$i++];
306 306
                 }
307 307
 
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 
317 317
                     // Whether this statement should be returned or not.
318 318
                     $ret = '';
319
-                    if (! empty($this->options['parse_delimiter'])) {
319
+                    if (!empty($this->options['parse_delimiter'])) {
320 320
                         // Appending the `DELIMITER` statement that was just
321 321
                         // found to the current statement.
322 322
                         $ret = trim(
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
                 $ret = $this->current;
360 360
 
361 361
                 // If needed, adds a delimiter at the end of the statement.
362
-                if (! empty($this->options['add_delimiter'])) {
362
+                if (!empty($this->options['add_delimiter'])) {
363 363
                     $ret .= $this->delimiter;
364 364
                 }
365 365
 
Please login to merge, or discard this patch.
src/Parser.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
     /**
356 356
      * The list of tokens that are parsed.
357 357
      */
358
-    public TokensList|null $list = null;
358
+    public TokensList | null $list = null;
359 359
 
360 360
     /**
361 361
      * List of statements parsed.
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
      * @param string|UtfString|TokensList|null $list   the list of tokens to be parsed
374 374
      * @param bool                             $strict whether strict mode should be enabled or not
375 375
      */
376
-    public function __construct(string|UtfString|TokensList|null $list = null, bool $strict = false)
376
+    public function __construct(string | UtfString | TokensList | null $list = null, bool $strict = false)
377 377
     {
378 378
         if (Context::$keywords === []) {
379 379
             Context::load();
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
                 $list->idx = $lastIdx;
504 504
             } elseif (empty(self::STATEMENT_PARSERS[$token->keyword])) {
505 505
                 // Checking if it is a known statement that can be parsed.
506
-                if (! isset(self::STATEMENT_PARSERS[$token->keyword])) {
506
+                if (!isset(self::STATEMENT_PARSERS[$token->keyword])) {
507 507
                     // A statement is considered recognized if the parser
508 508
                     // is aware that it is a statement, but it does not have
509 509
                     // a parser for it yet.
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 
544 544
             // Handles unions.
545 545
             if (
546
-                ! empty($unionType)
546
+                !empty($unionType)
547 547
                 && ($lastStatement instanceof SelectStatement)
548 548
                 && ($statement instanceof SelectStatement)
549 549
             ) {
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
      *
631 631
      * @throws ParserException throws the exception, if strict mode is enabled.
632 632
      */
633
-    public function error(string $msg, Token|null $token = null, int $code = 0): void
633
+    public function error(string $msg, Token | null $token = null, int $code = 0): void
634 634
     {
635 635
         $error = new ParserException(
636 636
             Translator::gettext($msg),
Please login to merge, or discard this patch.