Passed
Push — master ( 04a929...43c45e )
by Maurício
03:15 queued 13s
created
src/Components/Expression.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
      * @param string|null $alias    the name of the alias
115 115
      */
116 116
     public function __construct(
117
-        string|null $database = null,
118
-        string|null $table = null,
119
-        string|null $column = null,
120
-        string|null $alias = null,
117
+        string | null $database = null,
118
+        string | null $table = null,
119
+        string | null $column = null,
120
+        string | null $alias = null,
121 121
     ) {
122 122
         if (($column === null) && ($alias === null)) {
123 123
             $this->expr = $database; // case 1
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      *
163 163
      * @throws ParserException
164 164
      */
165
-    public static function parse(Parser $parser, TokensList $list, array $options = []): Expression|null
165
+    public static function parse(Parser $parser, TokensList $list, array $options = []): Expression | null
166 166
     {
167 167
         $ret = new static();
168 168
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
         ];
196 196
 
197 197
         // When a field is parsed, no parentheses are expected.
198
-        if (! empty($options['parseField'])) {
198
+        if (!empty($options['parseField'])) {
199 199
             $options['breakOnParentheses'] = true;
200 200
             $options['field'] = $options['parseField'];
201 201
         }
@@ -222,18 +222,18 @@  discard block
 block discarded – undo
222 222
             }
223 223
 
224 224
             if ($token->type === TokenType::Keyword) {
225
-                if (($brackets > 0) && empty($ret->subquery) && ! empty(Parser::STATEMENT_PARSERS[$token->keyword])) {
225
+                if (($brackets > 0) && empty($ret->subquery) && !empty(Parser::STATEMENT_PARSERS[$token->keyword])) {
226 226
                     // A `(` was previously found and this keyword is the
227 227
                     // beginning of a statement, so this is a subquery.
228 228
                     $ret->subquery = $token->keyword;
229 229
                 } elseif (
230 230
                     ($token->flags & Token::FLAG_KEYWORD_FUNCTION)
231 231
                     && (empty($options['parseField'])
232
-                    && ! $alias)
232
+                    && !$alias)
233 233
                 ) {
234 234
                     $isExpr = true;
235 235
                 } elseif (($token->flags & Token::FLAG_KEYWORD_RESERVED) && ($brackets === 0)) {
236
-                    if (! in_array($token->keyword, self::ALLOWED_KEYWORDS, true)) {
236
+                    if (!in_array($token->keyword, self::ALLOWED_KEYWORDS, true)) {
237 237
                         // A reserved keyword that is not allowed in the
238 238
                         // expression was found so the expression must have
239 239
                         // ended and a new clause is starting.
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
                     }
242 242
 
243 243
                     if ($token->keyword === 'AS') {
244
-                        if (! empty($options['breakOnAlias'])) {
244
+                        if (!empty($options['breakOnAlias'])) {
245 245
                             break;
246 246
                         }
247 247
 
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 
266 266
                     $isExpr = true;
267 267
                 } elseif (
268
-                    $brackets === 0 && strlen((string) $ret->expr) > 0 && ! $alias
268
+                    $brackets === 0 && strlen((string) $ret->expr) > 0 && !$alias
269 269
                     && ($ret->table === null || $ret->table === '')
270 270
                 ) {
271 271
                     /* End of expression */
@@ -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.