Completed
Push — master ( 0392f4...72179e )
by Ivan
04:50
created
src/schema/TableQuery.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 
4 4
 use vakata\database\DBInterface;
5 5
 use vakata\database\DBException;
6
-use vakata\database\ResultInterface;
7 6
 
8 7
 /**
9 8
  * A database query class
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     /**
61 61
      * Create an instance
62 62
      * @param  DBInterface    $db         the database connection
63
-     * @param  Table|string   $table      the name or definition of the main table in the query
63
+     * @param  Table   $table      the name or definition of the main table in the query
64 64
      */
65 65
     public function __construct(DBInterface $db, $table)
66 66
     {
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
     }
240 240
     /**
241 241
      * Group by a column (or columns)
242
-     * @param  string|array        $column the column name (or names) to group by
242
+     * @param  string        $column the column name (or names) to group by
243 243
      * @return $this
244 244
      */
245 245
     public function group($column) : TableQuery
Please login to merge, or discard this patch.
Spacing   +113 added lines, -116 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     /**
44 44
      * @var int[]
45 45
      */
46
-    protected $li_of = [0,0];
46
+    protected $li_of = [0, 0];
47 47
     /**
48 48
      * @var array
49 49
      */
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     public function __construct(DBInterface $db, $table)
74 74
     {
75 75
         $this->db = $db;
76
-        $this->definition = $table instanceof Table ? $table : $this->db->definition((string)$table);
76
+        $this->definition = $table instanceof Table ? $table : $this->db->definition((string) $table);
77 77
         $primary = $this->definition->getPrimaryKey();
78 78
         $columns = $this->definition->getColumns();
79 79
         $this->pkey = count($primary) ? $primary : $columns;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     {
97 97
         $column = explode('.', $column);
98 98
         if (count($column) === 1) {
99
-            $column = [ $this->definition->getName(), $column[0] ];
99
+            $column = [$this->definition->getName(), $column[0]];
100 100
             $col = $this->definition->getColumn($column[1]);
101 101
             if (!$col) {
102 102
                 throw new DBException('Invalid column name in own table');
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
                         throw new DBException('Invalid column name in related table');
120 120
                     }
121 121
                 } else {
122
-                    throw new DBException('Invalid foreign table name: ' . implode(',', $column));
122
+                    throw new DBException('Invalid foreign table name: '.implode(',', $column));
123 123
                 }
124 124
             }
125 125
         } else {
@@ -128,15 +128,15 @@  discard block
 block discarded – undo
128 128
             $table = $this->definition;
129 129
             $table = array_reduce(
130 130
                 $column,
131
-                function ($carry, $item) use (&$table) {
131
+                function($carry, $item) use (&$table) {
132 132
                     $table = $table->getRelation($item)->table;
133 133
                     return $table;
134 134
                 }
135 135
             );
136 136
             $col = $table->getColumn($name);
137
-            $column = [ implode(static::SEP, $column), $name ];
137
+            $column = [implode(static::SEP, $column), $name];
138 138
         }
139
-        return [ 'name' => implode('.', $column), 'data' => $col ];
139
+        return ['name' => implode('.', $column), 'data' => $col];
140 140
     }
141 141
     protected function normalizeValue(TableColumn $col, $value)
142 142
     {
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
                 }
184 184
                 return $value;
185 185
             case 'int':
186
-                return (int)$value;
186
+                return (int) $value;
187 187
             default:
188 188
                 return $value;
189 189
         }
@@ -201,18 +201,16 @@  discard block
 block discarded – undo
201 201
         list($name, $column) = array_values($this->getColumn($column));
202 202
         if (is_null($value)) {
203 203
             return $negate ?
204
-                $this->where($name . ' IS NOT NULL') :
205
-                $this->where($name . ' IS NULL');
204
+                $this->where($name.' IS NOT NULL') : $this->where($name.' IS NULL');
206 205
         }
207 206
         if (!is_array($value)) {
208 207
             return $negate ?
209 208
                 $this->where(
210
-                    $name . ' <> ?',
211
-                    [ $this->normalizeValue($column, $value) ]
212
-                ) :
213
-                $this->where(
214
-                    $name . ' = ?',
215
-                    [ $this->normalizeValue($column, $value) ]
209
+                    $name.' <> ?',
210
+                    [$this->normalizeValue($column, $value)]
211
+                ) : $this->where(
212
+                    $name.' = ?',
213
+                    [$this->normalizeValue($column, $value)]
216 214
                 );
217 215
         }
218 216
         if (isset($value['beg']) && isset($value['end'])) {
@@ -223,8 +221,7 @@  discard block
 block discarded – undo
223 221
                         $this->normalizeValue($column, $value['beg']),
224 222
                         $this->normalizeValue($column, $value['end'])
225 223
                     ]
