Passed
Push — master ( a870bc...f7b692 )
by Maurício
03:05 queued 14s
created
src/Components/Expression.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      *
156 156
      * @throws ParserException
157 157
      */
158
-    public static function parse(Parser $parser, TokensList $list, array $options = []): Expression|null
158
+    public static function parse(Parser $parser, TokensList $list, array $options = []): Expression | null
159 159
     {
160 160
         $ret = new static();
161 161
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         ];
199 199
 
200 200
         // When a field is parsed, no parentheses are expected.
201
-        if (! empty($options['parseField'])) {
201
+        if (!empty($options['parseField'])) {
202 202
             $options['breakOnParentheses'] = true;
203 203
             $options['field'] = $options['parseField'];
204 204
         }
@@ -225,14 +225,14 @@  discard block
 block discarded – undo
225 225
             }
226 226
 
227 227
             if ($token->type === TokenType::Keyword) {
228
-                if (($brackets > 0) && empty($ret->subquery) && ! empty(Parser::STATEMENT_PARSERS[$token->keyword])) {
228
+                if (($brackets > 0) && empty($ret->subquery) && !empty(Parser::STATEMENT_PARSERS[$token->keyword])) {
229 229
                     // A `(` was previously found and this keyword is the
230 230
                     // beginning of a statement, so this is a subquery.
231 231
                     $ret->subquery = $token->keyword;
232 232
                 } elseif (
233 233
                     ($token->flags & Token::FLAG_KEYWORD_FUNCTION)
234 234
                     && (empty($options['parseField'])
235
-                    && ! $alias)
235
+                    && !$alias)
236 236
                 ) {
237 237
                     $isExpr = true;
238 238
                 } elseif (($token->flags & Token::FLAG_KEYWORD_RESERVED) && ($brackets === 0)) {
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
                     }
245 245
 
246 246
                     if ($token->keyword === 'AS') {
247
-                        if (! empty($options['breakOnAlias'])) {
247
+                        if (!empty($options['breakOnAlias'])) {
248 248
                             break;
249 249
                         }
250 250
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
                     }
268 268
 
269 269
                     $isExpr = true;
270
-                } elseif ($brackets === 0 && strlen((string) $ret->expr) > 0 && ! $alias) {
270
+                } elseif ($brackets === 0 && strlen((string) $ret->expr) > 0 && !$alias) {
271 271
                     /* End of expression */
272 272
                     break;
273 273
                 }
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
                 || (($token->type === TokenType::Operator)
284 284
                 && ($token->value !== '.'))
285 285
             ) {
286
-                if (! empty($options['parseField'])) {
286
+                if (!empty($options['parseField'])) {
287 287
                     break;
288 288
                 }
289 289
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
             }
294 294
 
295 295
             if ($token->type === TokenType::Operator) {
296
-                if (! empty($options['breakOnParentheses']) && (($token->value === '(') || ($token->value === ')'))) {
296
+                if (!empty($options['breakOnParentheses']) && (($token->value === '(') || ($token->value === ')'))) {
297 297
                     // No brackets were expected.
298 298
                     break;
299 299
                 }
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
                     --$brackets;
319 319
                     if ($brackets === 0) {
320
-                        if (! empty($options['parenthesesDelimited'])) {
320
+                        if (!empty($options['parenthesesDelimited'])) {
321 321
                             // The current token is the last bracket, the next
322 322
                             // one will be outside the expression.
323 323
                             $ret->expr .= $token->token;
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 
344 344
             if ($alias) {
345 345
                 // An alias is expected (the keyword `AS` was previously found).
346
-                if (! empty($ret->alias)) {
346
+                if (!empty($ret->alias)) {
347 347
                     $parser->error('An alias was previously found.', $token);
348 348
                     break;
349 349
                 }
@@ -357,15 +357,15 @@  discard block
 block discarded – undo
357 357
                     && ($prev[0] === null
358 358
                         || (($prev[0]->type !== TokenType::Operator || $prev[0]->token === ')')
359 359
                             && ($prev[0]->type !== TokenType::Keyword
360
-                                || ! ($prev[0]->flags & Token::FLAG_KEYWORD_RESERVED))))
360
+                                || !($prev[0]->flags & Token::FLAG_KEYWORD_RESERVED))))
361 361
                     && (($prev[1]->type === TokenType::String)
362 362
                         || ($prev[1]->type === TokenType::Symbol
363
-                            && ! ($prev[1]->flags & Token::FLAG_SYMBOL_VARIABLE)
364
-                            && ! ($prev[1]->flags & Token::FLAG_SYMBOL_PARAMETER))
363
+                            && !($prev[1]->flags & Token::FLAG_SYMBOL_VARIABLE)
364
+                            && !($prev[1]->flags & Token::FLAG_SYMBOL_PARAMETER))
365 365
                         || ($prev[1]->type === TokenType::None
366 366
                             && $prev[1]->token !== 'OVER'))
367 367
                 ) {
368
-                    if (! empty($ret->alias)) {
368
+                    if (!empty($ret->alias)) {
369 369
                         $parser->error('An alias was previously found.', $token);
370 370
                         break;
371 371
                     }
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
                     // Found a `.` which means we expect a column name and
397 397
                     // the column name we parsed is actually the table name
398 398
                     // and the table name is actually a database name.
399
-                    if (! empty($ret->database) || $dot) {
399
+                    if (!empty($ret->database) || $dot) {
400 400
                         $parser->error('Unexpected dot.', $token);
401 401
                     }
402 402
 
@@ -413,11 +413,11 @@  discard block
 block discarded – undo
413 413
                         $dot = false;
414 414
                     } else {
415 415
                         // No alias is expected.
416
-                        if (! empty($options['breakOnAlias'])) {
416
+                        if (!empty($options['breakOnAlias'])) {
417 417
                             break;
418 418
                         }
419 419
 
420
-                        if (! empty($ret->alias)) {
420
+                        if (!empty($ret->alias)) {
421 421
                             $parser->error('An alias was previously found.', $token);
422 422
                             break;
423 423
                         }
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
             $ret = implode('.', Context::escapeAll($fields));
466 466
         }
467 467
 
468
-        if (! empty($this->alias)) {
468
+        if (!empty($this->alias)) {
469 469
             $ret .= ' AS ' . Context::escape($this->alias);
470 470
         }
471 471
 
Please login to merge, or discard this patch.
src/Lexer.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         $len = $str instanceof UtfString ? $str->length() : strlen($str);
120 120
 
121 121
         // For multi-byte strings, a new instance of `UtfString` is initialized.
122
-        if (! $str instanceof UtfString && $len !== mb_strlen($str, 'UTF-8')) {
122
+        if (!$str instanceof UtfString && $len !== mb_strlen($str, 'UTF-8')) {
123 123
             $str = new UtfString($str);
124 124
         }
125 125
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
         $this->strict = $strict;
130 130
 
131 131
         // Setting the delimiter.
132
-        $this->setDelimiter(! empty($delimiter) ? $delimiter : static::$defaultDelimiter);
132
+        $this->setDelimiter(!empty($delimiter) ? $delimiter : static::$defaultDelimiter);
133 133
 
134 134
         $this->lex();
135 135
     }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
                 $delimiterLen = 0;
239 239
                 while (
240 240
                     ++$this->last < $this->len
241
-                    && ! Context::isWhitespace($this->str[$this->last])
241
+                    && !Context::isWhitespace($this->str[$this->last])
242 242
                     && $delimiterLen < 15
243 243
                 ) {
244 244
                     $this->delimiter .= $this->str[$this->last];
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
             }
298 298
 
299 299
             if (
300
-                ($next->type !== TokenType::Keyword || ! in_array($next->value, ['FROM', 'USING'], true))
301
-                && ($next->type !== TokenType::Operator || ! in_array($next->value, [',', ')'], true))
300
+                ($next->type !== TokenType::Keyword || !in_array($next->value, ['FROM', 'USING'], true))
301
+                && ($next->type !== TokenType::Operator || !in_array($next->value, [',', ')'], true))
302 302
             ) {
303 303
                 continue;
304 304
             }
@@ -336,10 +336,10 @@  discard block
 block discarded – undo
336 336
             $next = $this->list->getNext();
337 337
             if (
338 338
                 ($next->type !== TokenType::Keyword
339
-                    || ! in_array($next->value, self::KEYWORD_NAME_INDICATORS, true)
339
+                    || !in_array($next->value, self::KEYWORD_NAME_INDICATORS, true)
340 340
                 )
341 341
                 && ($next->type !== TokenType::Operator
342
-                    || ! in_array($next->value, self::OPERATOR_NAME_INDICATORS, true)
342
+                    || !in_array($next->value, self::OPERATOR_NAME_INDICATORS, true)
343 343
                 )
344 344
                 && ($next->value !== null)
345 345
             ) {
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
     /**
379 379
      * Parses a keyword.
380 380
      */
381
-    public function parseKeyword(): Token|null
381
+    public function parseKeyword(): Token | null
382 382
     {
383 383
         $token = '';
384 384
 
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
             $token .= $this->str[$this->last];
419 419
             $flags = Context::isKeyword($token);
420 420
 
421
-            if (($this->last + 1 !== $this->len && ! Context::isSeparator($this->str[$this->last + 1])) || ! $flags) {
421
+            if (($this->last + 1 !== $this->len && !Context::isSeparator($this->str[$this->last + 1])) || !$flags) {
422 422
                 continue;
423 423
             }
424 424
 
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
     /**
439 439
      * Parses a label.
440 440
      */
441
-    public function parseLabel(): Token|null
441
+    public function parseLabel(): Token | null
442 442
     {
443 443
         $token = '';
444 444
 
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
     /**
483 483
      * Parses an operator.
484 484
      */
485
-    public function parseOperator(): Token|null
485
+    public function parseOperator(): Token | null
486 486
     {
487 487
         $token = '';
488 488
 
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
             $token .= $this->str[$this->last];
503 503
             $flags = Context::isOperator($token);
504 504
 
505
-            if (! $flags) {
505
+            if (!$flags) {
506 506
                 continue;
507 507
             }
508 508
 
@@ -518,11 +518,11 @@  discard block
 block discarded – undo
518 518
     /**
519 519
      * Parses a whitespace.
520 520
      */
521
-    public function parseWhitespace(): Token|null
521
+    public function parseWhitespace(): Token | null
522 522
     {
523 523
         $token = $this->str[$this->last];
524 524
 
525
-        if (! Context::isWhitespace($token)) {
525
+        if (!Context::isWhitespace($token)) {
526 526
             return null;
527 527
         }
528 528
 
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
     /**
539 539
      * Parses a comment.
540 540
      */
541
-    public function parseComment(): Token|null
541
+    public function parseComment(): Token | null
542 542
     {
543 543
         $iBak = $this->last;
544 544
         $token = $this->str[$this->last];
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
     /**
656 656
      * Parses a boolean.
657 657
      */
658
-    public function parseBool(): Token|null
658
+    public function parseBool(): Token | null
659 659
     {
660 660
         if ($this->last + 3 >= $this->len) {
661 661
             // At least `min(strlen('TRUE'), strlen('FALSE'))` characters are
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
     /**
687 687
      * Parses a number.
688 688
      */
689
-    public function parseNumber(): Token|null
689
+    public function parseNumber(): Token | null
690 690
     {
691 691
         // A rudimentary state machine is being used to parse numbers due to
692 692
         // the various forms of their notation.
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
             } elseif ($state === 2) {
754 754
                 $flags |= Token::FLAG_NUMBER_HEX;
755 755
                 if (
756
-                    ! (
756
+                    !(
757 757
                         ($this->str[$this->last] >= '0' && $this->str[$this->last] <= '9')
758 758
                         || ($this->str[$this->last] >= 'A' && $this->str[$this->last] <= 'F')
759 759
                         || ($this->str[$this->last] >= 'a' && $this->str[$this->last] <= 'f')
@@ -849,12 +849,12 @@  discard block
 block discarded – undo
849 849
      *
850 850
      * @throws LexerException
851 851
      */
852
-    public function parseString($quote = ''): Token|null
852
+    public function parseString($quote = ''): Token | null
853 853
     {
854 854
         $token = $this->str[$this->last];
855 855
         $flags = Context::isString($token);
856 856
 
857
-        if (! $flags && $token !== $quote) {
857
+        if (!$flags && $token !== $quote) {
858 858
             return null;
859 859
         }
860 860
 
@@ -899,12 +899,12 @@  discard block
 block discarded – undo
899 899
      *
900 900
      * @throws LexerException
901 901
      */
902
-    public function parseSymbol(): Token|null
902
+    public function parseSymbol(): Token | null
903 903
     {
904 904
         $token = $this->str[$this->last];
905 905
         $flags = Context::isSymbol($token);
906 906
 
907
-        if (! $flags) {
907
+        if (!$flags) {
908 908
             return null;
909 909
         }
910 910
 
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
             if ($str === null) {
931 931
                 $str = $this->parseUnknown();
932 932
 
933
-                if ($str === null && ! ($flags & Token::FLAG_SYMBOL_PARAMETER)) {
933
+                if ($str === null && !($flags & Token::FLAG_SYMBOL_PARAMETER)) {
934 934
                     $this->error('Variable name was expected.', $this->str[$this->last], $this->last);
935 935
                 }
936 936
             }
@@ -946,14 +946,14 @@  discard block
 block discarded – undo
946 946
     /**
947 947
      * Parses unknown parts of the query.
948 948
      */
949
-    public function parseUnknown(): Token|null
949
+    public function parseUnknown(): Token | null
950 950
     {
951 951
         $token = $this->str[$this->last];
952 952
         if (Context::isSeparator($token)) {
953 953
             return null;
954 954
         }
955 955
 
956
-        while (++$this->last < $this->len && ! Context::isSeparator($this->str[$this->last])) {
956
+        while (++$this->last < $this->len && !Context::isSeparator($this->str[$this->last])) {
957 957
             $token .= $this->str[$this->last];
958 958
 
959 959
             // Test if end of token equals the current delimiter. If so, remove it from the token.
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
     /**
973 973
      * Parses the delimiter of the query.
974 974
      */
975
-    public function parseDelimiter(): Token|null
975
+    public function parseDelimiter(): Token | null
976 976
     {
977 977
         $idx = 0;
978 978
 
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
         return new Token($this->delimiter, TokenType::Delimiter);
990 990
     }
991 991
 
992
-    private function parse(): Token|null
992
+    private function parse(): Token | null
993 993
     {
994 994
         // It is best to put the parsers in order of their complexity
995 995
         // (ascending) and their occurrence rate (descending).
Please login to merge, or discard this patch.