Completed
Push — master ( 321b50...bfb7e6 )
by Ivan
14:19
created
src/driver/postgre/Driver.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
             if (isset($this->connection['opts']['search_path'])) {
46 46
                 @\pg_query(
47 47
                     $this->lnk,
48
-                    "SET search_path TO " . pg_escape_string($this->connection['opts']['search_path'])
48
+                    "SET search_path TO ".pg_escape_string($this->connection['opts']['search_path'])
49 49
                 );
50 50
             }
51 51
             if (!isset($this->connection['opts']['search_path']) && isset($this->connection['opts']['schema'])) {
52
-                @\pg_query($this->lnk, "SET search_path TO " . pg_escape_string($this->connection['opts']['schema']));
52
+                @\pg_query($this->lnk, "SET search_path TO ".pg_escape_string($this->connection['opts']['schema']));
53 53
             }
54 54
             if (isset($this->connection['opts']['timezone'])) {
55 55
                 @\pg_query($this->lnk, "SET TIME ZONE '".pg_escape_string($this->connection['opts']['timezone'])."'");
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
         $res = \pg_query($this->lnk, $sql);
88 88
         if ($log) {
89 89
             $tm = microtime(true) - $tm;
90
-            if ($tm >= (float)$this->option('log_slow', 0)) {
90
+            if ($tm >= (float) $this->option('log_slow', 0)) {
91 91
                 @file_put_contents(
92 92
                     $log,
93
-                    '--' . date('Y-m-d H:i:s') . ' ' . sprintf('%01.6f', $tm) . "s\r\n" .
94
-                    $sql . "\r\n" .
93
+                    '--'.date('Y-m-d H:i:s').' '.sprintf('%01.6f', $tm)."s\r\n".
94
+                    $sql."\r\n".
95 95
                     "\r\n",
96 96
                     FILE_APPEND
97 97
                 );
Please login to merge, or discard this patch.
src/driver/postgre/Result.php 1 patch
Spacing   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@  discard block
 block discarded – undo
37 37
             $temp = @\pg_query(
38 38
                 $this->driver,
39 39
                 $sequence ?
40
-                    'SELECT currval('.@\pg_escape_string($this->driver, $sequence).')' :
41
-                    'SELECT lastval()'
40
+                    'SELECT currval('.@\pg_escape_string($this->driver, $sequence).')' : 'SELECT lastval()'
42 41
             );
43 42
             if ($temp) {
44 43
                 $res = \pg_fetch_row($temp);
@@ -76,8 +75,8 @@  discard block
 block discarded – undo
76 75
     }
77 76
     public function next(): void
78 77
     {
79
-        $this->fetched ++;
80
-        $this->last = \pg_fetch_array($this->statement, null, \PGSQL_ASSOC)?:null;
78
+        $this->fetched++;
79
+        $this->last = \pg_fetch_array($this->statement, null, \PGSQL_ASSOC) ?: null;
81 80
         if (is_array($this->last)) {
82 81
             $this->cast();
83 82
         }
@@ -90,11 +89,11 @@  discard block
 block discarded – undo
90 89
     protected function cast(): void
91 90
     {
92 91
         if (!count($this->types)) {
93
-            foreach (array_keys($this->last??[]) as $k => $v) {
92
+            foreach (array_keys($this->last ?? []) as $k => $v) {
94 93
                 $this->types[$v] = \pg_field_type($this->statement, $k);
95 94
             }
96 95
         }
97
-        foreach ($this->last??[] as $k => $v) {
96
+        foreach ($this->last ?? [] as $k => $v) {
98 97
             if (is_null($v) || !isset($this->types[$k])) {
99 98
                 continue;
100 99
             }
@@ -102,15 +101,15 @@  discard block
 block discarded – undo
102 101
                 case 'int2':
103 102
                 case 'int4':
104 103
                 case 'int8':
105
-                    $this->last[$k] = (int)$v;
104
+                    $this->last[$k] = (int) $v;
106 105
                     break;
107 106
                 case 'bit':
108 107
                 case 'bool':
109
-                    $this->last[$k] = $v !== 'f' && (int)$v ? true : false;
108
+                    $this->last[$k] = $v !== 'f' && (int) $v ? true : false;
110 109
                     break;
111 110
                 case 'float4':
112 111
                 case 'float8':
113
-                    $this->last[$k] = (float)$v;
112
+                    $this->last[$k] = (float) $v;
114 113
                     break;
115 114
                 case 'money':
116 115
                 case 'numeric':
Please login to merge, or discard this patch.
src/driver/mysql/Schema.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
             $table = $temp[1];
28 28
         }
29 29
 
30
-        if (isset($tables[$schema . '.' . $table])) {
31
-            return $tables[$schema . '.' . $table];
30
+        if (isset($tables[$schema.'.'.$table])) {
31
+            return $tables[$schema.'.'.$table];
32 32
         }
33 33
 
34 34
         static $comments = [];
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
             $comments[$schema] = Collection::from(
37 37
                 $this->query(
38 38
                     "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ?",
39
-                    [ $schema ]
39
+                    [$schema]
40 40
                 )
41 41
             )
42
-            ->mapKey(function (array $v): string {
42
+            ->mapKey(function(array $v): string {
43 43
                 return $v['TABLE_NAME'];
44 44
             })
45 45
             ->pluck('TABLE_COMMENT')
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
                      WHERE
62 62
                         (TABLE_SCHEMA = ? OR REFERENCED_TABLE_SCHEMA = ?) AND
63 63
                         TABLE_NAME IS NOT NULL AND REFERENCED_TABLE_NAME IS NOT NULL",
64
-                    [ $main, $main ]
64
+                    [$main, $main]
65 65
                 )
66 66
             )->toArray();
67 67
             foreach ($col as $row) {
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
                 if ($row['REFERENCED_TABLE_SCHEMA'] !== $main) {
72 72
                     $additional[] = $row['REFERENCED_TABLE_SCHEMA'];
73 73
                 }
74
-                $relationsT[$row['TABLE_SCHEMA'] . '.' . $row['TABLE_NAME']][] = $row;
75
-                $relationsR[$row['REFERENCED_TABLE_SCHEMA'] . '.' . $row['REFERENCED_TABLE_NAME']][] = $row;
74
+                $relationsT[$row['TABLE_SCHEMA'].'.'.$row['TABLE_NAME']][] = $row;
75
+                $relationsR[$row['REFERENCED_TABLE_SCHEMA'].'.'.$row['REFERENCED_TABLE_NAME']][] = $row;
76 76
             }
77 77
             foreach (array_filter(array_unique($additional)) as $s) {
78 78
                 $col = Collection::from(
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
                         WHERE
85 85
                             TABLE_SCHEMA = ? AND REFERENCED_TABLE_SCHEMA = ? AND
86 86
                             TABLE_NAME IS NOT NULL AND REFERENCED_TABLE_NAME IS NOT NULL",
87
-                        [ $s, $s ]
87
+                        [$s, $s]
88 88
                     )
89 89
                 )->toArray();
90 90
                 foreach ($col as $row) {
91
-                    $relationsT[$row['TABLE_SCHEMA'] . '.' . $row['TABLE_NAME']][] = $row;
92
-                    $relationsR[$row['REFERENCED_TABLE_SCHEMA'] . '.' . $row['REFERENCED_TABLE_NAME']][] = $row;
91
+                    $relationsT[$row['TABLE_SCHEMA'].'.'.$row['TABLE_NAME']][] = $row;
92
+                    $relationsR[$row['REFERENCED_TABLE_SCHEMA'].'.'.$row['REFERENCED_TABLE_NAME']][] = $row;
93 93
                 }
94 94
             }
95 95
         }
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
         if (!count($columns)) {
99 99
             throw new DBException('Table not found by name');
100 100
         }
101
-        $tables[$schema . '.' . $table] = $definition = (new Table($table, $schema))
101
+        $tables[$schema.'.'.$table] = $definition = (new Table($table, $schema))
102 102
             ->addColumns(
103 103
                 $columns
104 104
                     ->clone()
105
-                    ->mapKey(function (array $v): string {
105
+                    ->mapKey(function(array $v): string {
106 106
                         return $v['Field'];
107 107
                     })
108
-                    ->map(function (array $v): array {
108
+                    ->map(function(array $v): array {
109 109
                         $v['length'] = null;
110 110
                         if (!isset($v['Type'])) {
111 111
                             return $v;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                             default:
128 128
                                 if (strpos($type, 'char') !== false && strpos($type, '(') !== false) {
129 129
                                     // extract length from varchar
130
-                                    $v['length'] = (int)explode(')', explode('(', $type)[1])[0];
130
+                                    $v['length'] = (int) explode(')', explode('(', $type)[1])[0];
131 131
                                     $v['length'] = $v['length'] > 0 ? $v['length'] : null;
132 132
                                 }
133 133
                                 break;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
             ->setPrimaryKey(
140 140
                 $columns
141 141
                     ->clone()
142
-                    ->filter(function (array $v): bool {
142
+                    ->filter(function(array $v): bool {
143 143
                         return $v['Key'] === 'PRI';
144 144
                     })
145 145
                     ->pluck('Field')
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
             // assuming current table is on the "one" end having "many" records in the referencing table
154 154
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
155 155
             $relations = [];
156
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) {
157
-                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'] . '.' .
156
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) {
157
+                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'].'.'.
158 158
                     $relation['TABLE_NAME'];
159 159
                 $relations[$relation['CONSTRAINT_NAME']]['keymap'][$relation['REFERENCED_COLUMN_NAME']] =
160 160
                     $relation['COLUMN_NAME'];
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
                 $usedcol = [];
172 172
                 if (count($columns)) {
173 173
                     foreach (Collection::from($relationsT[$data['table']] ?? [])
174
-                        ->filter(function (array $v) use ($columns): bool {
174
+                        ->filter(function(array $v) use ($columns): bool {
175 175
                             return in_array($v['COLUMN_NAME'], $columns);
176 176
                         })
177
-                        ->map(function (array $v): array {
177
+                        ->map(function(array $v): array {
178 178
                             $new = [];
179 179
                             foreach ($v as $kk => $vv) {
180 180
                                 $new[strtoupper($kk)] = $vv;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
                             return $new;
183 183
                         }) as $relation
184 184
                     ) {
185
-                        $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'] . '.' .
185
+                        $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'].'.'.
186 186
                             $relation['REFERENCED_TABLE_NAME'];
187 187
                         $foreign[$relation['CONSTRAINT_NAME']]['keymap'][$relation['COLUMN_NAME']] =
188 188
                             $relation['REFERENCED_COLUMN_NAME'];
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
                     $orig = $relname;
200 200
                     $cntr = 1;
201 201
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
202
-                        $relname = $orig . '_' . (++ $cntr);
202
+                        $relname = $orig.'_'.(++$cntr);
203 203
                     }
204 204
                     $definition->addRelation(
205 205
                         new TableRelation(
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
                     $orig = $relname;
221 221
                     $cntr = 1;
222 222
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
223
-                        $relname = $orig . '_' . (++ $cntr);
223
+                        $relname = $orig.'_'.(++$cntr);
224 224
                     }
225 225
                     $definition->addRelation(
226 226
                         new TableRelation(
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
             // assuming current table is linked to "one" record in the referenced table
237 237
             // resulting in a "belongsTo" relationship
238 238
             $relations = [];
239
-            foreach (Collection::from($relationsT[$schema . '.' . $table] ?? [])
240
-                ->map(function (array $v): array {
239
+            foreach (Collection::from($relationsT[$schema.'.'.$table] ?? [])
240
+                ->map(function(array $v): array {
241 241
                     $new = [];
242 242
                     foreach ($v as $kk => $vv) {
243 243
                         $new[strtoupper($kk)] = $vv;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                     return $new;
246 246
                 }) as $relation
247 247
             ) {
248
-                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'] . '.' .
248
+                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'].'.'.
249 249
                     $relation['REFERENCED_TABLE_NAME'];
250 250
                 $relations[$relation['CONSTRAINT_NAME']]['keymap'][$relation['COLUMN_NAME']] =
251 251
                     $relation['REFERENCED_COLUMN_NAME'];
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
                 $orig = $relname;
260 260
                 $cntr = 1;
261 261
                 while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
262
-                    $relname = $orig . '_' . (++ $cntr);
262
+                    $relname = $orig.'_'.(++$cntr);
263 263
                 }
264 264
                 $definition->addRelation(
265 265
                     new TableRelation(
@@ -280,23 +280,23 @@  discard block
 block discarded – undo
280 280
                 "SELECT table_name FROM information_schema.tables where table_schema = ?",
281 281
                 [$this->connection['opts']['schema'] ?? $this->connection['name']]
282 282
             ))
283
-            ->map(function (array $v): array {
283
+            ->map(function(array $v): array {
284 284
                 $new = [];
285 285
                 foreach ($v as $kk => $vv) {
286 286
                     $new[strtoupper($kk)] = $vv;
287 287
                 }
288 288
                 return $new;
289 289
             })
290
-            ->mapKey(function (array $v): string {
290
+            ->mapKey(function(array $v): string {
291 291
                 return strtolower($v['TABLE_NAME']);
292 292
             })
293 293
             ->pluck('TABLE_NAME')
294
-            ->map(function (string $v): Table {
294
+            ->map(function(string $v): Table {
295 295
                 return $this->table($v)->toLowerCase();
296 296
             })
297 297
             ->toArray();
298 298
         foreach (array_keys($tables) as $k) {
299
-            $tables[($this->connection['opts']['schema'] ?? $this->connection['name']) . '.' . $k] = &$tables[$k];
299
+            $tables[($this->connection['opts']['schema'] ?? $this->connection['name']).'.'.$k] = &$tables[$k];
300 300
         }
301 301
         return $tables;
302 302
     }
Please login to merge, or discard this patch.
src/Schema.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -64,13 +64,13 @@  discard block
 block discarded – undo
64 64
     
65 65
     public function toArray(): array
66 66
     {
67
-        return array_map(function ($table) {
67
+        return array_map(function($table) {
68 68
             return [
69 69
                 'name' => $table->getName(),
70 70
                 'schema' => $table->getSchema(),
71 71
                 'pkey' => $table->getPrimaryKey(),
72 72
                 'comment' => $table->getComment(),
73
-                'columns' => array_map(function ($column) {
73
+                'columns' => array_map(function($column) {
74 74
                     return [
75 75
                         'name' => $column->getName(),
76 76
                         'type' => $column->getType(),
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
                         'nullable' => $column->isNullable()
82 82
                     ];
83 83
                 }, $table->getFullColumns()),
84
-                'relations' => array_map(function ($rel) {
84
+                'relations' => array_map(function($rel) {
85 85
                     $relation = clone $rel;
86
-                    $relation = (array)$relation;
86
+                    $relation = (array) $relation;
87 87
                     $relation['table'] = $rel->table->getName();
88 88
                     if ($rel->pivot) {
89 89
                         $relation['pivot'] = $rel->pivot->getName();
Please login to merge, or discard this patch.
src/driver/postgre/Statement.php 1 patch
Spacing   +12 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,17 +23,17 @@  discard block
 block discarded – undo
23 23
         if (strpos(strtolower($statement), 'prepare') === 0) {
24 24
             $this->drv->raw($this->statement);
25 25
             if (!isset($this->name)) {
26
-                $this->name = trim((preg_split('(\s+)', trim($this->statement))?:[])[1]??'', '"');
26
+                $this->name = trim((preg_split('(\s+)', trim($this->statement)) ?: [])[1] ?? '', '"');
27 27
             }
28 28
         } elseif ($this->name !== null) {
29 29
             $temp = \pg_prepare($this->driver, $this->name, $this->statement);
30 30
             if (!$temp) {
31 31
                 $log = $this->drv->option('log_file');
32
-                if ($log && (int)$this->drv->option('log_errors', 1)) {
32
+                if ($log && (int) $this->drv->option('log_errors', 1)) {
33 33
                     @file_put_contents(
34 34
                         $log,
35
-                        '--' . date('Y-m-d H:i:s') . ' ERROR PREPARING: ' . \pg_last_error($this->driver) . "\r\n" .
36
-                        $this->statement . "\r\n" .
35
+                        '--'.date('Y-m-d H:i:s').' ERROR PREPARING: '.\pg_last_error($this->driver)."\r\n".
36
+                        $this->statement."\r\n".
37 37
                         "\r\n",
38 38
                         FILE_APPEND
39 39
                     );
@@ -62,22 +62,20 @@  discard block
 block discarded – undo
62 62
         try {
63 63
             if ($this->name !== null) {
64 64
                 $temp = (is_array($data) && count($data)) ?
65
-                    \pg_execute($this->driver, $this->name, $data) :
66
-                    \pg_execute($this->driver, $this->name, array());
65
+                    \pg_execute($this->driver, $this->name, $data) : \pg_execute($this->driver, $this->name, array());
67 66
             } else {
68 67
                 $temp = (is_array($data) && count($data)) ?
69
-                    \pg_query_params($this->driver, $this->statement, $data) :
70
-                    \pg_query_params($this->driver, $this->statement, array());
68
+                    \pg_query_params($this->driver, $this->statement, $data) : \pg_query_params($this->driver, $this->statement, array());
71 69
             }
72 70
         } catch (\Exception $e) {
73 71
             $temp = false;
74 72
         }
75 73
         if (!$temp) {
76
-            if ($log && (int)$this->drv->option('log_errors', 1)) {
74
+            if ($log && (int) $this->drv->option('log_errors', 1)) {
77 75
                 @file_put_contents(
78 76
                     $log,
79
-                    '--' . date('Y-m-d H:i:s') . ' ERROR: ' . \pg_last_error($this->driver) . "\r\n" .
80
-                    $this->statement . "\r\n" .
77
+                    '--'.date('Y-m-d H:i:s').' ERROR: '.\pg_last_error($this->driver)."\r\n".
78
+                    $this->statement."\r\n".
81 79
                     "\r\n",
82 80
                     FILE_APPEND
83 81
                 );
@@ -86,11 +84,11 @@  discard block
 block discarded – undo
86 84
         }
87 85
         if ($log) {
88 86
             $tm = microtime(true) - $tm;
89
-            if ($tm >= (float)$this->drv->option('log_slow', 0)) {
87
+            if ($tm >= (float) $this->drv->option('log_slow', 0)) {
90 88
                 @file_put_contents(
91 89
                     $log,
92
-                    '--' . date('Y-m-d H:i:s') . ' ' . sprintf('%01.6f', $tm) . "s\r\n" .
93
-                    $this->statement . "\r\n" .
90
+                    '--'.date('Y-m-d H:i:s').' '.sprintf('%01.6f', $tm)."s\r\n".
91
+                    $this->statement."\r\n".
94 92
                     "\r\n",
95 93
                     FILE_APPEND
96 94
                 );
Please login to merge, or discard this patch.
src/driver/mysql/Statement.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
             foreach ($lng as $index) {
78 78
                 if (is_resource($data[$index]) && get_resource_type($data[$index]) === 'stream') {
79 79
                     while (!feof($data[$index])) {
80
-                        $this->statement->send_long_data($index, (string)fread($data[$index], $lds));
80
+                        $this->statement->send_long_data($index, (string) fread($data[$index], $lds));
81 81
                     }
82 82
                 } else {
83 83
                     $data[$index] = str_split($data[$index], $lds);
@@ -97,24 +97,24 @@  discard block
 block discarded – undo
97 97
             $res = false;
98 98
         }
99 99
         if (!$res) {
100
-            if ($log && (int)$this->driver->option('log_errors', 1)) {
100
+            if ($log && (int) $this->driver->option('log_errors', 1)) {
101 101
                 @file_put_contents(
102 102
                     $log,
103
-                    '--' . date('Y-m-d H:i:s') . ' ERROR: ' . $this->statement->error . "\r\n" .
104
-                    $this->sql . "\r\n" .
103
+                    '--'.date('Y-m-d H:i:s').' ERROR: '.$this->statement->error."\r\n".
104
+                    $this->sql."\r\n".
105 105
                     "\r\n",
106 106
                     FILE_APPEND
107 107
                 );
108 108
             }
109
-            throw new DBException('Prepared execute error: ' . $this->statement->error);
109
+            throw new DBException('Prepared execute error: '.$this->statement->error);
110 110
         }
111 111
         if ($log) {
112 112
             $tm = microtime(true) - $tm;
113
-            if ($tm >= (float)$this->driver->option('log_slow', 0)) {
113
+            if ($tm >= (float) $this->driver->option('log_slow', 0)) {
114 114
                 @file_put_contents(
115 115
                     $log,
116
-                    '--' . date('Y-m-d H:i:s') . ' ' . sprintf('%01.6f', $tm) . "s\r\n" .
117
-                    $this->sql . "\r\n" .
116
+                    '--'.date('Y-m-d H:i:s').' '.sprintf('%01.6f', $tm)."s\r\n".
117
+                    $this->sql."\r\n".
118 118
                     "\r\n",
119 119
                     FILE_APPEND
120 120
                 );
Please login to merge, or discard this patch.
src/schema/TableQuery.php 1 patch
Spacing   +254 added lines, -258 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     protected array $order = [];
23 23
     protected array $group = [];
24 24
     protected array $having = [];
25
-    protected array $li_of = [0,0,0];
25
+    protected array $li_of = [0, 0, 0];
26 26
     protected array $fields = [];
27 27
     protected array $withr = [];
28 28
     protected array $joins = [];
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
      * @param  Table|string   $table           the name or definition of the main table in the query
37 37
      * @param  bool           $findRelations   should the query builder try to find missing joins
38 38
      */
39
-    public function __construct(DBInterface $db, Table|string $table, bool $findRelations = false)
39
+    public function __construct(DBInterface $db, Table | string $table, bool $findRelations = false)
40 40
     {
41 41
         $this->db = $db;
42 42
         $this->findRelations = $findRelations;
43
-        $this->definition = $table instanceof Table ? $table : $this->db->definition((string)$table);
43
+        $this->definition = $table instanceof Table ? $table : $this->db->definition((string) $table);
44 44
         $primary = $this->definition->getPrimaryKey();
45 45
         $columns = $this->definition->getColumns();
46 46
         $this->pkey = count($primary) ? $primary : $columns;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     {
64 64
         $column = explode('.', $column);
65 65
         if (count($column) === 1) {
66
-            $column = [ $this->definition->getFullName(), $column[0] ];
66
+            $column = [$this->definition->getFullName(), $column[0]];
67 67
             $col = $this->definition->getColumn($column[1]);
68 68
             if (!$col) {
69 69
                 throw new DBException('Invalid column name in own table');
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
                             $path = $this->db->findRelation($this->definition->getName(), $column[0]);
103 103
                         }
104 104
                         if (!count($path)) {
105
-                            throw new DBException('Invalid foreign table / column name: ' . implode(',', $column));
105
+                            throw new DBException('Invalid foreign table / column name: '.implode(',', $column));
106 106
                         }
107 107
                         unset($path[0]);
108 108
                         $this->with(implode('.', $path), false);
@@ -115,26 +115,26 @@  discard block
 block discarded – undo
115 115
             if ($this->definition->hasRelation(implode('.', $column))) {
116 116
                 $this->with(implode('.', $column), false);
117 117
                 $col = $this->definition->getRelation(implode('.', $column))?->table?->getColumn($name);
118
-                $column = [ implode('.', $column), $name ];
118
+                $column = [implode('.', $column), $name];
119 119
             } else {
120 120
                 $this->with(implode('.', $column), false);
121 121
                 $table = $this->definition;
122 122
                 $table = array_reduce(
123 123
                     $column,
124
-                    function ($carry, $item) use (&$table) {
124
+                    function($carry, $item) use (&$table) {
125 125
                         $table = $table->getRelation($item)->table;
126 126
                         return $table;
127 127
                     }
128 128
                 );
129 129
                 $col = $table->getColumn($name);
130
-                $column = [ implode(static::SEP, $column), $name ];
130
+                $column = [implode(static::SEP, $column), $name];
131 131
             }
132 132
         }
133
-        return [ 'name' => implode('.', $column), 'data' => $col ];
133
+        return ['name' => implode('.', $column), 'data' => $col];
134 134
     }
135 135
     protected function normalizeValue(TableColumn $col, mixed $value): mixed
136 136
     {
137
-        $strict = (int)$this->db->driverOption('strict', 0) > 0;
137
+        $strict = (int) $this->db->driverOption('strict', 0) > 0;
138 138
         if ($value === null && $col->isNullable()) {
139 139
             return null;
140 140
         }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
                     $temp = strtotime($value);
145 145
                     if (!$temp) {
146 146
                         if ($strict) {
147
-                            throw new DBException('Invalid value for date column ' . $col->getName());
147
+                            throw new DBException('Invalid value for date column '.$col->getName());
148 148
                         }
149 149
                         return null;
150 150
                     }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
                     return $value->format('Y-m-d');
158 158
                 }
159 159
                 if ($strict) {
160
-                    throw new DBException('Invalid value (unknown data type) for date column ' . $col->getName());
160
+                    throw new DBException('Invalid value (unknown data type) for date column '.$col->getName());
161 161
                 }
162 162
                 return $value;
163 163
             case 'datetime':
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
                     $temp = strtotime($value);
166 166
                     if (!$temp) {
167 167
                         if ($strict) {
168
-                            throw new DBException('Invalid value for datetime column ' . $col->getName());
168
+                            throw new DBException('Invalid value for datetime column '.$col->getName());
169 169
                         }
170 170
                         return null;
171 171
                     }
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
                     return $value->format('Y-m-d H:i:s');
179 179
                 }
180 180
                 if ($strict) {
181
-                    throw new DBException('Invalid value (unknown data type) for datetime column ' . $col->getName());
181
+                    throw new DBException('Invalid value (unknown data type) for datetime column '.$col->getName());
182 182
                 }
183 183
                 return $value;
184 184
             case 'enum':
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
                 if (is_int($value)) {
187 187
                     if (!isset($values[$value])) {
188 188
                         if ($strict) {
189
-                            throw new DBException('Invalid value (using integer) for enum ' . $col->getName());
189
+                            throw new DBException('Invalid value (using integer) for enum '.$col->getName());
190 190
                         }
191 191
                         return $value;
192 192
                     }
@@ -194,23 +194,23 @@  discard block
 block discarded – undo
194 194
                 }
195 195
                 if (!in_array($value, $col->getValues())) {
196 196
                     if ($strict) {
197
-                        throw new DBException('Invalid value for enum ' . $col->getName());
197
+                        throw new DBException('Invalid value for enum '.$col->getName());
198 198
                     }
199 199
                     return 0;
200 200
                 }
201 201
                 return $value;
202 202
             case 'int':
203 203
                 $temp = preg_replace('([^+\-0-9]+)', '', $value);
204
-                return is_string($temp) ? (int)$temp : 0;
204
+                return is_string($temp) ? (int) $temp : 0;
205 205
             case 'float':
206 206
                 $temp = preg_replace('([^+\-0-9.]+)', '', str_replace(',', '.', $value));
207
-                return is_string($temp) ? (float)$temp : 0;
207
+                return is_string($temp) ? (float) $temp : 0;
208 208
             case 'text':
209 209
                 // check using strlen first, in order to avoid hitting mb_ functions which might be polyfilled
210 210
                 // because the polyfill is quite slow
211 211
                 if ($col->hasLength() && strlen($value) > $col->getLength() && mb_strlen($value) > $col->getLength()) {
212 212
                     if ($strict) {
213
-                        throw new DBException('Invalid value for text column ' . $col->getName());
213
+                        throw new DBException('Invalid value for text column '.$col->getName());
214 214
                     }
215 215
                     return mb_substr($value, 0, $col->getLength());
216 216
                 }
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
             if ($column->getBasicType() !== 'text') {
235 235
                 switch ($this->db->driverName()) {
236 236
                     case 'oracle':
237
-                        $name = 'CAST(' . $name . ' AS NVARCHAR(500))';
237
+                        $name = 'CAST('.$name.' AS NVARCHAR(500))';
238 238
                         break;
239 239
                     case 'postgre':
240 240
                         $name = $name.'::text';
@@ -242,45 +242,42 @@  discard block
 block discarded – undo
242 242
                 }
243 243
             }
244 244
             $mode = array_keys($value)[0];
245
-            $value = str_replace(['%', '_'], ['\\%','\\_'], array_values($value)[0]) . '%';
245
+            $value = str_replace(['%', '_'], ['\\%', '\\_'], array_values($value)[0]).'%';
246 246
             if ($mode === 'contains' || $mode === 'icontains') {
247
-                $value = '%' . $value;
247
+                $value = '%'.$value;
248 248
             }
249 249
             if ($mode === 'icontains' || $mode === 'ilike') {
250 250
                 $value = mb_strtoupper($value);
251
-                $name = 'UPPER(' . $name . ')';
251
+                $name = 'UPPER('.$name.')';
252 252
             }
253 253
             return $negate ?
254 254
                 [
255
-                    $name . ' NOT LIKE ?',
256
-                    [ (string)$value ]
257
-                ] :
258
-                [
259
-                    $name . ' LIKE ?',
260
-                    [ (string)$value ]
255
+                    $name.' NOT LIKE ?',
256
+                    [(string) $value]
257
+                ] : [
258
+                    $name.' LIKE ?',
259
+                    [(string) $value]
261 260
                 ];
262 261
         }
263 262
         if (is_null($value)) {
264 263
             return $negate ?
265
-                [ $name . ' IS NOT NULL', [] ]:
266
-                [ $name . ' IS NULL', [] ];
264
+                [$name.' IS NOT NULL', []] : [$name.' IS NULL', []];
267 265
         }
268 266
         if (!is_array($value)) {
269 267
             return $negate ?
270 268
                 [
271
-                    $name . ' <> ?',
272
-                    [ $this->normalizeValue($column, $value) ]
273
-                ] :
274
-                [
275
-                    $name . ' = ?',
276
-                    [ $this->normalizeValue($column, $value) ]
269
+                    $name.' <> ?',
270
+                    [$this->normalizeValue($column, $value)]
271
+                ] : [
272
+                    $name.' = ?',
273
+                    [$this->normalizeValue($column, $value)]
277 274
                 ];
278 275
         }
279 276
         if (isset($value['beg']) && strlen($value['beg']) && (!isset($value['end']) || !strlen($value['end']))) {
280
-            $value = [ 'gte' => $value['beg'] ];
277
+            $value = ['gte' => $value['beg']];
281 278
         }
282 279
         if (isset($value['end']) && strlen($value['end']) && (!isset($value['beg']) || !strlen($value['beg']))) {
283
-            $value = [ 'lte' => $value['end'] ];
280
+            $value = ['lte' => $value['end']];
284 281
         }
285 282
         if (isset($value['beg']) && isset($value['end'])) {
286 283
             return $negate ?
@@ -290,8 +287,7 @@  discard block
 block discarded – undo
290 287
                         $this->normalizeValue($column, $value['beg']),
291 288
                         $this->normalizeValue($column, $value['end'])
292 289
                     ]
293
-                ] :
294
-                [
290
+                ] : [
295 291
                     $name.' BETWEEN ? AND ?',
296 292
                     [
297 293
                         $this->normalizeValue($column, $value['beg']),
@@ -303,42 +299,42 @@  discard block
 block discarded – undo
303 299
             $sql = [];
304 300
             $par = [];
305 301
             if (isset($value['gt'])) {
306
-                $sql[] = $name. ' ' . ($negate ? '<=' : '>') . ' ?';
302
+                $sql[] = $name.' '.($negate ? '<=' : '>').' ?';
307 303
                 $par[] = $this->normalizeValue($column, $value['gt']);
308 304
             }
309 305
             if (isset($value['gte'])) {
310
-                $sql[] = $name. ' ' . ($negate ? '<' : '>=') . ' ?';
306
+                $sql[] = $name.' '.($negate ? '<' : '>=').' ?';
311 307
                 $par[] = $this->normalizeValue($column, $value['gte']);
312 308
             }
313 309
             if (isset($value['lt'])) {
314
-                $sql[] = $name. ' ' . ($negate ? '>=' : '<') . ' ?';
310
+                $sql[] = $name.' '.($negate ? '>=' : '<').' ?';
315 311
                 $par[] = $this->normalizeValue($column, $value['lt']);
316 312
             }
317 313
             if (isset($value['lte'])) {
318
-                $sql[] = $name. ' ' . ($negate ? '>' : '<=') . ' ?';
314
+                $sql[] = $name.' '.($negate ? '>' : '<=').' ?';
319 315
                 $par[] = $this->normalizeValue($column, $value['lte']);
320 316
             }
321 317
             return [
322
-                '(' . implode(' AND ', $sql) . ')',
318
+                '('.implode(' AND ', $sql).')',
323 319
                 $par
324 320
             ];
325 321
         }
326 322
 
327
-        $value = array_values(array_map(function ($v) use ($column) {
323
+        $value = array_values(array_map(function($v) use ($column) {
328 324
             return $this->normalizeValue($column, $v);
329 325
         }, $value));
330 326
         if ($this->db->driverName() === 'oracle') {
331 327
             $sql = [];
332 328
             $par = [];
333 329
             for ($i = 0; $i < count($value); $i += 500) {
334
-                $sql[] = $negate ? $name . ' NOT IN (??)' : $name . ' IN (??)';
330
+                $sql[] = $negate ? $name.' NOT IN (??)' : $name.' IN (??)';
335 331
                 $par[] = array_slice($value, $i, 500);
336 332
             }
337
-            $sql = '(' . implode($negate ? ' AND ' : ' OR ', $sql) . ')';
338
-            return [ $sql, $par ];
333
+            $sql = '('.implode($negate ? ' AND ' : ' OR ', $sql).')';
334
+            return [$sql, $par];
339 335
         }
340 336
         return [
341
-            $negate ? $name . ' NOT IN (??)' : $name . ' IN (??)',
337
+            $negate ? $name.' NOT IN (??)' : $name.' IN (??)',
342 338
             [$value]
343 339
         ];
344 340
     }
@@ -370,7 +366,7 @@  discard block
 block discarded – undo
370 366
                 $par = array_merge($par, $temp[1]);
371 367
             }
372 368
         }
373
-        return $this->where('(' . implode(' OR ', $sql) . ')', $par);
369
+        return $this->where('('.implode(' OR ', $sql).')', $par);
374 370
     }
375 371
     /**
376 372
      * Filter the results matching all of the criteria
@@ -388,7 +384,7 @@  discard block
 block discarded – undo
388 384
                 $par = array_merge($par, $temp[1]);
389 385
             }
390 386
         }
391
-        return $this->where('(' . implode(' AND ', $sql) . ')', $par);
387
+        return $this->where('('.implode(' AND ', $sql).')', $par);
392 388
     }
393 389
     /**
394 390
      * Sort by a column
@@ -403,7 +399,7 @@  discard block
 block discarded – undo
403 399
         } catch (DBException $e) {
404 400
             throw new DBException('Invalid sort column');
405 401
         }
406
-        return $this->order($column . ' ' . ($desc ? 'DESC' : 'ASC'));
402
+        return $this->order($column.' '.($desc ? 'DESC' : 'ASC'));
407 403
     }
408 404
     /**
409 405
      * Group by a column (or columns)
@@ -413,7 +409,7 @@  discard block
 block discarded – undo
413 409
     public function group($column) : self
414 410
     {
415 411
         if (!is_array($column)) {
416
-            $column = [ $column ];
412
+            $column = [$column];
417 413
         }
418 414
         foreach ($column as $k => $v) {
419 415
             $column[$k] = $this->getColumn($v)['name'];
@@ -456,7 +452,7 @@  discard block
 block discarded – undo
456 452
         $this->order = [];
457 453
         $this->having = [];
458 454
         $this->aliases = [];
459
-        $this->li_of = [0,0,0];
455
+        $this->li_of = [0, 0, 0];
460 456
         $this->qiterator = null;
461 457
         return $this;
462 458
     }
@@ -469,7 +465,7 @@  discard block
 block discarded – undo
469 465
     public function groupBy(string $sql, array $params = []) : self
470 466
     {
471 467
         $this->qiterator = null;
472
-        $this->group = [ $sql, $params ];
468
+        $this->group = [$sql, $params];
473 469
         return $this;
474 470
     }
475 471
     /**
@@ -483,7 +479,7 @@  discard block
 block discarded – undo
483 479
     public function join($table, array $fields, string $name = null, bool $multiple = true)
484 480
     {
485 481
         $this->qiterator = null;
486
-        $table = $table instanceof Table ? $table : $this->db->definition((string)$table);
482
+        $table = $table instanceof Table ? $table : $this->db->definition((string) $table);
487 483
         $name = $name ?? $table->getName();
488 484
         if (isset($this->joins[$name]) || $this->definition->hasRelation($name)) {
489 485
             throw new DBException('Alias / table name already in use');
@@ -492,7 +488,7 @@  discard block
 block discarded – undo
492 488
         foreach ($fields as $k => $v) {
493 489
             $k = explode('.', $k, 2);
494 490
             $k = count($k) == 2 ? $k[1] : $k[0];
495
-            $this->joins[$name]->keymap[$this->getColumn($name . '.' . $k)['name']] = $this->getColumn($v)['name'];
491
+            $this->joins[$name]->keymap[$this->getColumn($name.'.'.$k)['name']] = $this->getColumn($v)['name'];
496 492
         }
497 493
         return $this;
498 494
     }
@@ -505,7 +501,7 @@  discard block
 block discarded – undo
505 501
     public function where(string $sql, array $params = []) : self
506 502
     {
507 503
         $this->qiterator = null;
508
-        $this->where[] = [ $sql, $params ];
504
+        $this->where[] = [$sql, $params];
509 505
         return $this;
510 506
     }
511 507
     /**
@@ -517,7 +513,7 @@  discard block
 block discarded – undo
517 513
     public function having(string $sql, array $params = []) : self
518 514
     {
519 515
         $this->qiterator = null;
520
-        $this->having[] = [ $sql, $params ];
516
+        $this->having[] = [$sql, $params];
521 517
         return $this;
522 518
     }
523 519
     /**
@@ -537,12 +533,12 @@  discard block
 block discarded – undo
537 533
                     throw new \Exception();
538 534
                 }
539 535
                 $name = $this->getColumn(trim($name))['name'];
540
-                $sql = $name . ' ' . (strpos(strtolower($sql), ' desc') ? 'DESC' : 'ASC');
536
+                $sql = $name.' '.(strpos(strtolower($sql), ' desc') ? 'DESC' : 'ASC');
541 537
             } catch (\Exception $e) {
542 538
                 $name = null;
543 539
             }
544 540
         }
545
-        $this->order = [ $sql, $params, $name ];
541
+        $this->order = [$sql, $params, $name];
546 542
         return $this;
547 543
     }
548 544
     /**
@@ -554,7 +550,7 @@  discard block
 block discarded – undo
554 550
     public function limit(int $limit, int $offset = 0, bool $limitOnMainTable = false) : self
555 551
     {
556 552
         $this->qiterator = null;
557
-        $this->li_of = [ $limit, $offset, $limitOnMainTable ? 1 : 0 ];
553
+        $this->li_of = [$limit, $offset, $limitOnMainTable ? 1 : 0];
558 554
         return $this;
559 555
     }
560 556
     /**
@@ -565,9 +561,9 @@  discard block
 block discarded – undo
565 561
     {
566 562
         $aliases = [];
567 563
         $aliases_ext = [];
568
-        $getAlias = function ($name) use (&$aliases, &$aliases_ext) {
564
+        $getAlias = function($name) use (&$aliases, &$aliases_ext) {
569 565
             // to bypass use: return $name;
570
-            $aliases[$name] = $aliases[$name] ?? 'alias' . static::SEP . count($aliases);
566
+            $aliases[$name] = $aliases[$name] ?? 'alias'.static::SEP.count($aliases);
571 567
             if (isset($aliases_ext[$name])) {
572 568
                 unset($aliases_ext[$name]);
573 569
             }
@@ -590,7 +586,7 @@  discard block
 block discarded – undo
590 586
         $h = $this->having;
591 587
         $o = $this->order;
592 588
         $g = $this->group;
593
-        $j = array_map(function ($v) {
589
+        $j = array_map(function($v) {
594 590
             return clone $v;
595 591
         }, $this->joins);
596 592
 
@@ -600,28 +596,28 @@  discard block
 block discarded – undo
600 596
                 continue;
601 597
             }
602 598
             foreach ($w as $kk => $v) {
603
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
599
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
604 600
                     $used_relations[] = $k;
605
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $v[0]);
601
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $v[0]);
606 602
                 }
607 603
             }
608 604
             foreach ($h as $kk => $v) {
609
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
605
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
610 606
                     $used_relations[] = $k;
611
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $v[0]);
607
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $v[0]);
612 608
                 }
613 609
             }
614
-            if (isset($g[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $g[0])) {
610
+            if (isset($g[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $g[0])) {
615 611
                 $used_relations[] = $k;
616
-                $g[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $g[0]);
612
+                $g[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $g[0]);
617 613
             }
618 614
             foreach ($j as $kk => $v) {
619 615
                 foreach ($v->keymap as $kkk => $vv) {
620
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv)) {
616
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vv)) {
621 617
                         $used_relations[] = $k;
622 618
                         $j[$kk]->keymap[$kkk] = preg_replace(
623
-                            '(\b'.preg_quote($k . '.'). ')i',
624
-                            $getAlias($k) . '.',
619
+                            '(\b'.preg_quote($k.'.').')i',
620
+                            $getAlias($k).'.',
625 621
                             $vv
626 622
                         );
627 623
                     }
@@ -630,65 +626,65 @@  discard block
 block discarded – undo
630 626
         }
631 627
         foreach ($this->definition->getRelations() as $k => $v) {
632 628
             foreach ($w as $kk => $vv) {
633
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv[0])) {
634
-                    $relations[$k] = [ $v, $table ];
629
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $vv[0])) {
630
+                    $relations[$k] = [$v, $table];
635 631
                     $used_relations[] = $k;
636
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $vv[0]);
632
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $vv[0]);
637 633
                 }
638 634
             }
639
-            if (isset($o[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $o[0])) {
640
-                $relations[$k] = [ $v, $table ];
635
+            if (isset($o[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $o[0])) {
636
+                $relations[$k] = [$v, $table];
641 637
             }
642 638
             foreach ($h as $kk => $vv) {
643
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv[0])) {
644
-                    $relations[$k] = [ $v, $table ];
639
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $vv[0])) {
640
+                    $relations[$k] = [$v, $table];
645 641
                     $used_relations[] = $k;
646
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $vv[0]);
642
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $vv[0]);
647 643
                 }
648 644
             }
649
-            if (isset($g[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $g[0])) {
650
-                $relations[$k] = [ $v, $table ];
645
+            if (isset($g[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $g[0])) {
646
+                $relations[$k] = [$v, $table];
651 647
                 $used_relations[] = $k;
652
-                $g[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $g[0]);
648
+                $g[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $g[0]);
653 649
             }
654 650
             foreach ($j as $kk => $vv) {
655 651
                 foreach ($vv->keymap as $kkk => $vvv) {
656
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vvv)) {
657
-                        $relations[$k] = [ $v, $table ];
652
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vvv)) {
653
+                        $relations[$k] = [$v, $table];
658 654
                         $used_relations[] = $k;
659 655
                         $j[$kk]->keymap[$kkk] =
660
-                            preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $vvv);
656
+                            preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $vvv);
661 657
                     }
662 658
                 }
663 659
             }
664 660
         }
665 661
         foreach ($aliases_ext as $k => $alias) {
666 662
             foreach ($w as $kk => $v) {
667
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
668
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $v[0]);
663
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
664
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $v[0]);
669 665
                     $used_relations[] = $k;
670 666
                 }
671 667
             }
672 668
             foreach ($h as $kk => $v) {
673
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
674
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $v[0]);
669
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
670
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $v[0]);
675 671
                     $used_relations[] = $k;
676 672
                 }
677 673
             }
678
-            if (isset($o[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $o[0])) {
674
+            if (isset($o[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $o[0])) {
679 675
                 $used_relations[] = $k;
680 676
             }
681
-            if (isset($g[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $g[0])) {
682
-                $g[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $g[0]);
677
+            if (isset($g[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $g[0])) {
678
+                $g[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $g[0]);
683 679
                 $used_relations[] = $k;
684 680
             }
685 681
             foreach ($j as $kk => $v) {
686 682
                 foreach ($v->keymap as $kkk => $vv) {
687
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv)) {
683
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vv)) {
688 684
                         $used_relations[] = $k;
689 685
                         $j[$kk]->keymap[$kkk] = preg_replace(
690
-                            '(\b'.preg_quote($k . '.'). ')i',
691
-                            $alias . '.',
686
+                            '(\b'.preg_quote($k.'.').')i',
687
+                            $alias.'.',
692 688
                             $vv
693 689
                         );
694 690
                     }
@@ -707,13 +703,13 @@  discard block
 block discarded – undo
707 703
                     foreach ($v->keymap as $kk => $vv) {
708 704
                         $tmp[] = $table.'.'.$kk.' = '.$alias.'.'.$vv.' ';
709 705
                     }
710
-                    $sql .= implode(' AND ', $tmp) . ' ';
706
+                    $sql .= implode(' AND ', $tmp).' ';
711 707
                     $sql .= 'LEFT JOIN '.$v->table->getFullName().' '.$getAlias($k).' ON ';
712 708
                     $tmp = [];
713 709
                     foreach ($v->pivot_keymap as $kk => $vv) {
714 710
                         $tmp[] = $getAlias($k).'.'.$vv.' = '.$alias.'.'.$kk.' ';
715 711
                     }
716
-                    $sql .= implode(' AND ', $tmp) . ' ';
712
+                    $sql .= implode(' AND ', $tmp).' ';
717 713
                 } else {
718 714
                     $alias = $getAlias($k);
719 715
                     $sql .= 'LEFT JOIN '.$v->table->getFullName().' '.$alias.' ON ';
@@ -722,10 +718,10 @@  discard block
 block discarded – undo
722 718
                         $tmp[] = $table.'.'.$kk.' = '.$alias.'.'.$vv.' ';
723 719
                     }
724 720
                     if ($v->sql) {
725
-                        $tmp[] = $v->sql . ' ';
721
+                        $tmp[] = $v->sql.' ';
726 722
                         $par = array_merge($par, $v->par ?? []);
727 723
                     }
728
-                    $sql .= implode(' AND ', $tmp) . ' ';
724
+                    $sql .= implode(' AND ', $tmp).' ';
729 725
                 }
730 726
             }
731 727
         }
@@ -734,12 +730,12 @@  discard block
 block discarded – undo
734 730
             if ($v->many) {
735 731
                 $jMany = true;
736 732
             }
737
-            $sql .= ($v->many ? 'LEFT ' : '' ) . 'JOIN '.$v->table->getFullName().' '.$k.' ON ';
733
+            $sql .= ($v->many ? 'LEFT ' : '').'JOIN '.$v->table->getFullName().' '.$k.' ON ';
738 734
             $tmp = [];
739 735
             foreach ($v->keymap as $kk => $vv) {
740 736
                 $tmp[] = $kk.' = '.$vv;
741 737
             }
742
-            $sql .= implode(' AND ', $tmp) . ' ';
738
+            $sql .= implode(' AND ', $tmp).' ';
743 739
         }
744 740
         if (!$jMany && !count($used_relations)) {
745 741
             $sql = str_replace('COUNT(DISTINCT ', 'COUNT(', $sql);
@@ -748,20 +744,20 @@  discard block
 block discarded – undo
748 744
             $sql .= 'WHERE ';
749 745
             $tmp = [];
750 746
             foreach ($w as $v) {
751
-                $tmp[] = '(' . $v[0] . ')';
747
+                $tmp[] = '('.$v[0].')';
752 748
                 $par = array_merge($par, $v[1]);
753 749
             }
754 750
             $sql .= implode(' AND ', $tmp).' ';
755 751
         }
756 752
         if (count($g)) {
757
-            $sql .= 'GROUP BY ' . $g[0] . ' ';
753
+            $sql .= 'GROUP BY '.$g[0].' ';
758 754
             $par = array_merge($par, $g[1]);
759 755
         }
760 756
         if (count($h)) {
761 757
             $sql .= 'HAVING ';
762 758
             $tmp = [];
763 759
             foreach ($h as $v) {
764
-                $tmp[] = '(' . $v[0] . ')';
760
+                $tmp[] = '('.$v[0].')';
765 761
                 $par = array_merge($par, $v[1]);
766 762
             }
767 763
             $sql .= implode(' AND ', $tmp).' ';
@@ -796,7 +792,7 @@  discard block
 block discarded – undo
796 792
                     $this->with(implode('.', $temp));
797 793
                     $table = array_reduce(
798 794
                         $temp,
799
-                        function ($carry, $item) use (&$table) {
795
+                        function($carry, $item) use (&$table) {
800 796
                             return $table->getRelation($item)->table;
801 797
                         }
802 798
                     );
@@ -805,7 +801,7 @@  discard block
 block discarded – undo
805 801
                 }
806 802
                 unset($fields[$k]);
807 803
                 foreach ($cols as $col) {
808
-                    $fields[] = $table . '.' . $col;
804
+                    $fields[] = $table.'.'.$col;
809 805
                 }
810 806
             }
811 807
         }
@@ -840,9 +836,9 @@  discard block
 block discarded – undo
840 836
         }
841 837
         $aliases = [];
842 838
         $aliases_ext = [];
843
-        $getAlias = function ($name) use (&$aliases, &$aliases_ext) {
839
+        $getAlias = function($name) use (&$aliases, &$aliases_ext) {
844 840
             // to bypass use: return $name;
845
-            $aliases[$name] = $aliases[$name] ?? 'alias' . static::SEP . count($aliases);
841
+            $aliases[$name] = $aliases[$name] ?? 'alias'.static::SEP.count($aliases);
846 842
             if (isset($aliases_ext[$name])) {
847 843
                 unset($aliases_ext[$name]);
848 844
             }
@@ -867,7 +863,7 @@  discard block
 block discarded – undo
867 863
         $h = $this->having;
868 864
         $o = $this->order;
869 865
         $g = $this->group;
870
-        $j = array_map(function ($v) {
866
+        $j = array_map(function($v) {
871 867
             return clone $v;
872 868
         }, $this->joins);
873 869
 
@@ -881,32 +877,32 @@  discard block
 block discarded – undo
881 877
                 continue;
882 878
             }
883 879
             foreach ($f as $kk => $field) {
884
-                if (strpos($field, $k . '.') === 0) {
885
-                    $f[$kk] = str_replace($k . '.', $getAlias($k) . '.', $field);
880
+                if (strpos($field, $k.'.') === 0) {
881
+                    $f[$kk] = str_replace($k.'.', $getAlias($k).'.', $field);
886 882
                 }
887 883
             }
888 884
             foreach ($w as $kk => $v) {
889
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
890
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $v[0]);
885
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
886
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $v[0]);
891 887
                 }
892 888
             }
893 889
             foreach ($h as $kk => $v) {
894
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
895
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $v[0]);
890
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
891
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $v[0]);
896 892
                 }
897 893
             }
898
-            if (isset($o[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $o[0])) {
899
-                $o[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $o[0]);
894
+            if (isset($o[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $o[0])) {
895
+                $o[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $o[0]);
900 896
             }
901
-            if (isset($g[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $g[0])) {
902
-                $g[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $g[0]);
897
+            if (isset($g[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $g[0])) {
898
+                $g[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $g[0]);
903 899
             }
904 900
             foreach ($j as $kk => $v) {
905 901
                 foreach ($v->keymap as $kkk => $vv) {
906
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv)) {
902
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vv)) {
907 903
                         $j[$kk]->keymap[$kkk] = preg_replace(
908
-                            '(\b'.preg_quote($k . '.'). ')i',
909
-                            $getAlias($k) . '.',
904
+                            '(\b'.preg_quote($k.'.').')i',
905
+                            $getAlias($k).'.',
910 906
                             $vv
911 907
                         );
912 908
                     }
@@ -915,38 +911,38 @@  discard block
 block discarded – undo
915 911
         }
916 912
         foreach ($this->definition->getRelations() as $k => $relation) {
917 913
             foreach ($f as $kk => $field) {
918
-                if (strpos($field, $k . '.') === 0) {
919
-                    $relations[$k] = [ $relation, $table ];
920
-                    $f[$kk] = str_replace($k . '.', $getAlias($k) . '.', $field);
914
+                if (strpos($field, $k.'.') === 0) {
915
+                    $relations[$k] = [$relation, $table];
916
+                    $f[$kk] = str_replace($k.'.', $getAlias($k).'.', $field);
921 917
                 }
922 918
             }
923 919
             foreach ($w as $kk => $v) {
924
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
925
-                    $relations[$k] = [ $relation, $table ];
926
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $v[0]);
920
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
921
+                    $relations[$k] = [$relation, $table];
922
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $v[0]);
927 923
                 }
928 924
             }
929 925
             foreach ($h as $kk => $v) {
930
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
931
-                    $relations[$k] = [ $relation, $table ];
932
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $v[0]);
926
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
927
+                    $relations[$k] = [$relation, $table];
928
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $v[0]);
933 929
                 }
934 930
             }
935
-            if (isset($o[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $o[0])) {
936
-                $relations[$k] = [ $relation, $table ];
937
-                $o[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $o[0]);
931
+            if (isset($o[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $o[0])) {
932
+                $relations[$k] = [$relation, $table];
933
+                $o[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $o[0]);
938 934
             }
939
-            if (isset($g[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $g[0])) {
940
-                $relations[$k] = [ $relation, $table ];
941
-                $g[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $g[0]);
935
+            if (isset($g[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $g[0])) {
936
+                $relations[$k] = [$relation, $table];
937
+                $g[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $g[0]);
942 938
             }
943 939
             foreach ($j as $kk => $v) {
944 940
                 foreach ($v->keymap as $kkk => $vv) {
945
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv)) {
946
-                        $relations[$k] = [ $relation, $table ];
941
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vv)) {
942
+                        $relations[$k] = [$relation, $table];
947 943
                         $j[$kk]->keymap[$kkk] = preg_replace(
948
-                            '(\b'.preg_quote($k . '.'). ')i',
949
-                            $getAlias($k) . '.',
944
+                            '(\b'.preg_quote($k.'.').')i',
945
+                            $getAlias($k).'.',
950 946
                             $vv
951 947
                         );
952 948
                     }
@@ -955,32 +951,32 @@  discard block
 block discarded – undo
955 951
         }
956 952
         foreach ($aliases_ext as $k => $alias) {
957 953
             foreach ($f as $kk => $field) {
958
-                if (strpos($field, $k . '.') === 0) {
959
-                    $f[$kk] = str_replace($k . '.', $alias . '.', $field);
954
+                if (strpos($field, $k.'.') === 0) {
955
+                    $f[$kk] = str_replace($k.'.', $alias.'.', $field);
960 956
                 }
961 957
             }
962 958
             foreach ($w as $kk => $v) {
963
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
964
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $v[0]);
959
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
960
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $v[0]);
965 961
                 }
966 962
             }
967 963
             foreach ($h as $kk => $v) {
968
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
969
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $v[0]);
964
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
965
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $v[0]);
970 966
                 }
971 967
             }
972
-            if (isset($o[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $o[0])) {
973
-                $o[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $o[0]);
968
+            if (isset($o[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $o[0])) {
969
+                $o[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $o[0]);
974 970
             }
975
-            if (isset($g[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $g[0])) {
976
-                $g[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $g[0]);
971
+            if (isset($g[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $g[0])) {
972
+                $g[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $g[0]);
977 973
             }
978 974
             foreach ($j as $kk => $v) {
979 975
                 foreach ($v->keymap as $kkk => $vv) {
980
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv)) {
976
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vv)) {
981 977
                         $j[$kk]->keymap[$kkk] = preg_replace(
982
-                            '(\b'.preg_quote($k . '.'). ')i',
983
-                            $alias . '.',
978
+                            '(\b'.preg_quote($k.'.').')i',
979
+                            $alias.'.',
984 980
                             $vv
985 981
                         );
986 982
                     }
@@ -989,12 +985,12 @@  discard block
 block discarded – undo
989 985
         }
990 986
         $select = [];
991 987
         foreach ($f as $k => $field) {
992
-            $select[] = $field . (!is_numeric($k) ? ' ' . $k : '');
988
+            $select[] = $field.(!is_numeric($k) ? ' '.$k : '');
993 989
         }
994 990
         foreach ($this->withr as $name => $relation) {
995 991
             if ($relation[2]) {
996 992
                 foreach ($relation[0]->table->getColumns() as $column) {
997
-                    $select[] = $getAlias($name) . '.' . $column . ' ' . $getAlias($name . static::SEP . $column);
993
+                    $select[] = $getAlias($name).'.'.$column.' '.$getAlias($name.static::SEP.$column);
998 994
                 }
999 995
             }
1000 996
         }
@@ -1015,13 +1011,13 @@  discard block
 block discarded – undo
1015 1011
                 foreach ($v->keymap as $kk => $vv) {
1016 1012
                     $tmp[] = $table.'.'.$kk.' = '.$alias.'.'.$vv.' ';
1017 1013
                 }
1018
-                $sql .= implode(' AND ', $tmp) . ' ';
1014
+                $sql .= implode(' AND ', $tmp).' ';
1019 1015
                 $sql .= 'LEFT JOIN '.$v->table->getFullName().' '.$getAlias($relation).' ON ';
1020 1016
                 $tmp = [];
1021 1017
                 foreach ($v->pivot_keymap as $kk => $vv) {
1022 1018
                     $tmp[] = $getAlias($relation).'.'.$vv.' = '.$alias.'.'.$kk.' ';
1023 1019
                 }
1024
-                $sql .= implode(' AND ', $tmp) . ' ';
1020
+                $sql .= implode(' AND ', $tmp).' ';
1025 1021
             } else {
1026 1022
                 $alias = $getAlias($relation);
1027 1023
 
@@ -1031,22 +1027,22 @@  discard block
 block discarded – undo
1031 1027
                     $tmp[] = $table.'.'.$kk.' = '.$alias.'.'.$vv.' ';
1032 1028
                 }
1033 1029
                 if ($v->sql) {
1034
-                    $tmp[] = $v->sql . ' ';
1030
+                    $tmp[] = $v->sql.' ';
1035 1031
                     $par = array_merge($par, $v->par ?? []);
1036 1032
                 }
1037
-                $sql .= implode(' AND ', $tmp) . ' ';
1033
+                $sql .= implode(' AND ', $tmp).' ';
1038 1034
             }
1039 1035
         }
1040 1036
         foreach ($j as $k => $v) {
1041 1037
             if ($v->many) {
1042 1038
                 $many = true;
1043 1039
             }
1044
-            $sql .= ($v->many ? 'LEFT ' : '' ) . 'JOIN '.$v->table->getFullName().' '.$k.' ON ';
1040
+            $sql .= ($v->many ? 'LEFT ' : '').'JOIN '.$v->table->getFullName().' '.$k.' ON ';
1045 1041
             $tmp = [];
1046 1042
             foreach ($v->keymap as $kk => $vv) {
1047 1043
                 $tmp[] = $kk.' = '.$vv;
1048 1044
             }
1049
-            $sql .= implode(' AND ', $tmp) . ' ';
1045
+            $sql .= implode(' AND ', $tmp).' ';
1050 1046
         }
1051 1047
         if ($many && count($porder) && $this->li_of[2] === 1) {
1052 1048
             $ids = $this->ids();
@@ -1054,9 +1050,9 @@  discard block
 block discarded – undo
1054 1050
                 if (count($porder) > 1) {
1055 1051
                     $pkw = [];
1056 1052
                     foreach ($porder as $name) {
1057
-                        $pkw[] = $name . ' = ?';
1053
+                        $pkw[] = $name.' = ?';
1058 1054
                     }
1059
-                    $pkw = '(' . implode(' AND ', $pkw) . ')';
1055
+                    $pkw = '('.implode(' AND ', $pkw).')';
1060 1056
                     $pkp = [];
1061 1057
                     foreach ($ids as $id) {
1062 1058
                         foreach ($id as $p) {
@@ -1068,60 +1064,60 @@  discard block
 block discarded – undo
1068 1064
                         $pkp
1069 1065
                     ];
1070 1066
                 } else {
1071
-                    $w[] = [ $porder[0] . ' IN ('.implode(',', array_fill(0, count($ids), '?')).')', $ids ];
1067
+                    $w[] = [$porder[0].' IN ('.implode(',', array_fill(0, count($ids), '?')).')', $ids];
1072 1068
                 }
1073 1069
             } else {
1074
-                $w[] = [ '1=0', [] ];
1070
+                $w[] = ['1=0', []];
1075 1071
             }
1076 1072
         }
1077 1073
         if (count($w)) {
1078 1074
             $sql .= 'WHERE ';
1079 1075
             $tmp = [];
1080 1076
             foreach ($w as $v) {
1081
-                $tmp[] = '(' . $v[0] . ')';
1077
+                $tmp[] = '('.$v[0].')';
1082 1078
                 $par = array_merge($par, $v[1]);
1083 1079
             }
1084 1080
             $sql .= implode(' AND ', $tmp).' ';
1085 1081
         }
1086 1082
         if (count($g)) {
1087
-            $sql .= 'GROUP BY ' . $g[0] . ' ';
1083
+            $sql .= 'GROUP BY '.$g[0].' ';
1088 1084
             $par = array_merge($par, $g[1]);
1089 1085
         }
1090 1086
         if (count($h)) {
1091 1087
             $sql .= 'HAVING ';
1092 1088
             $tmp = [];
1093 1089
             foreach ($h as $v) {
1094
-                $tmp[] = '(' . $v[0] . ')';
1090
+                $tmp[] = '('.$v[0].')';
1095 1091
                 $par = array_merge($par, $v[1]);
1096 1092
             }
1097 1093
             $sql .= implode(' AND ', $tmp).' ';
1098 1094
         }
1099 1095
         $ordered = false;
1100 1096
         if (count($o)) {
1101
-            $sql .= 'ORDER BY ' . $o[0] . ' ';
1097
+            $sql .= 'ORDER BY '.$o[0].' ';
1102 1098
             $par = array_merge($par, $o[1]);
1103 1099
             $ordered = true;
1104 1100
         }
1105 1101
         if (!count($g) && count($porder)) {
1106 1102
             $pdir = (count($o) && strpos($o[0], 'DESC') !== false) ? 'DESC' : 'ASC';
1107
-            $porder = array_map(function ($v) use ($pdir) {
1108
-                return $v . ' ' . $pdir;
1103
+            $porder = array_map(function($v) use ($pdir) {
1104
+                return $v.' '.$pdir;
1109 1105
             }, $porder);
1110
-            $sql .= ($ordered ? ', ' : 'ORDER BY ') . implode(', ', $porder) . ' ';
1106
+            $sql .= ($ordered ? ', ' : 'ORDER BY ').implode(', ', $porder).' ';
1111 1107
             $ordered = true;
1112 1108
         }
1113 1109
         foreach ($this->withr as $k => $v) {
1114 1110
             if (isset($v[3])) {
1115
-                $sql .= ($ordered ? ', ' : 'ORDER BY ') . $getAlias($k) . '.' . $v[3] . ' ' . ($v[4] ? 'DESC' : 'ASC');
1111
+                $sql .= ($ordered ? ', ' : 'ORDER BY ').$getAlias($k).'.'.$v[3].' '.($v[4] ? 'DESC' : 'ASC');
1116 1112
                 $ordered = true;
1117 1113
             }
1118 1114
         }
1119 1115
         if ((!$many || $this->li_of[2] === 0 || !count($porder)) && $this->li_of[0]) {
1120 1116
             if ($this->db->driverName() === 'oracle') {
1121
-                if ((int)$this->db->driverOption('version', 0) >= 12) {
1122
-                    $sql .= 'OFFSET ' . $this->li_of[1] . ' ROWS FETCH NEXT ' . $this->li_of[0] . ' ROWS ONLY';
1117
+                if ((int) $this->db->driverOption('version', 0) >= 12) {
1118
+                    $sql .= 'OFFSET '.$this->li_of[1].' ROWS FETCH NEXT '.$this->li_of[0].' ROWS ONLY';
1123 1119
                 } else {
1124
-                    $f = array_map(function ($v) {
1120
+                    $f = array_map(function($v) {
1125 1121
                         $v = explode(' ', trim($v), 2);
1126 1122
                         if (count($v) === 2) {
1127 1123
                             return $v[1];
@@ -1129,16 +1125,16 @@  discard block
 block discarded – undo
1129 1125
                         $v = explode('.', $v[0], 2);
1130 1126
                         return count($v) === 2 ? $v[1] : $v[0];
1131 1127
                     }, $select);
1132
-                    $sql = "SELECT " . implode(', ', $f) . " 
1128
+                    $sql = "SELECT ".implode(', ', $f)." 
1133 1129
                             FROM (
1134 1130
                                 SELECT tbl__.*, rownum rnum__ FROM (
1135
-                                    " . $sql . "
1131
+                                    " . $sql."
1136 1132
                                 ) tbl__ 
1137
-                                WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1]) . "
1133
+                                WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1])."
1138 1134
                             ) WHERE rnum__ > " . $this->li_of[1];
1139 1135
                 }
1140 1136
             } else {
1141
-                $sql .= 'LIMIT ' . $this->li_of[0] . ' OFFSET ' . $this->li_of[1];
1137
+                $sql .= 'LIMIT '.$this->li_of[0].' OFFSET '.$this->li_of[1];
1142 1138
             }
1143 1139
         }
1144 1140
         return $this->qiterator = new TableQueryIterator(
@@ -1188,12 +1184,12 @@  discard block
 block discarded – undo
1188 1184
                 $ret[$k] = str_repeat(' ', 255);
1189 1185
                 $par[] = &$ret[$k];
1190 1186
             }
1191
-            $sql .= ' RETURNING ' . implode(',', $primary) .
1192
-                ' INTO ' . implode(',', array_fill(0, count($primary), '?'));
1187
+            $sql .= ' RETURNING '.implode(',', $primary).
1188
+                ' INTO '.implode(',', array_fill(0, count($primary), '?'));
1193 1189
             $this->db->query($sql, $par);
1194 1190
             return $ret;
1195 1191
         } elseif ($this->db->driverName() === 'postgre') {
1196
-            $sql .= ' RETURNING ' . implode(',', $primary);
1192
+            $sql .= ' RETURNING '.implode(',', $primary);
1197 1193
             return $this->db->one($sql, $par, false);
1198 1194
         } else {
1199 1195
             $ret = [];
@@ -1224,9 +1220,9 @@  discard block
 block discarded – undo
1224 1220
         }
1225 1221
         $sql = 'UPDATE '.$table.' SET ';
1226 1222
         $par = [];
1227
-        $sql .= implode(', ', array_map(function ($v) {
1228
-            return $v . ' = ?';
1229
-        }, array_keys($update))) . ' ';
1223
+        $sql .= implode(', ', array_map(function($v) {
1224
+            return $v.' = ?';
1225
+        }, array_keys($update))).' ';
1230 1226
         $par = array_merge($par, array_values($update));
1231 1227
         if (count($this->where)) {
1232 1228
             $sql .= 'WHERE ';
@@ -1235,7 +1231,7 @@  discard block
 block discarded – undo
1235 1231
                 $tmp[] = $v[0];
1236 1232
                 $par = array_merge($par, $v[1]);
1237 1233
             }
1238
-            $sql .= implode(' AND ', $tmp) . ' ';
1234
+            $sql .= implode(' AND ', $tmp).' ';
1239 1235
         }
1240 1236
         if (count($this->order)) {
1241 1237
             $sql .= $this->order[0];
@@ -1259,7 +1255,7 @@  discard block
 block discarded – undo
1259 1255
                 $tmp[] = $v[0];
1260 1256
                 $par = array_merge($par, $v[1]);
1261 1257
             }
1262
-            $sql .= implode(' AND ', $tmp) . ' ';
1258
+            $sql .= implode(' AND ', $tmp).' ';
1263 1259
         }
1264 1260
         if (count($this->order)) {
1265 1261
             $sql .= $this->order[0];
@@ -1290,15 +1286,15 @@  discard block
 block discarded – undo
1290 1286
             try {
1291 1287
                 $name = array_reduce(
1292 1288
                     $parts,
1293
-                    function ($carry, $item) use (&$table, $select) {
1289
+                    function($carry, $item) use (&$table, $select) {
1294 1290
                         if (!$table->hasRelation($item)) {
1295
-                            throw new DBException('Invalid relation name: '.$table->getName().' -> ' . $item);
1291
+                            throw new DBException('Invalid relation name: '.$table->getName().' -> '.$item);
1296 1292
                         }
1297 1293
                         $relation = $table->getRelation($item);
1298 1294
                         if (!$relation) {
1299
-                            throw new DBException('Invalid relation name: '.$table->getName().' -> ' . $item);
1295
+                            throw new DBException('Invalid relation name: '.$table->getName().' -> '.$item);
1300 1296
                         }
1301
-                        $name = $carry ? $carry . static::SEP . $item : $item;
1297
+                        $name = $carry ? $carry.static::SEP.$item : $item;
1302 1298
                         $this->withr[$name] = [
1303 1299
                             $relation,
1304 1300
                             $carry ?? $table->getName(),
@@ -1363,9 +1359,9 @@  discard block
 block discarded – undo
1363 1359
 
1364 1360
         $aliases = [];
1365 1361
         $aliases_ext = [];
1366
-        $getAlias = function ($name) use (&$aliases, &$aliases_ext) {
1362
+        $getAlias = function($name) use (&$aliases, &$aliases_ext) {
1367 1363
             // to bypass use: return $name;
1368
-            $aliases[$name] = $aliases[$name] ?? 'alias' . static::SEP . count($aliases);
1364
+            $aliases[$name] = $aliases[$name] ?? 'alias'.static::SEP.count($aliases);
1369 1365
             if (isset($aliases_ext[$name])) {
1370 1366
                 unset($aliases_ext[$name]);
1371 1367
             }
@@ -1385,7 +1381,7 @@  discard block
 block discarded – undo
1385 1381
         $w = $this->where;
1386 1382
         $h = $this->having;
1387 1383
         $o = $this->order;
1388
-        $j = array_map(function ($v) {
1384
+        $j = array_map(function($v) {
1389 1385
             return clone $v;
1390 1386
         }, $this->joins);
1391 1387
 
@@ -1394,24 +1390,24 @@  discard block
 block discarded – undo
1394 1390
                 continue;
1395 1391
             }
1396 1392
             foreach ($w as $kk => $v) {
1397
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
1398
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $v[0]);
1393
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
1394
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $v[0]);
1399 1395
                 }
1400 1396
             }
1401 1397
             foreach ($h as $kk => $v) {
1402
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
1403
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $v[0]);
1398
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
1399
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $v[0]);
1404 1400
                 }
1405 1401
             }
1406
-            if (isset($o[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $o[0])) {
1407
-                $o[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $o[0]);
1402
+            if (isset($o[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $o[0])) {
1403
+                $o[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $o[0]);
1408 1404
             }
1409 1405
             foreach ($j as $kk => $v) {
1410 1406
                 foreach ($v->keymap as $kkk => $vv) {
1411
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv)) {
1407
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vv)) {
1412 1408
                         $j[$kk]->keymap[$kkk] = preg_replace(
1413
-                            '(\b'.preg_quote($k . '.'). ')i',
1414
-                            $getAlias($k) . '.',
1409
+                            '(\b'.preg_quote($k.'.').')i',
1410
+                            $getAlias($k).'.',
1415 1411
                             $vv
1416 1412
                         );
1417 1413
                     }
@@ -1420,52 +1416,52 @@  discard block
 block discarded – undo
1420 1416
         }
1421 1417
         foreach ($this->definition->getRelations() as $k => $v) {
1422 1418
             foreach ($w as $kk => $vv) {
1423
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv[0])) {
1424
-                    $relations[$k] = [ $v, $table ];
1425
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $vv[0]);
1419
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $vv[0])) {
1420
+                    $relations[$k] = [$v, $table];
1421
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $vv[0]);
1426 1422
                 }
1427 1423
             }
1428
-            if (isset($o[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $o[0])) {
1429
-                $relations[$k] = [ $v, $table ];
1430
-                $o[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $o[0]);
1431
-                $o[2] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $o[2]);
1424
+            if (isset($o[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $o[0])) {
1425
+                $relations[$k] = [$v, $table];
1426
+                $o[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $o[0]);
1427
+                $o[2] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $o[2]);
1432 1428
             }
1433 1429
             foreach ($h as $kk => $vv) {
1434
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv[0])) {
1435
-                    $relations[$k] = [ $v, $table ];
1436
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $vv[0]);
1430
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $vv[0])) {
1431
+                    $relations[$k] = [$v, $table];
1432
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $vv[0]);
1437 1433
                 }
1438 1434
             }
1439 1435
             foreach ($j as $kk => $vv) {
1440 1436
                 foreach ($vv->keymap as $kkk => $vvv) {
1441
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vvv)) {
1442
-                        $relations[$k] = [ $v, $table ];
1437
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vvv)) {
1438
+                        $relations[$k] = [$v, $table];
1443 1439
                         $j[$kk]->keymap[$kkk] =
1444
-                            preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $vvv);
1440
+                            preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $vvv);
1445 1441
                     }
1446 1442
                 }
1447 1443
             }
1448 1444
         }
1449 1445
         foreach ($aliases_ext as $k => $alias) {
1450 1446
             foreach ($w as $kk => $v) {
1451
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
1452
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $v[0]);
1447
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
1448
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $v[0]);
1453 1449
                 }
1454 1450
             }
1455 1451
             foreach ($h as $kk => $v) {
1456
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
1457
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $v[0]);
1452
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
1453
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $v[0]);
1458 1454
                 }
1459 1455
             }
1460
-            if (isset($o[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $o[0])) {
1461
-                $o[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $o[0]);
1456
+            if (isset($o[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $o[0])) {
1457
+                $o[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $o[0]);
1462 1458
             }
1463 1459
             foreach ($j as $kk => $v) {
1464 1460
                 foreach ($v->keymap as $kkk => $vv) {
1465
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv)) {
1461
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vv)) {
1466 1462
                         $j[$kk]->keymap[$kkk] = preg_replace(
1467
-                            '(\b'.preg_quote($k . '.'). ')i',
1468
-                            $alias . '.',
1463
+                            '(\b'.preg_quote($k.'.').')i',
1464
+                            $alias.'.',
1469 1465
                             $vv
1470 1466
                         );
1471 1467
                     }
@@ -1473,29 +1469,29 @@  discard block
 block discarded – undo
1473 1469
             }
1474 1470
         }
1475 1471
 
1476
-        $key = array_map(function ($v) use ($table) {
1477
-            return $table . '.' . $v;
1472
+        $key = array_map(function($v) use ($table) {
1473
+            return $table.'.'.$v;
1478 1474
         }, $this->pkey);
1479 1475
         $own = false;
1480 1476
         $dir = 'ASC';
1481 1477
         if (count($o)) {
1482 1478
             $dir = strpos($o[0], ' DESC') ? 'DESC' : 'ASC';
1483
-            $own = strpos($o[2], $table . '.') === 0;
1479
+            $own = strpos($o[2], $table.'.') === 0;
1484 1480
         }
1485 1481
 
1486 1482
         $dst = $key;
1487 1483
         if (count($o)) {
1488 1484
             if ($own) {
1489 1485
                 // if using own table - do not use max/min in order - that will prevent index usage
1490
-                $dst[] = $o[2] . ' orderbyfix___';
1486
+                $dst[] = $o[2].' orderbyfix___';
1491 1487
             } else {
1492
-                $dst[] = 'MAX(' . $o[2] . ') orderbyfix___';
1488
+                $dst[] = 'MAX('.$o[2].') orderbyfix___';
1493 1489
             }
1494 1490
         }
1495 1491
         $dst = array_unique($dst);
1496 1492
 
1497 1493
         $par = [];
1498
-        $sql  = 'SELECT DISTINCT '.implode(', ', $dst).' FROM '.$this->definition->getFullName().' ';
1494
+        $sql = 'SELECT DISTINCT '.implode(', ', $dst).' FROM '.$this->definition->getFullName().' ';
1499 1495
         foreach ($relations as $k => $v) {
1500 1496
             $table = $v[1] !== $this->definition->getName() ? $getAlias($v[1]) : $v[1];
1501 1497
             $v = $v[0];
@@ -1506,13 +1502,13 @@  discard block
 block discarded – undo
1506 1502
                 foreach ($v->keymap as $kk => $vv) {
1507 1503
                     $tmp[] = $table.'.'.$kk.' = '.$alias.'.'.$vv.' ';
1508 1504
                 }
1509
-                $sql .= implode(' AND ', $tmp) . ' ';
1505
+                $sql .= implode(' AND ', $tmp).' ';
1510 1506
                 $sql .= 'LEFT JOIN '.$v->table->getFullName().' '.$getAlias($k).' ON ';
1511 1507
                 $tmp = [];
1512 1508
                 foreach ($v->pivot_keymap as $kk => $vv) {
1513 1509
                     $tmp[] = $getAlias($k).'.'.$vv.' = '.$alias.'.'.$kk.' ';
1514 1510
                 }
1515
-                $sql .= implode(' AND ', $tmp) . ' ';
1511
+                $sql .= implode(' AND ', $tmp).' ';
1516 1512
             } else {
1517 1513
                 $alias = $getAlias($k);
1518 1514
                 $sql .= 'LEFT JOIN '.$v->table->getFullName().' '.$alias.' ON ';
@@ -1521,37 +1517,37 @@  discard block
 block discarded – undo
1521 1517
                     $tmp[] = $table.'.'.$kk.' = '.$alias.'.'.$vv.' ';
1522 1518
                 }
1523 1519
                 if ($v->sql) {
1524
-                    $tmp[] = $v->sql . ' ';
1520
+                    $tmp[] = $v->sql.' ';
1525 1521
                     $par = array_merge($par, $v->par ?? []);
1526 1522
                 }
1527
-                $sql .= implode(' AND ', $tmp) . ' ';
1523
+                $sql .= implode(' AND ', $tmp).' ';
1528 1524
             }
1529 1525
         }
1530 1526
         foreach ($j as $k => $v) {
1531
-            $sql .= ($v->many ? 'LEFT ' : '' ) . 'JOIN '.$v->table->getFullName().' '.$k.' ON ';
1527
+            $sql .= ($v->many ? 'LEFT ' : '').'JOIN '.$v->table->getFullName().' '.$k.' ON ';
1532 1528
             $tmp = [];
1533 1529
             foreach ($v->keymap as $kk => $vv) {
1534 1530
                 $tmp[] = $kk.' = '.$vv;
1535 1531
             }
1536
-            $sql .= implode(' AND ', $tmp) . ' ';
1532
+            $sql .= implode(' AND ', $tmp).' ';
1537 1533
         }
1538 1534
         if (count($w)) {
1539 1535
             $sql .= 'WHERE ';
1540 1536
             $tmp = [];
1541 1537
             foreach ($w as $v) {
1542
-                $tmp[] = '(' . $v[0] . ')';
1538
+                $tmp[] = '('.$v[0].')';
1543 1539
                 $par = array_merge($par, $v[1]);
1544 1540
             }
1545 1541
             $sql .= implode(' AND ', $tmp).' ';
1546 1542
         }
1547 1543
         if (!$own) {
1548
-            $sql .= 'GROUP BY ' . implode(', ', $key) . ' ';
1544
+            $sql .= 'GROUP BY '.implode(', ', $key).' ';
1549 1545
         }
1550 1546
         if (count($h)) {
1551 1547
             $sql .= 'HAVING ';
1552 1548
             $tmp = [];
1553 1549
             foreach ($h as $v) {
1554
-                $tmp[] = '(' . $v[0] . ')';
1550
+                $tmp[] = '('.$v[0].')';
1555 1551
                 $par = array_merge($par, $v[1]);
1556 1552
             }
1557 1553
             $sql .= implode(' AND ', $tmp).' ';
@@ -1559,38 +1555,38 @@  discard block
 block discarded – undo
1559 1555
         if (count($o)) {
1560 1556
             $sql .= 'ORDER BY ';
1561 1557
             if ($own) {
1562
-                $sql .= $o[2] . ' ' . $dir;
1558
+                $sql .= $o[2].' '.$dir;
1563 1559
             } else {
1564
-                $sql .= 'MAX('.$o[2].') ' . $dir;
1560
+                $sql .= 'MAX('.$o[2].') '.$dir;
1565 1561
             }
1566 1562
         }
1567 1563
         $porder = [];
1568 1564
         $pdir = (count($o) && strpos($o[0], 'DESC') !== false) ? 'DESC' : 'ASC';
1569 1565
         foreach ($this->definition->getPrimaryKey() as $field) {
1570
-            $porder[] = $this->getColumn($field)['name'] . ' ' . $pdir;
1566
+            $porder[] = $this->getColumn($field)['name'].' '.$pdir;
1571 1567
         }
1572 1568
         if (count($porder)) {
1573
-            $sql .= (count($o) ? ', ' : 'ORDER BY ') . implode(', ', $porder) . ' ';
1569
+            $sql .= (count($o) ? ', ' : 'ORDER BY ').implode(', ', $porder).' ';
1574 1570
         }
1575 1571
 
1576 1572
         if ($this->li_of[0]) {
1577 1573
             if ($this->db->driverName() === 'oracle') {
1578
-                if ((int)$this->db->driverOption('version', 0) >= 12) {
1579
-                    $sql .= 'OFFSET ' . $this->li_of[1] . ' ROWS FETCH NEXT ' . $this->li_of[0] . ' ROWS ONLY';
1574
+                if ((int) $this->db->driverOption('version', 0) >= 12) {
1575
+                    $sql .= 'OFFSET '.$this->li_of[1].' ROWS FETCH NEXT '.$this->li_of[0].' ROWS ONLY';
1580 1576
                 } else {
1581
-                    $sql = "SELECT " . implode(', ', $dst) . " 
1577
+                    $sql = "SELECT ".implode(', ', $dst)." 
1582 1578
                             FROM (
1583 1579
                                 SELECT tbl__.*, rownum rnum__ FROM (
1584
-                                    " . $sql . "
1580
+                                    " . $sql."
1585 1581
                                 ) tbl__ 
1586
-                                WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1]) . "
1582
+                                WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1])."
1587 1583
                             ) WHERE rnum__ > " . $this->li_of[1];
1588 1584
                 }
1589 1585
             } else {
1590
-                $sql .= 'LIMIT ' . $this->li_of[0] . ' OFFSET ' . $this->li_of[1];
1586
+                $sql .= 'LIMIT '.$this->li_of[0].' OFFSET '.$this->li_of[1];
1591 1587
             }
1592 1588
         }
1593
-        return array_map(function ($v) {
1589
+        return array_map(function($v) {
1594 1590
             if (array_key_exists('orderbyfix___', $v)) {
1595 1591
                 unset($v['orderbyfix___']);
1596 1592
             }
Please login to merge, or discard this patch.
src/driver/sqlite/Driver.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
         if ($this->lnk === null) {
39 39
             try {
40 40
                 $this->lnk = new \SQLite3($this->connection['name']);
41
-                $this->lnk->exec('PRAGMA encoding = "'.$this->option('charset', 'utf-8') . '"');
41
+                $this->lnk->exec('PRAGMA encoding = "'.$this->option('charset', 'utf-8').'"');
42 42
             } catch (\Exception $e) {
43 43
                 if ($this->lnk !== null) {
44 44
                     throw new DBException('Connect error: '.$this->lnk->lastErrorMsg());
Please login to merge, or discard this patch.
src/schema/TableColumn.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             $instance->setNullable($data['nullable']);
43 43
         }
44 44
         if (isset($data['notnull'])) {
45
-            $instance->setNullable(!((int)$data['notnull']));
45
+            $instance->setNullable(!((int) $data['notnull']));
46 46
         }
47 47
         if (isset($data['Default'])) {
48 48
             $instance->setDefault($data['Default']);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
             $instance->setLength($data['length']);
58 58
         }
59 59
         if ($instance->getBasicType() === 'enum' && strpos($instance->getType(), 'enum(') === 0) {
60
-            $temp = array_map(function ($v) {
60
+            $temp = array_map(function($v) {
61 61
                 return str_replace("''", "'", $v);
62 62
             }, explode("','", substr($instance->getType(), 6, -2)));
63 63
             $instance->setValues($temp);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
                 $instance->setDefault(null);
87 87
             }
88 88
         }
89
-        if ($instance->getBasicType() === 'text' && isset($data['CHAR_LENGTH']) && (int)$data['CHAR_LENGTH']) {
89
+        if ($instance->getBasicType() === 'text' && isset($data['CHAR_LENGTH']) && (int) $data['CHAR_LENGTH']) {
90 90
             $instance->setLength($data['CHAR_LENGTH']);
91 91
         }
92 92
         return $instance;
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
     }
184 184
     public function getLength(): int
185 185
     {
186
-        return (int)$this->length;
186
+        return (int) $this->length;
187 187
     }
188 188
     public function setLength(int $length): static
189 189
     {
Please login to merge, or discard this patch.