226
-                ) :
227
-                $this->where(
224
+                ) : $this->where(
228 225
                     $name.' BETWEEN ? AND ?',
229 226
                     [
230 227
                         $this->normalizeValue($column, $value['beg']),
@@ -235,38 +232,38 @@  discard block
 block discarded – undo
235 232
         if (isset($value['gt']) || isset($value['lt']) || isset($value['gte']) || isset($value['lte'])) {
236 233
             if (isset($value['gt'])) {
237 234
                 $this->where(
238
-                    $name. ' ' . ($negate ? '<=' : '>') . ' ?',
239
-                    [ $this->normalizeValue($column, $value['gt']) ]
235
+                    $name.' '.($negate ? '<=' : '>').' ?',
236
+                    [$this->normalizeValue($column, $value['gt'])]
240 237
                 );
241 238
             }
242 239
             if (isset($value['gte'])) {
243 240
                 $this->where(
244
-                    $name. ' ' . ($negate ? '<' : '>=') . ' ?',
245
-                    [ $this->normalizeValue($column, $value['gte']) ]
241
+                    $name.' '.($negate ? '<' : '>=').' ?',
242
+                    [$this->normalizeValue($column, $value['gte'])]
246 243
                 );
247 244
             }
248 245
             if (isset($value['lt'])) {
249 246
                 $this->where(
250
-                    $name. ' ' . ($negate ? '>=' : '<') . ' ?',
251
-                    [ $this->normalizeValue($column, $value['lt']) ]
247
+                    $name.' '.($negate ? '>=' : '<').' ?',
248
+                    [$this->normalizeValue($column, $value['lt'])]
252 249
                 );
253 250
             }
254 251
             if (isset($value['lte'])) {
255 252
                 $this->where(
256
-                    $name. ' ' . ($negate ? '>' : '<=') . ' ?',
257
-                    [ $this->normalizeValue($column, $value['lte']) ]
253
+                    $name.' '.($negate ? '>' : '<=').' ?',
254
+                    [$this->normalizeValue($column, $value['lte'])]
258 255
                 );
259 256
             }
260 257
             return $this;
261 258
         }
262 259
         return $negate ?
263 260
             $this->where(
264
-                $name . ' NOT IN (??)',
265
-                [ array_map(function ($v) use ($column) { return $this->normalizeValue($column, $v); }, $value) ]
261
+                $name.' NOT IN (??)',
262
+                [array_map(function($v) use ($column) { return $this->normalizeValue($column, $v); }, $value)]
266 263
             ) :
267 264
             $this->where(
268
-                $name . ' IN (??)',
269
-                [ array_map(function ($v) use ($column) { return $this->normalizeValue($column, $v); }, $value) ]
265
+                $name.' IN (??)',
266
+                [array_map(function($v) use ($column) { return $this->normalizeValue($column, $v); }, $value)]
270 267
             );
271 268
     }
272 269
     /**
@@ -277,7 +274,7 @@  discard block
 block discarded – undo
277 274
      */
278 275
     public function sort(string $column, bool $desc = false) : TableQuery
279 276
     {
280
-        return $this->order($this->getColumn($column)['name'] . ' ' . ($desc ? 'DESC' : 'ASC'));
277
+        return $this->order($this->getColumn($column)['name'].' '.($desc ? 'DESC' : 'ASC'));
281 278
     }
282 279
     /**
283 280
      * Group by a column (or columns)
@@ -287,7 +284,7 @@  discard block
 block discarded – undo
287 284
     public function group($column) : TableQuery
288 285
     {
289 286
         if (!is_array($column)) {
290
-            $column = [ $column ];
287
+            $column = [$column];
291 288
         }
292 289
         foreach ($column as $k => $v) {
293 290
             $column[$k] = $this->getColumn($v)['name'];
@@ -329,7 +326,7 @@  discard block
 block discarded – undo
329 326
         $this->order = [];
330 327
         $this->having = [];
331 328
         $this->aliases = [];
332
-        $this->li_of = [0,0];
329
+        $this->li_of = [0, 0];
333 330
         $this->qiterator = null;
334 331
         return $this;
335 332
     }
@@ -342,7 +339,7 @@  discard block
 block discarded – undo
342 339
     public function groupBy(string $sql, array $params = []) : TableQuery
343 340
     {
344 341
         $this->qiterator = null;
345
-        $this->group = [ $sql, $params ];
342
+        $this->group = [$sql, $params];
346 343
         return $this;
347 344
     }
348 345
     /**
@@ -355,7 +352,7 @@  discard block
 block discarded – undo
355 352
      */
356 353
     public function join($table, array $fields, string $name = null, bool $multiple = true)
357 354
     {
358
-        $table = $table instanceof Table ? $table : $this->db->definition((string)$table);
355
+        $table = $table instanceof Table ? $table : $this->db->definition((string) $table);
359 356
         $name = $name ?? $table->getName();
360 357
         if (isset($this->joins[$name]) || $this->definition->hasRelation($name)) {
361 358
             throw new DBException('Alias / table name already in use');
@@ -364,7 +361,7 @@  discard block
 block discarded – undo
364 361
         foreach ($fields as $k => $v) {
365 362
             $k = explode('.', $k, 2);
366 363
             $k = count($k) == 2 ? $k[1] : $k[0];
367
-            $this->joins[$name]->keymap[$this->getColumn($name . '.' . $k)['name']] = $this->getColumn($v)['name'];
364
+            $this->joins[$name]->keymap[$this->getColumn($name.'.'.$k)['name']] = $this->getColumn($v)['name'];
368 365
         }
369 366
         return $this;
370 367
     }
@@ -377,7 +374,7 @@  discard block
 block discarded – undo
377 374
     public function where(string $sql, array $params = []) : TableQuery
378 375
     {
379 376
         $this->qiterator = null;
380
-        $this->where[] = [ $sql, $params ];
377
+        $this->where[] = [$sql, $params];
381 378
         return $this;
382 379
     }
383 380
     /**
@@ -389,7 +386,7 @@  discard block
 block discarded – undo
389 386
     public function having(string $sql, array $params = []) : TableQuery
390 387
     {
391 388
         $this->qiterator = null;
392
-        $this->having[] = [ $sql, $params ];
389
+        $this->having[] = [$sql, $params];
393 390
         return $this;
394 391
     }
395 392
     /**
@@ -401,7 +398,7 @@  discard block
 block discarded – undo
401 398
     public function order(string $sql, array $params = []) : TableQuery
402 399
     {
403 400
         $this->qiterator = null;
404
-        $this->order = [ $sql, $params ];
401
+        $this->order = [$sql, $params];
405 402
         return $this;
406 403
     }
407 404
     /**
@@ -413,7 +410,7 @@  discard block
 block discarded – undo
413 410
     public function limit(int $limit, int $offset = 0) : TableQuery
414 411
     {
415 412
         $this->qiterator = null;
416
-        $this->li_of = [ $limit, $offset ];
413
+        $this->li_of = [$limit, $offset];
417 414
         return $this;
418 415
     }
419 416
     /**
@@ -423,9 +420,9 @@  discard block
 block discarded – undo
423 420
     public function count() : int
424 421
     {
425 422
         $aliases = [];
426
-        $getAlias = function ($name) use (&$aliases) {
423
+        $getAlias = function($name) use (&$aliases) {
427 424
             // to bypass use: return $name;
428
-            return $aliases[$name] = $aliases[$name] ?? 'alias' . static::SEP . count($aliases);
425
+            return $aliases[$name] = $aliases[$name] ?? 'alias'.static::SEP.count($aliases);
429 426
         };
430 427
         $table = $this->definition->getName();
431 428
         $sql = 'SELECT COUNT(DISTINCT '.$table.'.'.implode(', '.$table.'.', $this->pkey).') FROM '.$table.' ';
@@ -440,44 +437,44 @@  discard block
 block discarded – undo
440 437
         $h = $this->having;
441 438
         $o = $this->order;
442 439
         $g = $this->group;
443
-        $j = array_map(function ($v) { return clone $v; }, $this->joins);
440
+        $j = array_map(function($v) { return clone $v; }, $this->joins);
444 441
         foreach ($this->definition->getRelations() as $k => $v) {
445 442
             foreach ($w as $kk => $vv) {
446
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv[0])) {
447
-                    $relations[$k] = [ $v, $table ];
448
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $vv[0]);
443
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $vv[0])) {
444
+                    $relations[$k] = [$v, $table];
445
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $vv[0]);
449 446
                 }
450 447
             }
451
-            if (isset($o[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $o[0])) {
452
-                $relations[$k] = [ $v, $table ];
448
+            if (isset($o[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $o[0])) {
449
+                $relations[$k] = [$v, $table];
453 450
             }
454 451
             foreach ($h as $kk => $vv) {
455
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv[0])) {
456
-                    $relations[$k] = [ $relation, $table ];
457
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $vv[0]);
452
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $vv[0])) {
453
+                    $relations[$k] = [$relation, $table];
454
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $vv[0]);
458 455
                 }
459 456
             }
460
-            if (isset($g[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $g[0])) {
461
-                $relations[$k] = [ $relation, $table ];
462
-                $g[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $g[0]);
457
+            if (isset($g[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $g[0])) {
458
+                $relations[$k] = [$relation, $table];
459
+                $g[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $g[0]);
463 460
             }
464 461
             foreach ($j as $kk => $v) {
465 462
                 foreach ($v->keymap as $kkk => $vv) {
466
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv)) {
467
-                        $relations[$k] = [ $relation, $table ];
468
-                        $j[$k]->keymap[$kkk] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $vv);
463
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vv)) {
464
+                        $relations[$k] = [$relation, $table];
465
+                        $j[$k]->keymap[$kkk] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $vv);
469 466
                     }
470 467
                 }
471 468
             }
472 469
         }
473 470
 
474 471
         foreach ($j as $k => $v) {
475
-            $sql .= ($v->many ? 'LEFT ' : '' ) . 'JOIN '.$v->table->getName().' '.$k.' ON ';
472
+            $sql .= ($v->many ? 'LEFT ' : '').'JOIN '.$v->table->getName().' '.$k.' ON ';
476 473
             $tmp = [];
477 474
             foreach ($v->keymap as $kk => $vv) {
478 475
                 $tmp[] = $kk.' = '.$vv;
479 476
             }
480
-            $sql .= implode(' AND ', $tmp) . ' ';
477
+            $sql .= implode(' AND ', $tmp).' ';
481 478
         }
482 479
         foreach ($relations as $k => $v) {
483 480
             $table = $v[1] !== $this->definition->getName() ? $getAlias($v[1]) : $v[1];
@@ -489,13 +486,13 @@  discard block
 block discarded – undo
489 486
                 foreach ($v->keymap as $kk => $vv) {
490 487
                     $tmp[] = $table.'.'.$kk.' = '.$alias.'.'.$vv.' ';
491 488
                 }
492
-                $sql .= implode(' AND ', $tmp) . ' ';
489
+                $sql .= implode(' AND ', $tmp).' ';
493 490
                 $sql .= 'LEFT JOIN '.$v->table->getName().' '.$getAlias($k).' ON ';
494 491
                 $tmp = [];
495 492
                 foreach ($v->pivot_keymap as $kk => $vv) {
496 493
                     $tmp[] = $getAlias($k).'.'.$vv.' = '.$alias.'.'.$kk.' ';
497 494
                 }
498
-                $sql .= implode(' AND ', $tmp) . ' ';
495
+                $sql .= implode(' AND ', $tmp).' ';
499 496
             } else {
500 497
                 $alias = $getAlias($k);
501 498
                 $sql .= 'LEFT JOIN '.$v->table->getName().' '.$alias.' ON ';
@@ -504,30 +501,30 @@  discard block
 block discarded – undo
504 501
                     $tmp[] = $table.'.'.$kk.' = '.$alias.'.'.$vv.' ';
505 502
                 }
506 503
                 if ($v->sql) {
507
-                    $tmp[] = $v->sql . ' ';
504
+                    $tmp[] = $v->sql.' ';
508 505
                     $par = array_merge($par, $v->par ?? []);
509 506
                 }
510
-                $sql .= implode(' AND ', $tmp) . ' ';
507
+                $sql .= implode(' AND ', $tmp).' ';
511 508
             }
512 509
         }
513 510
         if (count($w)) {
514 511
             $sql .= 'WHERE ';
515 512
             $tmp = [];
516 513
             foreach ($w as $v) {
517
-                $tmp[] = '(' . $v[0] . ')';
514
+                $tmp[] = '('.$v[0].')';
518 515
                 $par = array_merge($par, $v[1]);
519 516
             }
520 517
             $sql .= implode(' AND ', $tmp).' ';
521 518
         }
522 519
         if (count($g)) {
523
-            $sql .= 'GROUP BY ' . $g[0] . ' ';
520
+            $sql .= 'GROUP BY '.$g[0].' ';
524 521
             $par = array_merge($par, $g[1]);
525 522
         }
526 523
         if (count($h)) {
527 524
             $sql .= 'HAVING ';
528 525
             $tmp = [];
529 526
             foreach ($h as $v) {
530
-                $tmp[] = '(' . $v[0] . ')';
527
+                $tmp[] = '('.$v[0].')';
531 528
                 $par = array_merge($par, $v[1]);
532 529
             }
533 530
             $sql .= implode(' AND ', $tmp).' ';
@@ -561,7 +558,7 @@  discard block
 block discarded – undo
561 558
                     $this->with(implode('.', $temp));
562 559
                     $table = array_reduce(
563 560
                         $temp,
564
-                        function ($carry, $item) use (&$table) {
561
+                        function($carry, $item) use (&$table) {
565 562
                             return $table->getRelation($item)->table;
566 563
                         }
567 564
                     );
@@ -570,7 +567,7 @@  discard block
 block discarded – undo
570 567
                 }
571 568
                 unset($fields[$k]);
572 569
                 foreach ($cols as $col) {
573
-                    $fields[] = $table . '.' . $col;
570
+                    $fields[] = $table.'.'.$col;
574 571
                 }
575 572
             }
576 573
         }
@@ -602,9 +599,9 @@  discard block
 block discarded – undo
602 599
             return $this->qiterator;
603 600
         }
604 601
         $aliases = [];
605
-        $getAlias = function ($name) use (&$aliases) {
602
+        $getAlias = function($name) use (&$aliases) {
606 603
             // to bypass use: return $name;
607
-            return $aliases[$name] = $aliases[$name] ?? 'alias' . static::SEP . count($aliases);
604
+            return $aliases[$name] = $aliases[$name] ?? 'alias'.static::SEP.count($aliases);
608 605
         };
609 606
         $table = $this->definition->getName();
610 607
         if ($fields !== null) {
@@ -620,61 +617,61 @@  discard block
 block discarded – undo
620 617
         $h = $this->having;
621 618
         $o = $this->order;
622 619
         $g = $this->group;
623
-        $j = array_map(function ($v) { return clone $v; }, $this->joins);
620
+        $j = array_map(function($v) { return clone $v; }, $this->joins);
624 621
         foreach ($this->definition->getRelations() as $k => $relation) {
625 622
             foreach ($f as $kk => $field) {
626
-                if (strpos($field, $k . '.') === 0) {
627
-                    $relations[$k] = [ $relation, $table ];
628
-                    $f[$kk] = str_replace($k . '.', $getAlias($k) . '.', $field);
623
+                if (strpos($field, $k.'.') === 0) {
624
+                    $relations[$k] = [$relation, $table];
625
+                    $f[$kk] = str_replace($k.'.', $getAlias($k).'.', $field);
629 626
                 }
630 627
             }
631 628
             foreach ($w as $kk => $v) {
632
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
633
-                    $relations[$k] = [ $relation, $table ];
634
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $v[0]);
629
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
630
+                    $relations[$k] = [$relation, $table];
631
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $v[0]);
635 632
                 }
636 633
             }
637 634
             foreach ($h as $kk => $v) {
638
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
639
-                    $relations[$k] = [ $relation, $table ];
640
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $v[0]);
635
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
636
+                    $relations[$k] = [$relation, $table];
637
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $v[0]);
641 638
                 }
642 639
             }
643
-            if (isset($o[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $o[0])) {
644
-                $relations[$k] = [ $relation, $table ];
645
-                $o[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $o[0]);
640
+            if (isset($o[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $o[0])) {
641
+                $relations[$k] = [$relation, $table];
642
+                $o[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $o[0]);
646 643
             }
647
-            if (isset($g[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $g[0])) {
648
-                $relations[$k] = [ $relation, $table ];
649
-                $g[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $g[0]);
644
+            if (isset($g[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $g[0])) {
645
+                $relations[$k] = [$relation, $table];
646
+                $g[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $g[0]);
650 647
             }
651 648
             foreach ($j as $kk => $v) {
652 649
                 foreach ($v->keymap as $kkk => $vv) {
653
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv)) {
654
-                        $relations[$k] = [ $relation, $table ];
655
-                        $j[$k]->keymap[$kkk] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $vv);
650
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vv)) {
651
+                        $relations[$k] = [$relation, $table];
652
+                        $j[$k]->keymap[$kkk] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $vv);
656 653
                     }
657 654
                 }
658 655
             }
659 656
         }
660 657
         $select = [];
661 658
         foreach ($f as $k => $field) {
662
-            $select[] = $field . (!is_numeric($k) ? ' ' . $k : '');
659
+            $select[] = $field.(!is_numeric($k) ? ' '.$k : '');
663 660
         }
664 661
         foreach ($this->withr as $name => $relation) {
665 662
             foreach ($relation[0]->table->getColumns() as $column) {
666
-                $select[] = $getAlias($name) . '.' . $column . ' ' . $getAlias($name . static::SEP . $column);
663
+                $select[] = $getAlias($name).'.'.$column.' '.$getAlias($name.static::SEP.$column);
667 664
             }
668 665
         }
669 666
         $sql = 'SELECT '.implode(', ', $select).' FROM '.$table.' ';
670 667
         $par = [];
671 668
         foreach ($j as $k => $v) {
672
-            $sql .= ($v->many ? 'LEFT ' : '' ) . 'JOIN '.$v->table->getName().' '.$k.' ON ';
669
+            $sql .= ($v->many ? 'LEFT ' : '').'JOIN '.$v->table->getName().' '.$k.' ON ';
673 670
             $tmp = [];
674 671
             foreach ($v->keymap as $kk => $vv) {
675 672
                 $tmp[] = $kk.' = '.$vv;
676 673
             }
677
-            $sql .= implode(' AND ', $tmp) . ' ';
674
+            $sql .= implode(' AND ', $tmp).' ';
678 675
         }
679 676
         foreach ($relations as $relation => $v) {
680 677
             $table = $v[1] !== $this->definition->getName() ? $getAlias($v[1]) : $v[1];
@@ -686,13 +683,13 @@  discard block
 block discarded – undo
686 683
                 foreach ($v->keymap as $kk => $vv) {
687 684
                     $tmp[] = $table.'.'.$kk.' = '.$alias.'.'.$vv.' ';
688 685
                 }
689
-                $sql .= implode(' AND ', $tmp) . ' ';
686
+                $sql .= implode(' AND ', $tmp).' ';
690 687
                 $sql .= 'LEFT JOIN '.$v->table->getName().' '.$getAlias($relation).' ON ';
691 688
                 $tmp = [];
692 689
                 foreach ($v->pivot_keymap as $kk => $vv) {
693 690
                     $tmp[] = $getAlias($relation).'.'.$vv.' = '.$alias.'.'.$kk.' ';
694 691
                 }
695
-                $sql .= implode(' AND ', $tmp) . ' ';
692
+                $sql .= implode(' AND ', $tmp).' ';
696 693
             } else {
697 694
                 $alias = $getAlias($relation);
698 695
 
@@ -702,36 +699,36 @@  discard block
 block discarded – undo
702 699
                     $tmp[] = $table.'.'.$kk.' = '.$alias.'.'.$vv.' ';
703 700
                 }
704 701
                 if ($v->sql) {
705
-                    $tmp[] = $v->sql . ' ';
702
+                    $tmp[] = $v->sql.' ';
706 703
                     $par = array_merge($par, $v->par ?? []);
707 704
                 }
708
-                $sql .= implode(' AND ', $tmp) . ' ';
705
+                $sql .= implode(' AND ', $tmp).' ';
709 706
             }
710 707
         }
711 708
         if (count($w)) {
712 709
             $sql .= 'WHERE ';
713 710
             $tmp = [];
714 711
             foreach ($w as $v) {
715
-                $tmp[] = '(' . $v[0] . ')';
712
+                $tmp[] = '('.$v[0].')';
716 713
                 $par = array_merge($par, $v[1]);
717 714
             }
718 715
             $sql .= implode(' AND ', $tmp).' ';
719 716
         }
720 717
         if (count($g)) {
721
-            $sql .= 'GROUP BY ' . $g[0] . ' ';
718
+            $sql .= 'GROUP BY '.$g[0].' ';
722 719
             $par = array_merge($par, $g[1]);
723 720
         }
724 721
         if (count($h)) {
725 722
             $sql .= 'HAVING ';
726 723
             $tmp = [];
727 724
             foreach ($h as $v) {
728
-                $tmp[] = '(' . $v[0] . ')';
725
+                $tmp[] = '('.$v[0].')';
729 726
                 $par = array_merge($par, $v[1]);
730 727
             }
731 728
             $sql .= implode(' AND ', $tmp).' ';
732 729
         }
733 730
         if (count($o)) {
734
-            $sql .= 'ORDER BY ' . $o[0] . ' ';
731
+            $sql .= 'ORDER BY '.$o[0].' ';
735 732
             $par = array_merge($par, $o[1]);
736 733
         }
737 734
         $porder = [];
@@ -739,30 +736,30 @@  discard block
 block discarded – undo
739 736
             $porder[] = $this->getColumn($field)['name'];
740 737
         }
741 738
         if (count($porder)) {
742
-            $sql .= (count($o) ? ', ' : 'ORDER BY ') . implode(', ', $porder) . ' ';
739
+            $sql .= (count($o) ? ', ' : 'ORDER BY ').implode(', ', $porder).' ';
743 740
         }
744 741
 
745 742
         if ($this->li_of[0]) {
746 743
             if ($this->db->driverName() === 'oracle') {
747
-                if ((int)$this->db->driverOption('version', 0) >= 12) {
748
-                    $sql .= 'OFFSET ' . $this->li_of[1] . ' ROWS FETCH NEXT ' . $this->li_of[0] . ' ROWS ONLY';
744
+                if ((int) $this->db->driverOption('version', 0) >= 12) {
745
+                    $sql .= 'OFFSET '.$this->li_of[1].' ROWS FETCH NEXT '.$this->li_of[0].' ROWS ONLY';
749 746
                 } else {
750
-                    $f = array_map(function ($v) {
747
+                    $f = array_map(function($v) {
751 748
                         $v = explode(' ', trim($v), 2);
752 749
                         if (count($v) === 2) { return $v[1]; }
753 750
                         $v = explode('.', $v[0], 2);
754 751
                         return count($v) === 2 ? $v[1] : $v[0];
755 752
                     }, $select);
756
-                    $sql = "SELECT " . implode(', ', $f) . " 
753
+                    $sql = "SELECT ".implode(', ', $f)." 
757 754
                             FROM (
758 755
                                 SELECT tbl__.*, rownum rnum__ FROM (
759
-                                    " . $sql . "
756
+                                    " . $sql."
760 757
                                 ) tbl__ 
761
-                                WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1]) . "
758
+                                WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1])."
762 759
                             ) WHERE rnum__ > " . $this->li_of[1];
763 760
                 }
764 761
             } else {
765
-                $sql .= 'LIMIT ' . $this->li_of[0] . ' OFFSET ' . $this->li_of[1];
762
+                $sql .= 'LIMIT '.$this->li_of[0].' OFFSET '.$this->li_of[1];
766 763
             }
767 764
         }
768 765
         return $this->qiterator = new TableQueryIterator(
@@ -812,7 +809,7 @@  discard block
 block discarded – undo
812 809
                 $ret[$k] = str_repeat(' ', 255);
813 810
                 $par[] = &$ret[$k];
814 811
             }
815
-            $sql .= ' RETURNING ' . implode(',', $primary) . ' INTO ' . implode(',', array_fill(0, count($primary), '?'));
812
+            $sql .= ' RETURNING '.implode(',', $primary).' INTO '.implode(',', array_fill(0, count($primary), '?'));
816 813
             $this->db->query($sql, $par);
817 814
             return $ret;
818 815
         } else {
@@ -844,7 +841,7 @@  discard block
 block discarded – undo
844 841
         }
845 842
         $sql = 'UPDATE '.$table.' SET ';
846 843
         $par = [];
847
-        $sql .= implode(', ', array_map(function ($v) { return $v . ' = ?'; }, array_keys($update))) . ' ';
844
+        $sql .= implode(', ', array_map(function($v) { return $v.' = ?'; }, array_keys($update))).' ';
848 845
         $par = array_merge($par, array_values($update));
849 846
         if (count($this->where)) {
850 847
             $sql .= 'WHERE ';
@@ -853,7 +850,7 @@  discard block
 block discarded – undo
853 850
                 $tmp[] = $v[0];
854 851
                 $par = array_merge($par, $v[1]);
855 852
             }
856
-            $sql .= implode(' AND ', $tmp) . ' ';
853
+            $sql .= implode(' AND ', $tmp).' ';
857 854
         }
858 855
         if (count($this->order)) {
859 856
             $sql .= $this->order[0];
@@ -877,7 +874,7 @@  discard block
 block discarded – undo
877 874
                 $tmp[] = $v[0];
878 875
                 $par = array_merge($par, $v[1]);
879 876
             }
880
-            $sql .= implode(' AND ', $tmp) . ' ';
877
+            $sql .= implode(' AND ', $tmp).' ';
881 878
         }
882 879
         if (count($this->order)) {
883 880
             $sql .= $this->order[0];
@@ -897,13 +894,13 @@  discard block
 block discarded – undo
897 894
         $table = $this->definition;
898 895
         array_reduce(
899 896
             $parts,
900
-            function ($carry, $item) use (&$table) {
897
+            function($carry, $item) use (&$table) {
901 898
                 $relation = $table->getRelation($item);
902 899
                 if (!$relation) {
903 900
                     throw new DBException('Invalid relation name');
904 901
                 }
905
-                $name = $carry ? $carry . static::SEP . $item : $item;
906
-                $this->withr[$name] = [ $relation, $carry ?? $table->getName() ];
902
+                $name = $carry ? $carry.static::SEP.$item : $item;
903
+                $this->withr[$name] = [$relation, $carry ?? $table->getName()];
907 904
                 $table = $relation->table;
908 905
                 return $name;
909 906
             }
Please login to merge, or discard this patch.
src/DriverAbstract.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
         $new = '';
13 13
         $par = array_values($par);
14 14
         if (substr_count($sql, '?') === 2 && !is_array($par[0])) {
15
-            $par = [ $par ];
15
+            $par = [$par];
16 16
         }
17 17
         $parts = explode('??', $sql);
18 18
         $index = 0;
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
             $index += count($tmp) - 1;
23 23
             if (isset($par[$index])) {
24 24
                 if (!is_array($par[$index])) {
25
-                    $par[$index] = [ $par[$index] ];
25
+                    $par[$index] = [$par[$index]];
26 26
                 }
27 27
                 $params = $par[$index];
28 28
                 array_splice($par, $index, 1, $params);
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
                 $new .= implode(',', array_fill(0, count($params), '?'));
31 31
             }
32 32
         }
33
-        return [ $new, $par ];
33
+        return [$new, $par];
34 34
     }
35 35
     /**
36 36
      * Run a query (prepare & execute).
Please login to merge, or discard this patch.
src/driver/postgre/Statement.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
             $data = array();
24 24
         }
25 25
         $temp = (is_array($data) && count($data)) ?
26
-            \pg_query_params($this->driver, $this->statement, $data) :
27
-            \pg_query_params($this->driver, $this->statement, array());
26
+            \pg_query_params($this->driver, $this->statement, $data) : \pg_query_params($this->driver, $this->statement, array());
28 27
         if (!$temp) {
29 28
             throw new DBException('Could not execute query : '.\pg_last_error($this->driver).' <'.$this->statement.'>');
30 29
         }
Please login to merge, or discard this patch.
src/driver/postgre/Result.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
     }
63 63
     public function next()
64 64
     {
65
-        $this->fetched ++;
65
+        $this->fetched++;
66 66
         $this->last = \pg_fetch_array($this->statement, null, \PGSQL_ASSOC);
67 67
     }
68 68
     public function valid()
Please login to merge, or discard this patch.
src/driver/oracle/Result.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
     }
65 65
     public function next()
66 66
     {
67
-        $this->fetched ++;
67
+        $this->fetched++;
68 68
         $this->last = \oci_fetch_array($this->statement, \OCI_ASSOC + \OCI_RETURN_NULLS + \OCI_RETURN_LOBS);
69 69
     }
70 70
     public function valid()
Please login to merge, or discard this patch.
src/driver/oracle/Driver.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 
76 76
     public function begin() : bool
77 77
     {
78
-         return $this->transaction = true;
78
+            return $this->transaction = true;
79 79
     }
80 80
     public function commit() : bool
81 81
     {
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
                     }
200 200
                     return $new;
201 201
                 })
202
-                 as $relation
202
+                    as $relation
203 203
             ) {
204 204
                 $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_NAME'];
205 205
                 $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int)$relation['POSITION']-1]] = $relation['COLUMN_NAME'];
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -124,16 +124,16 @@  discard block
 block discarded – undo
124 124
         $columns = Collection::from($this
125 125
             ->query(
126 126
                 "SELECT * FROM all_tab_cols WHERE table_name = ? AND owner = ?",
127
-                [ strtoupper($table), $this->name() ]
127
+                [strtoupper($table), $this->name()]
128 128
             ))
129
-            ->map(function ($v) {
129
+            ->map(function($v) {
130 130
                 $new = [];
131 131
                 foreach ($v as $kk => $vv) {
132 132
                     $new[strtoupper($kk)] = $vv;
133 133
                 }
134 134
                 return $new;
135 135
             })
136
-            ->mapKey(function ($v) { return $v['COLUMN_NAME']; })
136
+            ->mapKey(function($v) { return $v['COLUMN_NAME']; })
137 137
             ->toArray();
138 138
         if (!count($columns)) {
139 139
             throw new DBException('Table not found by name');
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
             ->query(
144 144
                 "SELECT constraint_name FROM all_constraints
145 145
                 WHERE table_name = ? AND constraint_type = ? AND owner = ?",
146
-                [ strtoupper($table), 'P', $owner ]
146
+                [strtoupper($table), 'P', $owner]
147 147
             ))
148
-            ->map(function ($v) {
148
+            ->map(function($v) {
149 149
                 $new = [];
150 150
                 foreach ($v as $kk => $vv) {
151 151
                     $new[strtoupper($kk)] = $vv;
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
                 ->query(
161 161
                     "SELECT column_name FROM all_cons_columns
162 162
                     WHERE table_name = ? AND constraint_name = ? AND owner = ?",
163
-                    [ strtoupper($table), $pkname, $owner ]
163
+                    [strtoupper($table), $pkname, $owner]
164 164
                 ))
165
-                ->map(function ($v) {
165
+                ->map(function($v) {
166 166
                     $new = [];
167 167
                     foreach ($v as $kk => $vv) {
168 168
                         $new[strtoupper($kk)] = $vv;
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
                     LEFT JOIN all_cons_columns cc ON cc.OWNER = ac.OWNER AND cc.CONSTRAINT_NAME = ac.CONSTRAINT_NAME
190 190
                     WHERE ac.OWNER = ? AND ac.R_OWNER = ? AND ac.R_CONSTRAINT_NAME = ? AND ac.CONSTRAINT_TYPE = ?
191 191
                     ORDER BY cc.POSITION",
192
-                    [ $owner, $owner, $pkname, 'R' ]
192
+                    [$owner, $owner, $pkname, 'R']
193 193
                 ))
194
-                ->map(function ($v) {
194
+                ->map(function($v) {
195 195
                     $new = [];
196 196
                     foreach ($v as $kk => $vv) {
197 197
                         $new[strtoupper($kk)] = $vv;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
                  as $relation
202 202
             ) {
203 203
                 $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_NAME'];
204
-                $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int)$relation['POSITION']-1]] = $relation['COLUMN_NAME'];
204
+                $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int) $relation['POSITION'] - 1]] = $relation['COLUMN_NAME'];
205 205
             }
206 206
             foreach ($relations as $data) {
207 207
                 $rtable = $this->table($data['table'], true);
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
                                 ac.OWNER = ? AND ac.R_OWNER = ? AND ac.TABLE_NAME = ? AND ac.CONSTRAINT_TYPE = ? AND
226 226
                                 cc.COLUMN_NAME IN (??)
227 227
                             ORDER BY POSITION",
228
-                            [ $owner, $owner, $data['table'], 'R', $columns ]
228
+                            [$owner, $owner, $data['table'], 'R', $columns]
229 229
                         ))
230
-                        ->map(function ($v) {
230
+                        ->map(function($v) {
231 231
                             $new = [];
232 232
                             foreach ($v as $kk => $vv) {
233 233
                                 $new[strtoupper($kk)] = $vv;
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
                     $rcolumns = Collection::from($this
246 246
                         ->query(
247 247
                             "SELECT COLUMN_NAME FROM all_cons_columns WHERE OWNER = ? AND CONSTRAINT_NAME = ? ORDER BY POSITION",
248
-                            [ $owner, current($foreign['keymap']) ]
248
+                            [$owner, current($foreign['keymap'])]
249 249
                         ))
250
-                        ->map(function ($v) {
250
+                        ->map(function($v) {
251 251
                             $new = [];
252 252
                             foreach ($v as $kk => $vv) {
253 253
                                 $new[strtoupper($kk)] = $vv;
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
                     $relname = $foreign['table'];
263 263
                     $cntr = 1;
264 264
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
265
-                        $relname = $foreign['table'] . '_' . (++ $cntr);
265
+                        $relname = $foreign['table'].'_'.(++$cntr);
266 266
                     }
267 267
                     $definition->addRelation(
268 268
                         new TableRelation(
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
                     $relname = $data['table'];
279 279
                     $cntr = 1;
280 280
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
281
-                        $relname = $data['table'] . '_' . (++ $cntr);
281
+                        $relname = $data['table'].'_'.(++$cntr);
282 282
                     }
283 283
                     $definition->addRelation(
284 284
                         new TableRelation(
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
                     LEFT JOIN all_cons_columns cc ON cc.OWNER = ac.OWNER AND cc.CONSTRAINT_NAME = ac.CONSTRAINT_NAME
303 303
                     WHERE ac.OWNER = ? AND ac.R_OWNER = ? AND ac.TABLE_NAME = ? AND ac.CONSTRAINT_TYPE = ?
304 304
                     ORDER BY cc.POSITION",
305
-                    [ $owner, $owner, strtoupper($table), 'R' ]
305
+                    [$owner, $owner, strtoupper($table), 'R']
306 306
                 ))
307
-                ->map(function ($v) {
307
+                ->map(function($v) {
308 308
                     $new = [];
309 309
                     foreach ($v as $kk => $vv) {
310 310
                         $new[strtoupper($kk)] = $vv;
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
                 $rcolumns = Collection::from($this
321 321
                     ->query(
322 322
                         "SELECT COLUMN_NAME FROM all_cons_columns WHERE OWNER = ? AND CONSTRAINT_NAME = ? ORDER BY POSITION",
323
-                        [ $owner, current($data['keymap']) ]
323
+                        [$owner, current($data['keymap'])]
324 324
                     ))
325
-                    ->map(function ($v) {
325
+                    ->map(function($v) {
326 326
                         $new = [];
327 327
                         foreach ($v as $kk => $vv) {
328 328
                             $new[strtoupper($kk)] = $vv;
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
                 $relname = $data['table'];
338 338
                 $cntr = 1;
339 339
                 while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
340
-                    $relname = $data['table'] . '_' . (++ $cntr);
340
+                    $relname = $data['table'].'_'.(++$cntr);
341 341
                 }
342 342
                 $definition->addRelation(
343 343
                     new TableRelation(
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
                 "SELECT TABLE_NAME FROM ALL_TABLES where OWNER = ?",
359 359
                 [$this->connection['name']]
360 360
             ))
361
-            ->map(function ($v) {
361
+            ->map(function($v) {
362 362
                 $new = [];
363 363
                 foreach ($v as $kk => $vv) {
364 364
                     $new[strtoupper($kk)] = $vv;
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
                 return $new;
367 367
             })
368 368
             ->pluck('TABLE_NAME')
369
-            ->map(function ($v) {
369
+            ->map(function($v) {
370 370
                 return $this->table($v);
371 371
             })
372 372
             ->toArray();
Please login to merge, or discard this patch.
src/driver/sqlite/Result.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
     }
63 63
     public function next()
64 64
     {
65
-        $this->fetched ++;
65
+        $this->fetched++;
66 66
         $this->last = $this->statement->fetchArray(\SQLITE3_ASSOC);
67 67
     }
68 68
     public function valid()
Please login to merge, or discard this patch.
src/driver/sqlite/Driver.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
         parse_str($temp[1], $connection['opts']);
23 23
         $connection['name'] = $temp[0];
24 24
         if (!is_file($connection['name']) && is_file('/'.$connection['name'])) {
25
-           $connection['name'] = '/'.$connection['name'];
25
+            $connection['name'] = '/'.$connection['name'];
26 26
         }
27 27
         $this->connection = $connection;
28 28
     }
Please login to merge, or discard this patch.
src/driver/mysql/Result.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
                 if ($temp) {
30 30
                     $temp = $temp->fetch_fields();
31 31
                     if ($temp) {
32
-                        $columns = array_map(function ($v) { return $v->name; }, $temp);
32
+                        $columns = array_map(function($v) { return $v->name; }, $temp);
33 33
                     }
34 34
                 }
35 35
                 if (count($columns)) {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     }
68 68
     public function current()
69 69
     {
70
-        return $this->nativeDriver ? $this->last : array_map(function ($v) { return $v; }, $this->row);
70
+        return $this->nativeDriver ? $this->last : array_map(function($v) { return $v; }, $this->row);
71 71
     }
72 72
     public function rewind()
73 73
     {
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     }
85 85
     public function next()
86 86
     {
87
-        $this->fetched ++;
87
+        $this->fetched++;
88 88
         $this->last = $this->nativeDriver ? $this->result->fetch_assoc() : $this->statement->fetch();
89 89
     }
90 90
     public function valid()
Please login to merge, or discard this patch.