Completed
Push — master ( 03e094...3a1553 )
by Ivan
11:39
created
src/DBInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      * @param class-string<T>|Table|string $table
119 119
      * @return ($table is class-string ? MapperInterface<T> : MapperInterface<Entity>)
120 120
      */
121
-    public function getMapper(Table|string $table): MapperInterface;
121
+    public function getMapper(Table | string $table): MapperInterface;
122 122
     /*
123 123
      * @template T of Entity
124 124
      * @param Table|string $table
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      * @param null|class-string<T> $class
127 127
      * @return static
128 128
      */
129
-    public function setMapper(Table|string $table, MapperInterface $mapper, ?string $class = null): static;
129
+    public function setMapper(Table | string $table, MapperInterface $mapper, ?string $class = null): static;
130 130
     public function tableMapped(
131 131
         string $table,
132 132
         bool $findRelations = false,
Please login to merge, or discard this patch.
src/driver/mysql/Schema.php 1 patch
Spacing   +40 added lines, -40 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
 
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
         if (!count($columns)) {
100 100
             throw new DBException('Table not found by name');
101 101
         }
102
-        $tables[$schema . '.' . $table] = $definition = (new Table($table, $schema))
102
+        $tables[$schema.'.'.$table] = $definition = (new Table($table, $schema))
103 103
             ->addColumns(
104 104
                 $columns
105 105
                     ->clone()
106
-                    ->mapKey(function (array $v): string {
106
+                    ->mapKey(function(array $v): string {
107 107
                         return $v['Field'];
108 108
                     })
109
-                    ->map(function (array $v): array {
109
+                    ->map(function(array $v): array {
110 110
                         $v['length'] = null;
111 111
                         if (!isset($v['Type'])) {
112 112
                             return $v;
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
                             default:
129 129
                                 if (strpos($type, 'char') !== false && strpos($type, '(') !== false) {
130 130
                                     // extract length from varchar
131
-                                    $v['length'] = (int)explode(')', explode('(', $type)[1])[0];
131
+                                    $v['length'] = (int) explode(')', explode('(', $type)[1])[0];
132 132
                                     $v['length'] = $v['length'] > 0 ? $v['length'] : null;
133 133
                                 }
134 134
                                 break;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
             ->setPrimaryKey(
141 141
                 $columns
142 142
                     ->clone()
143
-                    ->filter(function (array $v): bool {
143
+                    ->filter(function(array $v): bool {
144 144
                         return $v['Key'] === 'PRI';
145 145
                     })
146 146
                     ->pluck('Field')
@@ -151,20 +151,20 @@  discard block
 block discarded – undo
151 151
 
152 152
         if ($detectRelations) {
153 153
             $duplicated = [];
154
-            foreach ($relationsT[$schema . '.' . $table] ?? [] as $relation) {
155
-                $t = $relation['REFERENCED_TABLE_SCHEMA'] . '.' . $relation['REFERENCED_TABLE_NAME'];
154
+            foreach ($relationsT[$schema.'.'.$table] ?? [] as $relation) {
155
+                $t = $relation['REFERENCED_TABLE_SCHEMA'].'.'.$relation['REFERENCED_TABLE_NAME'];
156 156
                 $duplicated[$t] = isset($duplicated[$t]);
157 157
             }
158
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) {
159
-                $t = $relation['TABLE_SCHEMA'] . '.' . $relation['TABLE_NAME'];
158
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) {
159
+                $t = $relation['TABLE_SCHEMA'].'.'.$relation['TABLE_NAME'];
160 160
                 $duplicated[$t] = isset($duplicated[$t]);
161 161
             }
162 162
             // pivot relations where the current table is referenced
163 163
             // assuming current table is on the "one" end having "many" records in the referencing table
164 164
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
165 165
             $relations = [];
166
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) {
167
-                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'] . '.' .
166
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) {
167
+                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'].'.'.
168 168
                     $relation['TABLE_NAME'];
169 169
                 $relations[$relation['CONSTRAINT_NAME']]['keymap'][$relation['REFERENCED_COLUMN_NAME']] =
170 170
                     $relation['COLUMN_NAME'];
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
                 $usedcol = [];
182 182
                 if (count($columns)) {
183 183
                     foreach (Collection::from($relationsT[$data['table']] ?? [])
184
-                        ->filter(function (array $v) use ($columns): bool {
184
+                        ->filter(function(array $v) use ($columns): bool {
185 185
                             return in_array($v['COLUMN_NAME'], $columns);
186 186
                         })
187
-                        ->map(function (array $v): array {
187
+                        ->map(function(array $v): array {
188 188
                             $new = [];
189 189
                             foreach ($v as $kk => $vv) {
190 190
                                 $new[strtoupper($kk)] = $vv;
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
                             return $new;
193 193
                         }) as $relation
194 194
                     ) {
195
-                        $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'] . '.' .
195
+                        $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'].'.'.
196 196
                             $relation['REFERENCED_TABLE_NAME'];
197 197
                         $foreign[$relation['CONSTRAINT_NAME']]['keymap'][$relation['COLUMN_NAME']] =
198 198
                             $relation['REFERENCED_COLUMN_NAME'];
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
                     $orig = $relname;
210 210
                     $cntr = 1;
211 211
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
212
-                        $relname = $orig . '_' . (++ $cntr);
212
+                        $relname = $orig.'_'.(++$cntr);
213 213
                     }
214 214
                     $definition->addRelation(
215 215
                         new TableRelation(
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
             // assuming current table is linked to "one" record in the referenced table
232 232
             // resulting in a "belongsTo" relationship
233 233
             $relations = [];
234
-            foreach ($relationsT[$schema . '.' . $table] ?? [] as $relation) {
235
-                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'] . '.' .
234
+            foreach ($relationsT[$schema.'.'.$table] ?? [] as $relation) {
235
+                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'].'.'.
236 236
                     $relation['REFERENCED_TABLE_NAME'];
237 237
                 $relations[$relation['CONSTRAINT_NAME']]['keymap'][$relation['COLUMN_NAME']] =
238 238
                     $relation['REFERENCED_COLUMN_NAME'];
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
                     $definition->getName() == $relname ||
249 249
                     $definition->getColumn($relname)
250 250
                 ) {
251
-                    $relname = array_keys($data['keymap'])[0] . '_' . $relname;
251
+                    $relname = array_keys($data['keymap'])[0].'_'.$relname;
252 252
                 }
253 253
                 $orig = $relname;
254 254
                 $cntr = 1;
255 255
                 while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
256
-                    $relname = $orig . '_' . (++ $cntr);
256
+                    $relname = $orig.'_'.(++$cntr);
257 257
                 }
258 258
                 $definition->addRelation(
259 259
                     new TableRelation(
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
             // assuming current table is on the "one" end having "many" records in the referencing table
270 270
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
271 271
             $relations = [];
272
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) {
273
-                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'] . '.' .
272
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) {
273
+                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'].'.'.
274 274
                     $relation['TABLE_NAME'];
275 275
                 $relations[$relation['CONSTRAINT_NAME']]['keymap'][$relation['REFERENCED_COLUMN_NAME']] =
276 276
                     $relation['COLUMN_NAME'];
@@ -287,10 +287,10 @@  discard block
 block discarded – undo
287 287
                 $usedcol = [];
288 288
                 if (count($columns)) {
289 289
                     foreach (Collection::from($relationsT[$data['table']] ?? [])
290
-                        ->filter(function (array $v) use ($columns): bool {
290
+                        ->filter(function(array $v) use ($columns): bool {
291 291
                             return in_array($v['COLUMN_NAME'], $columns);
292 292
                         })
293
-                        ->map(function (array $v): array {
293
+                        ->map(function(array $v): array {
294 294
                             $new = [];
295 295
                             foreach ($v as $kk => $vv) {
296 296
                                 $new[strtoupper($kk)] = $vv;
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
                             return $new;
299 299
                         }) as $relation
300 300
                     ) {
301
-                        $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'] . '.' .
301
+                        $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'].'.'.
302 302
                             $relation['REFERENCED_TABLE_NAME'];
303 303
                         $foreign[$relation['CONSTRAINT_NAME']]['keymap'][$relation['COLUMN_NAME']] =
304 304
                             $relation['REFERENCED_COLUMN_NAME'];
@@ -316,12 +316,12 @@  discard block
 block discarded – undo
316 316
                         $definition->getName() == $relname ||
317 317
                         $definition->getColumn($relname)
318 318
                     ) {
319
-                        $relname .= '_' . array_values($data['keymap'])[0];
319
+                        $relname .= '_'.array_values($data['keymap'])[0];
320 320
                     }
321 321
                     $orig = $relname;
322 322
                     $cntr = 1;
323 323
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
324
-                        $relname = $orig . '_' . (++ $cntr);
324
+                        $relname = $orig.'_'.(++$cntr);
325 325
                     }
326 326
                     $definition->addRelation(
327 327
                         new TableRelation(
@@ -349,23 +349,23 @@  discard block
 block discarded – undo
349 349
                 "SELECT table_name FROM information_schema.tables where table_schema = ?",
350 350
                 [$this->connection['opts']['schema'] ?? $this->connection['name']]
351 351
             ))
352
-            ->map(function (array $v): array {
352
+            ->map(function(array $v): array {
353 353
                 $new = [];
354 354
                 foreach ($v as $kk => $vv) {
355 355
                     $new[strtoupper($kk)] = $vv;
356 356
                 }
357 357
                 return $new;
358 358
             })
359
-            ->mapKey(function (array $v): string {
359
+            ->mapKey(function(array $v): string {
360 360
                 return strtolower($v['TABLE_NAME']);
361 361
             })
362 362
             ->pluck('TABLE_NAME')
363
-            ->map(function (string $v): Table {
363
+            ->map(function(string $v): Table {
364 364
                 return $this->table($v)->toLowerCase();
365 365
             })
366 366
             ->toArray();
367 367
         foreach (array_keys($tables) as $k) {
368
-            $tables[($this->connection['opts']['schema'] ?? $this->connection['name']) . '.' . $k] = &$tables[$k];
368
+            $tables[($this->connection['opts']['schema'] ?? $this->connection['name']).'.'.$k] = &$tables[$k];
369 369
         }
370 370
         return $tables;
371 371
     }
Please login to merge, or discard this patch.
src/driver/postgre/Schema.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
             $table = $temp[1];
30 30
         }
31 31
 
32
-        if (isset($tables[$schema . '.' . $table])) {
33
-            return $tables[$schema . '.' . $table];
32
+        if (isset($tables[$schema.'.'.$table])) {
33
+            return $tables[$schema.'.'.$table];
34 34
         }
35 35
 
36 36
         static $relationsT = null;
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
                         (kc.table_schema = ? OR ct.table_schema = ?) AND
62 62
                         kc.table_name IS NOT NULL AND
63 63
                         kc.position_in_unique_constraint IS NOT NULL",
64
-                    [ $catalog, $main, $main ]
64
+                    [$catalog, $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(
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
                             (kc.table_schema = ? AND ct.table_schema = ?) AND
98 98
                             kc.table_name IS NOT NULL AND
99 99
                             kc.position_in_unique_constraint IS NOT NULL",
100
-                        [ $catalog, $s, $s ]
100
+                        [$catalog, $s, $s]
101 101
                     )
102 102
                 )->toArray();
103 103
                 foreach ($col as $row) {
104
-                    $relationsT[$row['table_schema'] . '.' . $row['table_name']][] = $row;
105
-                    $relationsR[$row['referenced_table_schema'] . '.' . $row['referenced_table_name']][] = $row;
104
+                    $relationsT[$row['table_schema'].'.'.$row['table_name']][] = $row;
105
+                    $relationsR[$row['referenced_table_schema'].'.'.$row['referenced_table_name']][] = $row;
106 106
                 }
107 107
             }
108 108
         }
@@ -114,12 +114,12 @@  discard block
 block discarded – undo
114 114
             ->query(
115 115
                 "SELECT * FROM information_schema.columns
116 116
                  WHERE table_name = ? AND table_schema = ? AND table_catalog = ?",
117
-                [ $table, $schema, $catalog ]
117
+                [$table, $schema, $catalog]
118 118
             ))
119
-            ->mapKey(function ($v): string {
119
+            ->mapKey(function($v): string {
120 120
                 return $v['column_name'];
121 121
             })
122
-            ->map(function ($v) {
122
+            ->map(function($v) {
123 123
                 $v['length'] = null;
124 124
                 if (!isset($v['data_type'])) {
125 125
                     return $v;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                 switch ($v['data_type']) {
128 128
                     case 'character':
129 129
                     case 'character varying':
130
-                        $v['length'] = (int)$v['character_maximum_length'];
130
+                        $v['length'] = (int) $v['character_maximum_length'];
131 131
                         break;
132 132
                 }
133 133
                 $v['hidden'] = $v['is_identity'] !== 'YES' && $v['is_generated'] === 'ALWAYS';
@@ -135,13 +135,13 @@  discard block
 block discarded – undo
135 135
             })
136 136
             ->toArray();
137 137
         if (!count($columns)) {
138
-            throw new DBException('Table not found by name: ' . implode('.', [$schema,$table]));
138
+            throw new DBException('Table not found by name: '.implode('.', [$schema, $table]));
139 139
         }
140 140
         $pkname = Collection::from($this
141 141
             ->query(
142 142
                 "SELECT constraint_name FROM information_schema.table_constraints
143 143
                 WHERE table_name = ? AND constraint_type = ? AND table_schema = ? AND table_catalog = ?",
144
-                [ $table, 'PRIMARY KEY', $schema, $catalog ]
144
+                [$table, 'PRIMARY KEY', $schema, $catalog]
145 145
             ))
146 146
             ->pluck('constraint_name')
147 147
             ->value();
@@ -151,32 +151,32 @@  discard block
 block discarded – undo
151 151
                 ->query(
152 152
                     "SELECT column_name FROM information_schema.constraint_column_usage
153 153
                      WHERE table_name = ? AND constraint_name = ? AND table_schema = ? AND table_catalog = ?",
154
-                    [ $table, $pkname, $schema, $catalog ]
154
+                    [$table, $pkname, $schema, $catalog]
155 155
                 ))
156 156
                 ->pluck('column_name')
157 157
                 ->toArray();
158 158
         }
159
-        $tables[$schema . '.' .$table] = $definition = (new Table($table, $schema))
159
+        $tables[$schema.'.'.$table] = $definition = (new Table($table, $schema))
160 160
             ->addColumns($columns)
161 161
             ->setPrimaryKey($primary)
162 162
             ->setComment('');
163 163
 
164 164
         if ($detectRelations) {
165 165
             $duplicated = [];
166
-            foreach ($relationsT[$schema . '.' . $table] ?? [] as $relation) {
167
-                $t = $relation['referenced_table_schema'] . '.' . $relation['referenced_table_name'];
166
+            foreach ($relationsT[$schema.'.'.$table] ?? [] as $relation) {
167
+                $t = $relation['referenced_table_schema'].'.'.$relation['referenced_table_name'];
168 168
                 $duplicated[$t] = isset($duplicated[$t]);
169 169
             }
170
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) {
171
-                $t = $relation['table_schema'] . '.' . $relation['table_name'];
170
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) {
171
+                $t = $relation['table_schema'].'.'.$relation['table_name'];
172 172
                 $duplicated[$t] = isset($duplicated[$t]);
173 173
             }
174 174
             // pivot relations where the current table is referenced
175 175
             // assuming current table is on the "one" end having "many" records in the referencing table
176 176
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
177 177
             $relations = [];
178
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) {
179
-                $relations[$relation['constraint_name']]['table'] = $relation['table_schema'] . '.' .
178
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) {
179
+                $relations[$relation['constraint_name']]['table'] = $relation['table_schema'].'.'.
180 180
                     $relation['table_name'];
181 181
                 $relations[$relation['constraint_name']]['keymap'][$relation['referenced_column_name']] =
182 182
                     $relation['column_name'];
@@ -193,11 +193,11 @@  discard block
 block discarded – undo
193 193
                 $usedcol = [];
194 194
                 if (count($columns)) {
195 195
                     foreach (Collection::from($relationsT[$data['table']] ?? [])
196
-                        ->filter(function ($v) use ($columns) {
196
+                        ->filter(function($v) use ($columns) {
197 197
                             return in_array($v['column_name'], $columns);
198 198
                         }) as $relation
199 199
                     ) {
200
-                        $foreign[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'] . '.' .
200
+                        $foreign[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'].'.'.
201 201
                             $relation['referenced_table_name'];
202 202
                         $foreign[$relation['constraint_name']]['keymap'][$relation['column_name']] =
203 203
                             $relation['referenced_column_name'];
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
                         $definition->getName() == $relname ||
218 218
                         $definition->getColumn($relname)
219 219
                     ) {
220
-                        $relname = $orig . '_' . (++ $cntr);
220
+                        $relname = $orig.'_'.(++$cntr);
221 221
                     }
222 222
                     $definition->addRelation(
223 223
                         new TableRelation(
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
             // assuming current table is linked to "one" record in the referenced table
240 240
             // resulting in a "belongsTo" relationship
241 241
             $relations = [];
242
-            foreach ($relationsT[$schema . '.' . $table] ?? [] as $relation) {
243
-                $relations[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'] . '.' .
242
+            foreach ($relationsT[$schema.'.'.$table] ?? [] as $relation) {
243
+                $relations[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'].'.'.
244 244
                     $relation['referenced_table_name'];
245 245
                 $relations[$relation['constraint_name']]['keymap'][$relation['column_name']] =
246 246
                     $relation['referenced_column_name'];
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
                     $definition->getName() == $relname ||
257 257
                     $definition->getColumn($relname)
258 258
                 ) {
259
-                    $relname = array_keys($data['keymap'])[0] . '_' . $relname;
259
+                    $relname = array_keys($data['keymap'])[0].'_'.$relname;
260 260
                 }
261 261
                 $orig = $relname;
262 262
                 $cntr = 1;
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
                     $definition->getName() == $relname ||
265 265
                     $definition->getColumn($relname)
266 266
                 ) {
267
-                    $relname = $orig . '_' . (++ $cntr);
267
+                    $relname = $orig.'_'.(++$cntr);
268 268
                 }
269 269
                 $definition->addRelation(
270 270
                     new TableRelation(
@@ -280,8 +280,8 @@  discard block
 block discarded – undo
280 280
             // assuming current table is on the "one" end having "many" records in the referencing table
281 281
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
282 282
             $relations = [];
283
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) {
284
-                $relations[$relation['constraint_name']]['table'] = $relation['table_schema'] . '.' .
283
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) {
284
+                $relations[$relation['constraint_name']]['table'] = $relation['table_schema'].'.'.
285 285
                     $relation['table_name'];
286 286
                 $relations[$relation['constraint_name']]['keymap'][$relation['referenced_column_name']] =
287 287
                     $relation['column_name'];
@@ -298,11 +298,11 @@  discard block
 block discarded – undo
298 298
                 $usedcol = [];
299 299
                 if (count($columns)) {
300 300
                     foreach (Collection::from($relationsT[$data['table']] ?? [])
301
-                        ->filter(function ($v) use ($columns) {
301
+                        ->filter(function($v) use ($columns) {
302 302
                             return in_array($v['column_name'], $columns);
303 303
                         }) as $relation
304 304
                     ) {
305
-                        $foreign[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'] . '.' .
305
+                        $foreign[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'].'.'.
306 306
                             $relation['referenced_table_name'];
307 307
                         $foreign[$relation['constraint_name']]['keymap'][$relation['column_name']] =
308 308
                             $relation['referenced_column_name'];
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
                         $definition->getName() == $relname ||
321 321
                         $definition->getColumn($relname)
322 322
                     ) {
323
-                        $relname .= '_' . array_values($data['keymap'])[0];
323
+                        $relname .= '_'.array_values($data['keymap'])[0];
324 324
                     }
325 325
                     $orig = $relname;
326 326
                     $cntr = 1;
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
                         $definition->getName() == $relname ||
329 329
                         $definition->getColumn($relname)
330 330
                     ) {
331
-                        $relname = $orig . '_' . (++ $cntr);
331
+                        $relname = $orig.'_'.(++$cntr);
332 332
                     }
333 333
                     $definition->addRelation(
334 334
                         new TableRelation(
@@ -378,20 +378,20 @@  discard block
 block discarded – undo
378 378
                     attr.attnum > 0
379 379
                  order by
380 380
                     attr.attnum",
381
-                [ $table, $schema ]
381
+                [$table, $schema]
382 382
             ))
383
-            ->mapKey(function ($v): string {
383
+            ->mapKey(function($v): string {
384 384
                 return $v['column_name'];
385 385
             })
386
-            ->map(function ($v) {
386
+            ->map(function($v) {
387 387
                 $v['length'] = null;
388 388
                 return $v;
389 389
             })
390 390
             ->toArray();
391 391
         if (!count($columns)) {
392
-            throw new DBException('View not found by name: ' . implode('.', [$schema,$table]));
392
+            throw new DBException('View not found by name: '.implode('.', [$schema, $table]));
393 393
         }
394
-        $tables[$schema . '.' .$table] = $definition = (new Table($table, $schema))
394
+        $tables[$schema.'.'.$table] = $definition = (new Table($table, $schema))
395 395
             ->addColumns($columns)
396 396
             ->setComment('');
397 397
         return $definition;
@@ -401,13 +401,13 @@  discard block
 block discarded – undo
401 401
         $tables = Collection::from($this
402 402
             ->query(
403 403
                 "SELECT table_name FROM information_schema.tables where table_schema = ? AND table_catalog = ?",
404
-                [ $this->connection['opts']['schema'] ?? 'public', $this->connection['name'] ]
404
+                [$this->connection['opts']['schema'] ?? 'public', $this->connection['name']]
405 405
             ))
406
-            ->mapKey(function ($v) {
406
+            ->mapKey(function($v) {
407 407
                 return strtolower($v['table_name']);
408 408
             })
409 409
             ->pluck('table_name')
410
-            ->map(function ($v) {
410
+            ->map(function($v) {
411 411
                 return $this->table($v)->toLowerCase();
412 412
             })
413 413
             ->toArray();
@@ -418,19 +418,19 @@  discard block
 block discarded – undo
418 418
                  FROM pg_catalog.pg_class cls
419 419
                  join pg_catalog.pg_namespace as ns on ns.oid = cls.relnamespace
420 420
                  WHERE cls.relkind = 'm' and ns.nspname = ?",
421
-                [ $this->connection['opts']['schema'] ?? 'public' ]
421
+                [$this->connection['opts']['schema'] ?? 'public']
422 422
             ))
423
-            ->mapKey(function ($v) {
423
+            ->mapKey(function($v) {
424 424
                 return strtolower($v['table_name']);
425 425
             })
426 426
             ->pluck('table_name')
427
-            ->map(function ($v) {
427
+            ->map(function($v) {
428 428
                 return $this->view($v)->toLowerCase();
429 429
             })
430 430
             ->toArray();
431 431
         $tables = array_merge($views, $tables);
432 432
         foreach (array_keys($tables) as $k) {
433
-            $tables[($this->connection['opts']['schema'] ?? 'public') . '.' . $k] = &$tables[$k];
433
+            $tables[($this->connection['opts']['schema'] ?? 'public').'.'.$k] = &$tables[$k];
434 434
         }
435 435
         return $tables;
436 436
     }
Please login to merge, or discard this patch.
src/driver/sqlite/Schema.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
             $table = $temp[1];
30 30
         }
31 31
 
32
-        if (isset($tables[$schema . '.' . $table])) {
33
-            return $tables[$schema . '.' . $table];
32
+        if (isset($tables[$schema.'.'.$table])) {
33
+            return $tables[$schema.'.'.$table];
34 34
         }
35 35
 
36 36
         static $relationsT = null;
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
                             ]
54 54
                         )
55 55
                     );
56
-                    $relationsT['main.' . $row['table']][] = $row;
57
-                    $relationsR['main.' . $row['referenced_table']][] = $row;
56
+                    $relationsT['main.'.$row['table']][] = $row;
57
+                    $relationsR['main.'.$row['referenced_table']][] = $row;
58 58
                 }
59 59
             }
60 60
         }
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
          */
65 65
         $columns = Collection::from($this
66 66
             ->query("PRAGMA table_info(".$table.")"))
67
-            ->mapKey(function ($v): string {
67
+            ->mapKey(function($v): string {
68 68
                 return $v['name'];
69 69
             })
70
-            ->map(function ($v) {
70
+            ->map(function($v) {
71 71
                 $v['length'] = null;
72 72
                 if (!isset($v['type'])) {
73 73
                     return $v;
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
                     default:
78 78
                         if (strpos($type, 'char') !== false && strpos($type, '(') !== false) {
79 79
                             // extract length from varchar
80
-                            $v['length'] = (int)explode(')', explode('(', $type)[1])[0];
80
+                            $v['length'] = (int) explode(')', explode('(', $type)[1])[0];
81 81
                             $v['length'] = $v['length'] > 0 ? $v['length'] : null;
82 82
                         }
83 83
                         break;
@@ -86,35 +86,35 @@  discard block
 block discarded – undo
86 86
             })
87 87
             ->toArray();
88 88
         if (!count($columns)) {
89
-            throw new DBException('Table not found by name: ' . implode('.', [$schema,$table]));
89
+            throw new DBException('Table not found by name: '.implode('.', [$schema, $table]));
90 90
         }
91 91
         $primary = [];
92 92
         foreach ($columns as $column) {
93
-            if ((int)$column['pk']) {
93
+            if ((int) $column['pk']) {
94 94
                 $primary[] = $column['name'];
95 95
             }
96 96
         }
97
-        $tables[$schema . '.' .$table] = $definition = (new Table($table, $schema))
97
+        $tables[$schema.'.'.$table] = $definition = (new Table($table, $schema))
98 98
             ->addColumns($columns)
99 99
             ->setPrimaryKey($primary)
100 100
             ->setComment('');
101 101
 
102 102
         if ($detectRelations) {
103 103
             $duplicated = [];
104
-            foreach ($relationsT[$schema . '.' . $table] ?? [] as $relation) {
105
-                $t = 'main.' . $relation['referenced_table'];
104
+            foreach ($relationsT[$schema.'.'.$table] ?? [] as $relation) {
105
+                $t = 'main.'.$relation['referenced_table'];
106 106
                 $duplicated[$t] = isset($duplicated[$t]);
107 107
             }
108
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) {
109
-                $t = 'main.' . $relation['table'];
108
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) {
109
+                $t = 'main.'.$relation['table'];
110 110
                 $duplicated[$t] = isset($duplicated[$t]);
111 111
             }
112 112
             // pivot relations where the current table is referenced
113 113
             // assuming current table is on the "one" end having "many" records in the referencing table
114 114
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
115 115
             $relations = [];
116
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $k => $relation) {
117
-                $relations[$relation['constraint_name']]['table'] = 'main.' . $relation['table'];
116
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $k => $relation) {
117
+                $relations[$relation['constraint_name']]['table'] = 'main.'.$relation['table'];
118 118
                 $relations[$relation['constraint_name']]['keymap'][$relation['to']] = $relation['from'];
119 119
             }
120 120
             foreach ($relations as $data) {
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
                 $usedcol = [];
130 130
                 if (count($columns)) {
131 131
                     foreach (Collection::from($relationsT[$data['table']] ?? [])
132
-                        ->filter(function ($v) use ($columns) {
132
+                        ->filter(function($v) use ($columns) {
133 133
                             return in_array($v['from'], $columns);
134 134
                         }) as $relation
135 135
                     ) {
136
-                        $foreign[$relation['constraint_name']]['table'] = 'main.' .
136
+                        $foreign[$relation['constraint_name']]['table'] = 'main.'.
137 137
                             $relation['referenced_table'];
138 138
                         $foreign[$relation['constraint_name']]['keymap'][$relation['from']] = $relation['to'];
139 139
                         $usedcol[] = $relation['from'];
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
                         $definition->getName() == $relname ||
153 153
                         $definition->getColumn($relname)
154 154
                     ) {
155
-                        $relname = $orig . '_' . (++ $cntr);
155
+                        $relname = $orig.'_'.(++$cntr);
156 156
                     }
157 157
                     $definition->addRelation(
158 158
                         new TableRelation(
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
             // assuming current table is linked to "one" record in the referenced table
175 175
             // resulting in a "belongsTo" relationship
176 176
             $relations = [];
177
-            foreach ($relationsT[$schema . '.' . $table] ?? [] as $relation) {
178
-                $relations[$relation['constraint_name']]['table'] = 'main.' . $relation['referenced_table'];
177
+            foreach ($relationsT[$schema.'.'.$table] ?? [] as $relation) {
178
+                $relations[$relation['constraint_name']]['table'] = 'main.'.$relation['referenced_table'];
179 179
                 $relations[$relation['constraint_name']]['keymap'][$relation['from']] = $relation['to'];
180 180
             }
181 181
             foreach ($relations as $name => $data) {
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
                     $definition->getName() == $relname ||
190 190
                     $definition->getColumn($relname)
191 191
                 ) {
192
-                    $relname = array_keys($data['keymap'])[0] . '_' . $relname;
192
+                    $relname = array_keys($data['keymap'])[0].'_'.$relname;
193 193
                 }
194 194
                 $orig = $relname;
195 195
                 $cntr = 1;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
                     $definition->getName() == $relname ||
198 198
                     $definition->getColumn($relname)
199 199
                 ) {
200
-                    $relname = $orig . '_' . (++ $cntr);
200
+                    $relname = $orig.'_'.(++$cntr);
201 201
                 }
202 202
                 $definition->addRelation(
203 203
                     new TableRelation(
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
             // assuming current table is on the "one" end having "many" records in the referencing table
214 214
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
215 215
             $relations = [];
216
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $k => $relation) {
217
-                $relations[$relation['constraint_name']]['table'] = 'main.' . $relation['table'];
216
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $k => $relation) {
217
+                $relations[$relation['constraint_name']]['table'] = 'main.'.$relation['table'];
218 218
                 $relations[$relation['constraint_name']]['keymap'][$relation['to']] = $relation['from'];
219 219
             }
220 220
             foreach ($relations as $data) {
@@ -229,11 +229,11 @@  discard block
 block discarded – undo
229 229
                 $usedcol = [];
230 230
                 if (count($columns)) {
231 231
                     foreach (Collection::from($relationsT[$data['table']] ?? [])
232
-                        ->filter(function ($v) use ($columns) {
232
+                        ->filter(function($v) use ($columns) {
233 233
                             return in_array($v['from'], $columns);
234 234
                         }) as $relation
235 235
                     ) {
236
-                        $foreign[$relation['constraint_name']]['table'] = 'main.' .
236
+                        $foreign[$relation['constraint_name']]['table'] = 'main.'.
237 237
                             $relation['referenced_table'];
238 238
                         $foreign[$relation['constraint_name']]['keymap'][$relation['from']] = $relation['to'];
239 239
                         $usedcol[] = $relation['from'];
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
                         $definition->getName() == $relname ||
251 251
                         $definition->getColumn($relname)
252 252
                     ) {
253
-                        $relname .= '_' . array_values($data['keymap'])[0];
253
+                        $relname .= '_'.array_values($data['keymap'])[0];
254 254
                     }
255 255
                     $orig = $relname;
256 256
                     $cntr = 1;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
                         $definition->getName() == $relname ||
259 259
                         $definition->getColumn($relname)
260 260
                     ) {
261
-                        $relname = $orig . '_' . (++ $cntr);
261
+                        $relname = $orig.'_'.(++$cntr);
262 262
                     }
263 263
                     $definition->addRelation(
264 264
                         new TableRelation(
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
                 "SELECT tbl_name
287 287
                  FROM sqlite_schema
288 288
                  WHERE (type = ? OR type = ?) AND tbl_name NOT LIKE 'sqlite_%';",
289
-                [ 'table', 'view' ]
289
+                ['table', 'view']
290 290
             ))
291
-            ->mapKey(function ($v) {
291
+            ->mapKey(function($v) {
292 292
                 return strtolower($v['tbl_name']);
293 293
             })
294 294
             ->pluck('tbl_name')
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
             $tables[$k] = $this->table($v, true, array_keys($tables))->toLowerCase();
298 298
         }
299 299
         foreach (array_keys($tables) as $k) {
300
-            $tables[($this->connection['opts']['schema'] ?? 'main') . '.' . $k] = &$tables[$k];
300
+            $tables[($this->connection['opts']['schema'] ?? 'main').'.'.$k] = &$tables[$k];
301 301
         }
302 302
         return $tables;
303 303
     }
Please login to merge, or discard this patch.
src/driver/oracle/Schema.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
         $columns = Collection::from($this
33 33
             ->query(
34 34
                 "SELECT * FROM user_tab_cols WHERE UPPER(table_name) = ?",
35
-                [ strtoupper($table) ]
35
+                [strtoupper($table)]
36 36
             ))
37
-            ->map(function ($v) {
37
+            ->map(function($v) {
38 38
                 $new = [];
39 39
                 foreach ($v as $kk => $vv) {
40 40
                     $new[strtoupper($kk)] = $vv;
41 41
                 }
42 42
                 return $new;
43 43
             })
44
-            ->mapKey(function ($v): string {
44
+            ->mapKey(function($v): string {
45 45
                 return $v['COLUMN_NAME'];
46 46
             })
47
-            ->map(function ($v) {
47
+            ->map(function($v) {
48 48
                 $v['length'] = null;
49 49
                 if (!isset($v['DATA_TYPE'])) {
50 50
                     return $v;
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
                     default:
57 57
                         if (strpos($type, 'char') !== false && strpos($type, '(') !== false) {
58 58
                             // extract length from varchar
59
-                            $v['length'] = (int)explode(')', (explode('(', $type)[1] ?? ''))[0];
59
+                            $v['length'] = (int) explode(')', (explode('(', $type)[1] ?? ''))[0];
60 60
                             $v['length'] = $v['length'] > 0 ? $v['length'] : null;
61 61
                         }
62 62
                         break;
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
             ->query(
74 74
                 "SELECT constraint_name FROM user_constraints
75 75
                 WHERE table_name = ? AND constraint_type = ?",
76
-                [ strtoupper($table), 'P' ]
76
+                [strtoupper($table), 'P']
77 77
             ))
78
-            ->map(function ($v) {
78
+            ->map(function($v) {
79 79
                 $new = [];
80 80
                 foreach ($v as $kk => $vv) {
81 81
                     $new[strtoupper($kk)] = $vv;
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
                 ->query(
91 91
                     "SELECT column_name FROM user_cons_columns
92 92
                     WHERE table_name = ? AND constraint_name = ?",
93
-                    [ strtoupper($table), $pkname ]
93
+                    [strtoupper($table), $pkname]
94 94
                 ))
95
-                ->map(function ($v) {
95
+                ->map(function($v) {
96 96
                     $new = [];
97 97
                     foreach ($v as $kk => $vv) {
98 98
                         $new[strtoupper($kk)] = $vv;
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
                     LEFT JOIN user_cons_columns cc ON cc.CONSTRAINT_NAME = ac.CONSTRAINT_NAME
121 121
                     WHERE ac.TABLE_NAME = ? AND ac.CONSTRAINT_TYPE = ?
122 122
                     ORDER BY cc.POSITION",
123
-                    [ strtoupper($table), 'R' ]
123
+                    [strtoupper($table), 'R']
124 124
                 ))
125
-                ->map(function ($v) {
125
+                ->map(function($v) {
126 126
                     $new = [];
127 127
                     foreach ($v as $kk => $vv) {
128 128
                         $new[strtoupper($kk)] = $vv;
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
                     WHERE
139 139
                         ac.R_CONSTRAINT_NAME = ? AND ac.CONSTRAINT_TYPE = ?
140 140
                     ORDER BY cc.POSITION",
141
-                    [ $pkname, 'R' ]
141
+                    [$pkname, 'R']
142 142
                 ))
143
-                ->map(function ($v) {
143
+                ->map(function($v) {
144 144
                     $new = [];
145 145
                     foreach ($v as $kk => $vv) {
146 146
                         $new[strtoupper($kk)] = $vv;
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
             $relations = [];
164 164
             foreach ($relationsR as $relation) {
165 165
                 $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_NAME'];
166
-                $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int)$relation['POSITION']-1]] =
166
+                $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int) $relation['POSITION'] - 1]] =
167 167
                     $relation['COLUMN_NAME'];
168 168
             }
169 169
             foreach ($relations as $data) {
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
                                 ac.TABLE_NAME = ? AND ac.CONSTRAINT_TYPE = ? AND
194 194
                                 cc.COLUMN_NAME IN (??)
195 195
                             ORDER BY POSITION",
196
-                            [ $data['table'], 'R', $columns ]
196
+                            [$data['table'], 'R', $columns]
197 197
                         ))
198
-                        ->map(function ($v) {
198
+                        ->map(function($v) {
199 199
                             $new = [];
200 200
                             foreach ($v as $kk => $vv) {
201 201
                                 $new[strtoupper($kk)] = $vv;
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
                         ->query(
216 216
                             "SELECT COLUMN_NAME FROM user_cons_columns
217 217
                             WHERE CONSTRAINT_NAME = ? ORDER BY POSITION",
218
-                            [ current($foreign['keymap']) ]
218
+                            [current($foreign['keymap'])]
219 219
                         ))
220
-                        ->map(function ($v) {
220
+                        ->map(function($v) {
221 221
                             $new = [];
222 222
                             foreach ($v as $kk => $vv) {
223 223
                                 $new[strtoupper($kk)] = $vv;
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
                     $relname = $foreign['table'];
233 233
                     $cntr = 1;
234 234
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
235
-                        $relname = $foreign['table'] . '_' . (++ $cntr);
235
+                        $relname = $foreign['table'].'_'.(++$cntr);
236 236
                     }
237 237
                     $definition->addRelation(
238 238
                         new TableRelation(
@@ -264,9 +264,9 @@  discard block
 block discarded – undo
264 264
                     ->query(
265 265
                         "SELECT COLUMN_NAME FROM user_cons_columns
266 266
                          WHERE CONSTRAINT_NAME = ? ORDER BY POSITION",
267
-                        [ current($data['keymap']) ]
267
+                        [current($data['keymap'])]
268 268
                     ))
269
-                    ->map(function ($v) {
269
+                    ->map(function($v) {
270 270
                         $new = [];
271 271
                         foreach ($v as $kk => $vv) {
272 272
                             $new[strtoupper($kk)] = $vv;
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
                     $definition->getName() == $relname ||
285 285
                     $definition->getColumn($relname)
286 286
                 ) {
287
-                    $relname = array_keys($data['keymap'])[0] . '_' . $relname;
287
+                    $relname = array_keys($data['keymap'])[0].'_'.$relname;
288 288
                 }
289 289
                 $orig = $relname;
290 290
                 $cntr = 1;
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
                     $definition->getName() == $relname ||
294 294
                     $definition->getColumn($relname)
295 295
                 ) {
296
-                    $relname = $orig . '_' . (++ $cntr);
296
+                    $relname = $orig.'_'.(++$cntr);
297 297
                 }
298 298
                 $definition->addRelation(
299 299
                     new TableRelation(
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
             $relations = [];
312 312
             foreach ($relationsR as $relation) {
313 313
                 $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_NAME'];
314
-                $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int)$relation['POSITION']-1]] =
314
+                $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int) $relation['POSITION'] - 1]] =
315 315
                     $relation['COLUMN_NAME'];
316 316
             }
317 317
             foreach ($relations as $data) {
@@ -341,9 +341,9 @@  discard block
 block discarded – undo
341 341
                                 ac.TABLE_NAME = ? AND ac.CONSTRAINT_TYPE = ? AND
342 342
                                 cc.COLUMN_NAME IN (??)
343 343
                             ORDER BY POSITION",
344
-                            [ $data['table'], 'R', $columns ]
344
+                            [$data['table'], 'R', $columns]
345 345
                         ))
346
-                        ->map(function ($v) {
346
+                        ->map(function($v) {
347 347
                             $new = [];
348 348
                             foreach ($v as $kk => $vv) {
349 349
                                 $new[strtoupper($kk)] = $vv;
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
                         $definition->getName() == $relname ||
365 365
                         $definition->getColumn($relname)
366 366
                     ) {
367
-                        $relname .= '_' . array_values($data['keymap'])[0];
367
+                        $relname .= '_'.array_values($data['keymap'])[0];
368 368
                     }
369 369
                     $orig = $relname;
370 370
                     $cntr = 1;
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
                         $definition->getName() == $relname ||
374 374
                         $definition->getColumn($relname)
375 375
                     ) {
376
-                        $relname = $orig . '_' . (++ $cntr);
376
+                        $relname = $orig.'_'.(++$cntr);
377 377
                     }
378 378
                     $definition->addRelation(
379 379
                         new TableRelation(
@@ -403,18 +403,18 @@  discard block
 block discarded – undo
403 403
                  SELECT VIEW_NAME AS TABLE_NAME FROM USER_VIEWS",
404 404
                 []
405 405
             ))
406
-            ->map(function ($v) {
406
+            ->map(function($v) {
407 407
                 $new = [];
408 408
                 foreach ($v as $kk => $vv) {
409 409
                     $new[strtoupper($kk)] = $vv;
410 410
                 }
411 411
                 return $new;
412 412
             })
413
-            ->mapKey(function ($v) {
413
+            ->mapKey(function($v) {
414 414
                 return strtolower($v['TABLE_NAME']);
415 415
             })
416 416
             ->pluck('TABLE_NAME')
417
-            ->map(function ($v) {
417
+            ->map(function($v) {
418 418
                 return $this->table($v)->toLowerCase();
419 419
             })
420 420
             ->toArray();
Please login to merge, or discard this patch.
src/driver/mysql/Result.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
                 if ($temp) {
33 33
                     $temp = $temp->fetch_fields();
34 34
                     if ($temp) {
35
-                        $columns = array_map(function ($v) {
35
+                        $columns = array_map(function($v) {
36 36
                             return $v->name;
37 37
                         }, $temp);
38 38
                     }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     }
52 52
     public function affected() : int
53 53
     {
54
-        return (int)$this->statement->affected_rows;
54
+        return (int) $this->statement->affected_rows;
55 55
     }
56 56
     public function insertID(?string $sequence = null): mixed
57 57
     {
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     }
74 74
     public function current(): mixed
75 75
     {
76
-        return $this->nativeDriver ? $this->last : array_map(function ($v) {
76
+        return $this->nativeDriver ? $this->last : array_map(function($v) {
77 77
             return $v;
78 78
         }, $this->row);
79 79
     }
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
     }
93 93
     public function next(): void
94 94
     {
95
-        $this->fetched ++;
96
-        $this->last = $this->nativeDriver ? ($this->result->fetch_assoc()?:null) : $this->statement->fetch();
95
+        $this->fetched++;
96
+        $this->last = $this->nativeDriver ? ($this->result->fetch_assoc() ?: null) : $this->statement->fetch();
97 97
     }
98 98
     public function valid(): bool
99 99
     {
Please login to merge, or discard this patch.
src/driver/oracle/Result.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     }
25 25
     public function affected() : int
26 26
     {
27
-        return (int)\oci_num_rows($this->statement);
27
+        return (int) \oci_num_rows($this->statement);
28 28
     }
29 29
     public function insertID(?string $sequence = null): mixed
30 30
     {
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
     public function count(): int
39 39
     {
40
-        return (int)\oci_num_rows($this->statement);
40
+        return (int) \oci_num_rows($this->statement);
41 41
     }
42 42
 
43 43
     public function key(): mixed
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
     }
66 66
     public function next(): void
67 67
     {
68
-        $this->fetched ++;
69
-        $this->last = \oci_fetch_array($this->statement, \OCI_ASSOC + \OCI_RETURN_NULLS + \OCI_RETURN_LOBS)?:null;
68
+        $this->fetched++;
69
+        $this->last = \oci_fetch_array($this->statement, \OCI_ASSOC +\OCI_RETURN_NULLS +\OCI_RETURN_LOBS) ?: null;
70 70
         if (is_array($this->last)) {
71 71
             $this->cast();
72 72
         }
@@ -78,23 +78,23 @@  discard block
 block discarded – undo
78 78
     protected function cast(): void
79 79
     {
80 80
         if (!count($this->types)) {
81
-            foreach (array_keys($this->last??[]) as $k => $v) {
81
+            foreach (array_keys($this->last ?? []) as $k => $v) {
82 82
                 $this->types[$v] = \oci_field_type($this->statement, $k + 1);
83 83
                 if ($this->types[$v] === 'NUMBER') {
84 84
                     $scale = \oci_field_scale($this->statement, $k + 1);
85 85
                     $precision = \oci_field_precision($this->statement, $k + 1);
86 86
                     // true float
87
-                    if ((int)$scale === -127 && (int)$precision !== 0) {
87
+                    if ((int) $scale === -127 && (int) $precision !== 0) {
88 88
                         $this->types[$v] = 'FLOAT';
89 89
                     }
90 90
                     // TODO: decimal
91
-                    if ((int)$scale > 0) {
91
+                    if ((int) $scale > 0) {
92 92
                         $this->types[$v] = 'DECIMAL';
93 93
                     }
94 94
                 }
95 95
             }
96 96
         }
97
-        foreach ($this->last??[] as $k => $v) {
97
+        foreach ($this->last ?? [] as $k => $v) {
98 98
             if (!isset($this->types[$k])) {
99 99
                 continue;
100 100
             }
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
             }
110 110
             switch ($this->types[$k]) {
111 111
                 case 'NUMBER':
112
-                    $this->last[$k] = (int)$v;
112
+                    $this->last[$k] = (int) $v;
113 113
                     break;
114 114
                 case 'FLOAT':
115
-                    $this->last[$k] = (float)$v;
115
+                    $this->last[$k] = (float) $v;
116 116
                     break;
117 117
             }
118 118
         }
Please login to merge, or discard this patch.
src/schema/Table.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
      * @param  array|string        $column either a single column name or an array of column names
85 85
      * @return  static
86 86
      */
87
-    public function setPrimaryKey(array|string $column): static
87
+    public function setPrimaryKey(array | string $column): static
88 88
     {
89 89
         if (!is_array($column)) {
90
-            $column = [ $column ];
90
+            $column = [$column];
91 91
         }
92 92
         $this->data['primary'] = array_values($column);
93 93
         return $this;
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      */
115 115
     public function getFullName(): string
116 116
     {
117
-        return ($this->data['schema'] ? $this->data['schema'] . '.' : '') . $this->data['name'];
117
+        return ($this->data['schema'] ? $this->data['schema'].'.' : '').$this->data['name'];
118 118
     }
119 119
     /**
120 120
      * Get a column definition
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
     public function hasOne(
172 172
         Table $toTable,
173 173
         ?string $name = null,
174
-        string|array|null $toTableColumn = null,
174
+        string | array | null $toTableColumn = null,
175 175
         ?string $sql = null,
176 176
         array $par = []
177 177
     ) : static {
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         }
200 200
 
201 201
         if (!isset($name)) {
202
-            $name = $toTable->getName() . '_' . implode('_', array_keys($keymap));
202
+            $name = $toTable->getName().'_'.implode('_', array_keys($keymap));
203 203
         }
204 204
         $this->addRelation(new TableRelation(
205 205
             $this,
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     public function hasMany(
227 227
         Table $toTable,
228 228
         ?string $name = null,
229
-        string|array|null $toTableColumn = null,
229
+        string | array | null $toTableColumn = null,
230 230
         ?string $sql = null,
231 231
         array $par = []
232 232
     ): static {
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
     public function belongsTo(
282 282
         Table $toTable,
283 283
         ?string $name = null,
284
-        string|array|null $localColumn = null,
284
+        string | array | null $localColumn = null,
285 285
         ?string $sql = null,
286 286
         array $par = []
287 287
     ): static {
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
         Table $toTable,
338 338
         Table $pivot,
339 339
         ?string $name = null,
340
-        string|array|null $toTableColumn = null,
341
-        string|array|null $localColumn = null
340
+        string | array | null $toTableColumn = null,
341
+        string | array | null $localColumn = null
342 342
     ): static {
343 343
         $pivotColumns = $pivot->getColumns();
344 344
 
Please login to merge, or discard this patch.
src/schema/TableQuery.php 1 patch
Spacing   +263 added lines, -263 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];
25
+    protected array $li_of = [0, 0];
26 26
     protected bool $li_mt = false;
27 27
     protected array $fields = [];
28 28
     protected array $withr = [];
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
      * @param  Table|string   $table           the name or definition of the main table in the query
38 38
      * @param  bool           $findRelations   should the query builder try to find missing joins
39 39
      */
40
-    public function __construct(DBInterface $db, Table|string $table, bool $findRelations = false)
40
+    public function __construct(DBInterface $db, Table | string $table, bool $findRelations = false)
41 41
     {
42 42
         $this->db = $db;
43 43
         $this->findRelations = $findRelations;
44
-        $this->definition = $table instanceof Table ? $table : $this->db->definition((string)$table);
44
+        $this->definition = $table instanceof Table ? $table : $this->db->definition((string) $table);
45 45
         $primary = $this->definition->getPrimaryKey();
46 46
         $columns = $this->definition->getColumns();
47 47
         $this->pkey = count($primary) ? $primary : $columns;
@@ -64,27 +64,27 @@  discard block
 block discarded – undo
64 64
     {
65 65
         $column = explode('.', $column);
66 66
         if (count($column) === 1) {
67
-            $column = [ $this->definition->getFullName(), $column[0] ];
67
+            $column = [$this->definition->getFullName(), $column[0]];
68 68
             $col = $this->definition->getColumn($column[1]);
69 69
             if (!$col) {
70
-                throw new DBException('Invalid column name in main table: ' . $column[1]);
70
+                throw new DBException('Invalid column name in main table: '.$column[1]);
71 71
             }
72 72
         } elseif (count($column) === 2) {
73 73
             if ($column[0] === $this->definition->getName()) {
74 74
                 $col = $this->definition->getColumn($column[1]);
75 75
                 if (!$col) {
76
-                    throw new DBException('Invalid column name in main table: ' . $column[1]);
76
+                    throw new DBException('Invalid column name in main table: '.$column[1]);
77 77
                 }
78 78
             } else {
79 79
                 if ($this->definition->hasRelation($column[0])) {
80 80
                     $col = $this->definition->getRelation($column[0])?->table?->getColumn($column[1]);
81 81
                     if (!$col) {
82
-                        throw new DBException('Invalid column name in related table: ' . $column[1]);
82
+                        throw new DBException('Invalid column name in related table: '.$column[1]);
83 83
                     }
84 84
                 } elseif (isset($this->joins[$column[0]])) {
85 85
                     $col = $this->joins[$column[0]]->table->getColumn($column[1]);
86 86
                     if (!$col) {
87
-                        throw new DBException('Invalid column name in related table: ' . $column[1]);
87
+                        throw new DBException('Invalid column name in related table: '.$column[1]);
88 88
                     }
89 89
                 } else {
90 90
                     $col = null;
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
                             $path = $this->db->findRelation($this->definition->getName(), $column[0]);
104 104
                         }
105 105
                         if (!count($path)) {
106
-                            throw new DBException('Invalid foreign table / column name: ' . implode(',', $column));
106
+                            throw new DBException('Invalid foreign table / column name: '.implode(',', $column));
107 107
                         }
108 108
                         unset($path[0]);
109 109
                         $this->with(implode('.', $path), false);
@@ -116,26 +116,26 @@  discard block
 block discarded – undo
116 116
             if ($this->definition->hasRelation(implode('.', $column))) {
117 117
                 $this->with(implode('.', $column), false);
118 118
                 $col = $this->definition->getRelation(implode('.', $column))?->table?->getColumn($name);
119
-                $column = [ implode('.', $column), $name ];
119
+                $column = [implode('.', $column), $name];
120 120
             } else {
121 121
                 $this->with(implode('.', $column), false);
122 122
                 $table = $this->definition;
123 123
                 $table = array_reduce(
124 124
                     $column,
125
-                    function ($carry, $item) use (&$table) {
125
+                    function($carry, $item) use (&$table) {
126 126
                         $table = $table->getRelation($item)->table;
127 127
                         return $table;
128 128
                     }
129 129
                 );
130 130
                 $col = $table->getColumn($name);
131
-                $column = [ implode(static::SEP, $column), $name ];
131
+                $column = [implode(static::SEP, $column), $name];
132 132
             }
133 133
         }
134
-        return [ 'name' => implode('.', $column), 'data' => $col ];
134
+        return ['name' => implode('.', $column), 'data' => $col];
135 135
     }
136 136
     protected function normalizeValue(TableColumn $col, mixed $value): mixed
137 137
     {
138
-        $strict = (int)$this->db->driverOption('strict', 0) > 0;
138
+        $strict = (int) $this->db->driverOption('strict', 0) > 0;
139 139
         if ($value === null && $col->isNullable()) {
140 140
             return null;
141 141
         }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                     $temp = strtotime($value);
146 146
                     if (!$temp) {
147 147
                         if ($strict) {
148
-                            throw new DBException('Invalid value for date column: ' . $col->getName());
148
+                            throw new DBException('Invalid value for date column: '.$col->getName());
149 149
                         }
150 150
                         return null;
151 151
                     }
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
                     return $value->format('Y-m-d');
159 159
                 }
160 160
                 if ($strict) {
161
-                    throw new DBException('Invalid value (unknown data type) for date column: ' . $col->getName());
161
+                    throw new DBException('Invalid value (unknown data type) for date column: '.$col->getName());
162 162
                 }
163 163
                 return $value;
164 164
             case 'datetime':
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
                     $temp = strtotime($value);
167 167
                     if (!$temp) {
168 168
                         if ($strict) {
169
-                            throw new DBException('Invalid value for datetime column: ' . $col->getName());
169
+                            throw new DBException('Invalid value for datetime column: '.$col->getName());
170 170
                         }
171 171
                         return null;
172 172
                     }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
                     return $value->format('Y-m-d H:i:s');
180 180
                 }
181 181
                 if ($strict) {
182
-                    throw new DBException('Invalid value (unknown data type) for datetime column ' . $col->getName());
182
+                    throw new DBException('Invalid value (unknown data type) for datetime column '.$col->getName());
183 183
                 }
184 184
                 return $value;
185 185
             case 'enum':
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
                 if (is_int($value)) {
188 188
                     if (!isset($values[$value])) {
189 189
                         if ($strict) {
190
-                            throw new DBException('Invalid value (using integer) for enum: ' . $col->getName());
190
+                            throw new DBException('Invalid value (using integer) for enum: '.$col->getName());
191 191
                         }
192 192
                         return $value;
193 193
                     }
@@ -195,23 +195,23 @@  discard block
 block discarded – undo
195 195
                 }
196 196
                 if (!in_array($value, $col->getValues())) {
197 197
                     if ($strict) {
198
-                        throw new DBException('Invalid value for enum: ' . $col->getName());
198
+                        throw new DBException('Invalid value for enum: '.$col->getName());
199 199
                     }
200 200
                     return 0;
201 201
                 }
202 202
                 return $value;
203 203
             case 'int':
204
-                $temp = preg_replace('([^+\-0-9]+)', '', (string)$value);
205
-                return is_string($temp) ? (int)$temp : 0;
204
+                $temp = preg_replace('([^+\-0-9]+)', '', (string) $value);
205
+                return is_string($temp) ? (int) $temp : 0;
206 206
             case 'float':
207
-                $temp = preg_replace('([^+\-0-9.]+)', '', str_replace(',', '.', (string)$value));
208
-                return is_string($temp) ? (float)$temp : 0;
207
+                $temp = preg_replace('([^+\-0-9.]+)', '', str_replace(',', '.', (string) $value));
208
+                return is_string($temp) ? (float) $temp : 0;
209 209
             case 'text':
210 210
                 // check using strlen first, in order to avoid hitting mb_ functions which might be polyfilled
211 211
                 // because the polyfill is quite slow
212 212
                 if ($col->hasLength() && strlen($value) > $col->getLength() && mb_strlen($value) > $col->getLength()) {
213 213
                     if ($strict) {
214
-                        throw new DBException('Invalid value for text column: ' . $col->getName());
214
+                        throw new DBException('Invalid value for text column: '.$col->getName());
215 215
                     }
216 216
                     return mb_substr($value, 0, $col->getLength());
217 217
                 }
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
                     $sqls[] = $temp[0];
240 240
                     $pars = array_merge($pars, $temp[1]);
241 241
                     unset($value[$k]);
242
-                } elseif (in_array($k, ['like','ilike','contains','icontains','ends','iends'])) {
242
+                } elseif (in_array($k, ['like', 'ilike', 'contains', 'icontains', 'ends', 'iends'])) {
243 243
                     if ($column->getBasicType() !== 'text') {
244 244
                         switch ($this->db->driverName()) {
245 245
                             case 'oracle':
246
-                                $name = 'CAST(' . $name . ' AS NVARCHAR(500))';
246
+                                $name = 'CAST('.$name.' AS NVARCHAR(500))';
247 247
                                 break;
248 248
                             case 'postgre':
249 249
                                 $name = $name.'::text';
@@ -258,25 +258,25 @@  discard block
 block discarded – undo
258 258
                     $sql = [];
259 259
                     $par = [];
260 260
                     foreach ($values as $v) {
261
-                        $v = str_replace(['%', '_'], ['\\%','\\_'], $v) . '%';
261
+                        $v = str_replace(['%', '_'], ['\\%', '\\_'], $v).'%';
262 262
                         if ($mode === 'contains' || $mode === 'icontains') {
263
-                            $v = '%' . $v;
263
+                            $v = '%'.$v;
264 264
                         }
265 265
                         if ($mode === 'ends' || $mode === 'iends') {
266
-                            $v = '%' . rtrim($v, '%');
266
+                            $v = '%'.rtrim($v, '%');
267 267
                         }
268 268
                         if ($mode === 'icontains' || $mode === 'ilike' || $mode === 'iends') {
269 269
                             $v = mb_strtoupper($v);
270
-                            $name = 'UPPER(' . $name . ')';
270
+                            $name = 'UPPER('.$name.')';
271 271
                         }
272
-                        $sql[] = $negate ? $name . ' NOT LIKE ?' : $name . ' LIKE ?';
272
+                        $sql[] = $negate ? $name.' NOT LIKE ?' : $name.' LIKE ?';
273 273
                         $par[] = $v;
274 274
                     }
275 275
                     if ($negate) {
276
-                        $sqls[] = '(' . implode(' AND ', $sql) . ')';
276
+                        $sqls[] = '('.implode(' AND ', $sql).')';
277 277
                         $pars = array_merge($pars, $par);
278 278
                     } else {
279
-                        $sqls[] = '(' . implode(' OR ', $sql) . ')';
279
+                        $sqls[] = '('.implode(' OR ', $sql).')';
280 280
                         $pars = array_merge($pars, $par);
281 281
                     }
282 282
                     unset($value[$k]);
@@ -284,38 +284,38 @@  discard block
 block discarded – undo
284 284
             }
285 285
             if (!count($value)) {
286 286
                 return [
287
-                    '(' . implode(' AND ', $sqls) . ')',
287
+                    '('.implode(' AND ', $sqls).')',
288 288
                     $pars
289 289
                 ];
290 290
             }
291 291
         }
292 292
         if (is_null($value)) {
293
-            $sqls[] = $negate ? $name . ' IS NOT NULL' : $name . ' IS NULL';
293
+            $sqls[] = $negate ? $name.' IS NOT NULL' : $name.' IS NULL';
294 294
             return [
295
-                '(' . implode(' AND ', $sqls) . ')',
295
+                '('.implode(' AND ', $sqls).')',
296 296
                 $pars
297 297
             ];
298 298
         }
299 299
         if (!is_array($value)) {
300
-            $sqls[] = $negate ? $name . ' <> ?' : $name . ' = ?';
300
+            $sqls[] = $negate ? $name.' <> ?' : $name.' = ?';
301 301
             $pars[] = $this->normalizeValue($column, $value);
302 302
             return [
303
-                '(' . implode(' AND ', $sqls) . ')',
303
+                '('.implode(' AND ', $sqls).')',
304 304
                 $pars
305 305
             ];
306 306
         }
307 307
         if (isset($value['beg']) && strlen($value['beg']) && (!isset($value['end']) || !strlen($value['end']))) {
308
-            $value = [ 'gte' => $value['beg'] ];
308
+            $value = ['gte' => $value['beg']];
309 309
         }
310 310
         if (isset($value['end']) && strlen($value['end']) && (!isset($value['beg']) || !strlen($value['beg']))) {
311
-            $value = [ 'lte' => $value['end'] ];
311
+            $value = ['lte' => $value['end']];
312 312
         }
313 313
         if (isset($value['beg']) && isset($value['end'])) {
314 314
             $sqls[] = $negate ? $name.' NOT BETWEEN ? AND ?' : $name.' BETWEEN ? AND ?';
315 315
             $pars[] = $this->normalizeValue($column, $value['beg']);
316 316
             $pars[] = $this->normalizeValue($column, $value['end']);
317 317
             return [
318
-                '(' . implode(' AND ', $sqls) . ')',
318
+                '('.implode(' AND ', $sqls).')',
319 319
                 $pars
320 320
             ];
321 321
         }
@@ -323,51 +323,51 @@  discard block
 block discarded – undo
323 323
             $sql = [];
324 324
             $par = [];
325 325
             if (isset($value['gt'])) {
326
-                $sql[] = $name. ' ' . ($negate ? '<=' : '>') . ' ?';
326
+                $sql[] = $name.' '.($negate ? '<=' : '>').' ?';
327 327
                 $par[] = $this->normalizeValue($column, $value['gt']);
328 328
             }
329 329
             if (isset($value['gte'])) {
330
-                $sql[] = $name. ' ' . ($negate ? '<' : '>=') . ' ?';
330
+                $sql[] = $name.' '.($negate ? '<' : '>=').' ?';
331 331
                 $par[] = $this->normalizeValue($column, $value['gte']);
332 332
             }
333 333
             if (isset($value['lt'])) {
334
-                $sql[] = $name. ' ' . ($negate ? '>=' : '<') . ' ?';
334
+                $sql[] = $name.' '.($negate ? '>=' : '<').' ?';
335 335
                 $par[] = $this->normalizeValue($column, $value['lt']);
336 336
             }
337 337
             if (isset($value['lte'])) {
338
-                $sql[] = $name. ' ' . ($negate ? '>' : '<=') . ' ?';
338
+                $sql[] = $name.' '.($negate ? '>' : '<=').' ?';
339 339
                 $par[] = $this->normalizeValue($column, $value['lte']);
340 340
             }
341
-            $sqls[] = '(' . implode(' AND ', $sql) . ')';
341
+            $sqls[] = '('.implode(' AND ', $sql).')';
342 342
             $pars = array_merge($pars, $par);
343 343
             return [
344
-                '(' . implode(' AND ', $sqls) . ')',
344
+                '('.implode(' AND ', $sqls).')',
345 345
                 $pars
346 346
             ];
347 347
         }
348 348
 
349
-        $value = array_values(array_map(function ($v) use ($column) {
349
+        $value = array_values(array_map(function($v) use ($column) {
350 350
             return $this->normalizeValue($column, $v);
351 351
         }, $value));
352 352
         if ($this->db->driverName() === 'oracle') {
353 353
             $sql = [];
354 354
             $par = [];
355 355
             for ($i = 0; $i < count($value); $i += 500) {
356
-                $sql[] = $negate ? $name . ' NOT IN (??)' : $name . ' IN (??)';
356
+                $sql[] = $negate ? $name.' NOT IN (??)' : $name.' IN (??)';
357 357
                 $par[] = array_slice($value, $i, 500);
358 358
             }
359
-            $sql = '(' . implode($negate ? ' AND ' : ' OR ', $sql) . ')';
359
+            $sql = '('.implode($negate ? ' AND ' : ' OR ', $sql).')';
360 360
             $sqls[] = $sql;
361 361
             $pars = array_merge($pars, $par);
362 362
             return [
363
-                '(' . implode(' AND ', $sqls) . ')',
363
+                '('.implode(' AND ', $sqls).')',
364 364
                 $pars
365 365
             ];
366 366
         }
367
-        $sqls[] = $negate ? $name . ' NOT IN (??)' : $name . ' IN (??)';
367
+        $sqls[] = $negate ? $name.' NOT IN (??)' : $name.' IN (??)';
368 368
         $pars[] = $value;
369 369
         return [
370
-            '(' . implode(' AND ', $sqls) . ')',
370
+            '('.implode(' AND ', $sqls).')',
371 371
             $pars
372 372
         ];
373 373
     }
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
                 $par = array_merge($par, $temp[1]);
400 400
             }
401 401
         }
402
-        return $this->where('(' . implode(' OR ', $sql) . ')', $par);
402
+        return $this->where('('.implode(' OR ', $sql).')', $par);
403 403
     }
404 404
     /**
405 405
      * Filter the results matching all of the criteria
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
                 $par = array_merge($par, $temp[1]);
418 418
             }
419 419
         }
420
-        return $this->where('(' . implode(' AND ', $sql) . ')', $par);
420
+        return $this->where('('.implode(' AND ', $sql).')', $par);
421 421
     }
422 422
     /**
423 423
      * Sort by a column
@@ -430,9 +430,9 @@  discard block
 block discarded – undo
430 430
         try {
431 431
             $this->getColumn($column);
432 432
         } catch (DBException $e) {
433
-            throw new DBException('Invalid sort column: ' . $column);
433
+            throw new DBException('Invalid sort column: '.$column);
434 434
         }
435
-        return $this->order($column . ' ' . ($desc ? 'DESC' : 'ASC'));
435
+        return $this->order($column.' '.($desc ? 'DESC' : 'ASC'));
436 436
     }
437 437
     /**
438 438
      * Group by a column (or columns)
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
     public function group($column) : static
443 443
     {
444 444
         if (!is_array($column)) {
445
-            $column = [ $column ];
445
+            $column = [$column];
446 446
         }
447 447
         foreach ($column as $k => $v) {
448 448
             $column[$k] = $this->getColumn($v)['name'];
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
         $this->order = [];
486 486
         $this->having = [];
487 487
         $this->aliases = [];
488
-        $this->li_of = [0,0];
488
+        $this->li_of = [0, 0];
489 489
         $this->li_mt = false;
490 490
         $this->qiterator = null;
491 491
         return $this;
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
     public function groupBy(string $sql, array $params = []) : static
500 500
     {
501 501
         $this->qiterator = null;
502
-        $this->group = [ $sql, $params ];
502
+        $this->group = [$sql, $params];
503 503
         return $this;
504 504
     }
505 505
     /**
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
     public function join($table, array $fields, ?string $name = null, bool $multiple = true)
514 514
     {
515 515
         $this->qiterator = null;
516
-        $table = $table instanceof Table ? $table : $this->db->definition((string)$table);
516
+        $table = $table instanceof Table ? $table : $this->db->definition((string) $table);
517 517
         $name = $name ?? $table->getName();
518 518
         if (isset($this->joins[$name]) || $this->definition->hasRelation($name)) {
519 519
             throw new DBException('Alias / table name already in use');
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
         foreach ($fields as $k => $v) {
523 523
             $k = explode('.', $k, 2);
524 524
             $k = count($k) == 2 ? $k[1] : $k[0];
525
-            $this->joins[$name]->keymap[$this->getColumn($name . '.' . $k)['name']] = $this->getColumn($v)['name'];
525
+            $this->joins[$name]->keymap[$this->getColumn($name.'.'.$k)['name']] = $this->getColumn($v)['name'];
526 526
         }
527 527
         return $this;
528 528
     }
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
     public function where(string $sql, array $params = []) : static
536 536
     {
537 537
         $this->qiterator = null;
538
-        $this->where[] = [ $sql, $params ];
538
+        $this->where[] = [$sql, $params];
539 539
         return $this;
540 540
     }
541 541
     /**
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
     public function having(string $sql, array $params = []) : static
548 548
     {
549 549
         $this->qiterator = null;
550
-        $this->having[] = [ $sql, $params ];
550
+        $this->having[] = [$sql, $params];
551 551
         return $this;
552 552
     }
553 553
     /**
@@ -567,12 +567,12 @@  discard block
 block discarded – undo
567 567
                     throw new \Exception();
568 568
                 }
569 569
                 $name = $this->getColumn(trim($name))['name'];
570
-                $sql = $name . ' ' . (strpos(strtolower($sql), ' desc') ? 'DESC' : 'ASC');
570
+                $sql = $name.' '.(strpos(strtolower($sql), ' desc') ? 'DESC' : 'ASC');
571 571
             } catch (\Exception $e) {
572 572
                 $name = null;
573 573
             }
574 574
         }
575
-        $this->order = [ $sql, $params, $name ];
575
+        $this->order = [$sql, $params, $name];
576 576
         return $this;
577 577
     }
578 578
     /**
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
     public function limit(int $limit, int $offset = 0, ?bool $limitOnMainTable = null) : static
585 585
     {
586 586
         $this->qiterator = null;
587
-        $this->li_of = [ $limit, $offset ];
587
+        $this->li_of = [$limit, $offset];
588 588
         if (isset($limitOnMainTable)) {
589 589
             $this->li_mt = $limitOnMainTable;
590 590
         }
@@ -603,9 +603,9 @@  discard block
 block discarded – undo
603 603
     {
604 604
         $aliases = [];
605 605
         $aliases_ext = [];
606
-        $getAlias = function ($name) use (&$aliases, &$aliases_ext) {
606
+        $getAlias = function($name) use (&$aliases, &$aliases_ext) {
607 607
             // to bypass use: return $name;
608
-            $aliases[$name] = $aliases[$name] ?? 'alias' . static::SEP . count($aliases);
608
+            $aliases[$name] = $aliases[$name] ?? 'alias'.static::SEP.count($aliases);
609 609
             if (isset($aliases_ext[$name])) {
610 610
                 unset($aliases_ext[$name]);
611 611
             }
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
         $h = $this->having;
629 629
         $o = $this->order;
630 630
         $g = $this->group;
631
-        $j = array_map(function ($v) {
631
+        $j = array_map(function($v) {
632 632
             return clone $v;
633 633
         }, $this->joins);
634 634
 
@@ -638,28 +638,28 @@  discard block
 block discarded – undo
638 638
                 continue;
639 639
             }
640 640
             foreach ($w as $kk => $v) {
641
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
641
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
642 642
                     $used_relations[] = $k;
643
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $v[0]);
643
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $v[0]);
644 644
                 }
645 645
             }
646 646
             foreach ($h as $kk => $v) {
647
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
647
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
648 648
                     $used_relations[] = $k;
649
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $v[0]);
649
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $v[0]);
650 650
                 }
651 651
             }
652
-            if (isset($g[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $g[0])) {
652
+            if (isset($g[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $g[0])) {
653 653
                 $used_relations[] = $k;
654
-                $g[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $g[0]);
654
+                $g[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $g[0]);
655 655
             }
656 656
             foreach ($j as $kk => $v) {
657 657
                 foreach ($v->keymap as $kkk => $vv) {
658
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv)) {
658
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vv)) {
659 659
                         $used_relations[] = $k;
660 660
                         $j[$kk]->keymap[$kkk] = preg_replace(
661
-                            '(\b'.preg_quote($k . '.'). ')i',
662
-                            $getAlias($k) . '.',
661
+                            '(\b'.preg_quote($k.'.').')i',
662
+                            $getAlias($k).'.',
663 663
                             $vv
664 664
                         );
665 665
                     }
@@ -668,65 +668,65 @@  discard block
 block discarded – undo
668 668
         }
669 669
         foreach ($this->definition->getRelations() as $k => $v) {
670 670
             foreach ($w as $kk => $vv) {
671
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv[0])) {
672
-                    $relations[$k] = [ $v, $table ];
671
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $vv[0])) {
672
+                    $relations[$k] = [$v, $table];
673 673
                     $used_relations[] = $k;
674
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $vv[0]);
674
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $vv[0]);
675 675
                 }
676 676
             }
677
-            if (isset($o[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $o[0])) {
678
-                $relations[$k] = [ $v, $table ];
677
+            if (isset($o[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $o[0])) {
678
+                $relations[$k] = [$v, $table];
679 679
             }
680 680
             foreach ($h as $kk => $vv) {
681
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv[0])) {
682
-                    $relations[$k] = [ $v, $table ];
681
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $vv[0])) {
682
+                    $relations[$k] = [$v, $table];
683 683
                     $used_relations[] = $k;
684
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $vv[0]);
684
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $vv[0]);
685 685
                 }
686 686
             }
687
-            if (isset($g[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $g[0])) {
688
-                $relations[$k] = [ $v, $table ];
687
+            if (isset($g[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $g[0])) {
688
+                $relations[$k] = [$v, $table];
689 689
                 $used_relations[] = $k;
690
-                $g[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $g[0]);
690
+                $g[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $g[0]);
691 691
             }
692 692
             foreach ($j as $kk => $vv) {
693 693
                 foreach ($vv->keymap as $kkk => $vvv) {
694
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vvv)) {
695
-                        $relations[$k] = [ $v, $table ];
694
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vvv)) {
695
+                        $relations[$k] = [$v, $table];
696 696
                         $used_relations[] = $k;
697 697
                         $j[$kk]->keymap[$kkk] =
698
-                            preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $vvv);
698
+                            preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $vvv);
699 699
                     }
700 700
                 }
701 701
             }
702 702
         }
703 703
         foreach ($aliases_ext as $k => $alias) {
704 704
             foreach ($w as $kk => $v) {
705
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
706
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $v[0]);
705
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
706
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $v[0]);
707 707
                     $used_relations[] = $k;
708 708
                 }
709 709
             }
710 710
             foreach ($h as $kk => $v) {
711
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
712
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $v[0]);
711
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
712
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $v[0]);
713 713
                     $used_relations[] = $k;
714 714
                 }
715 715
             }
716
-            if (isset($o[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $o[0])) {
716
+            if (isset($o[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $o[0])) {
717 717
                 $used_relations[] = $k;
718 718
             }
719
-            if (isset($g[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $g[0])) {
720
-                $g[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $g[0]);
719
+            if (isset($g[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $g[0])) {
720
+                $g[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $g[0]);
721 721
                 $used_relations[] = $k;
722 722
             }
723 723
             foreach ($j as $kk => $v) {
724 724
                 foreach ($v->keymap as $kkk => $vv) {
725
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv)) {
725
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vv)) {
726 726
                         $used_relations[] = $k;
727 727
                         $j[$kk]->keymap[$kkk] = preg_replace(
728
-                            '(\b'.preg_quote($k . '.'). ')i',
729
-                            $alias . '.',
728
+                            '(\b'.preg_quote($k.'.').')i',
729
+                            $alias.'.',
730 730
                             $vv
731 731
                         );
732 732
                     }
@@ -745,13 +745,13 @@  discard block
 block discarded – undo
745 745
                     foreach ($v->keymap as $kk => $vv) {
746 746
                         $tmp[] = $table.'.'.$kk.' = '.$alias.'.'.$vv.' ';
747 747
                     }
748
-                    $sql .= implode(' AND ', $tmp) . ' ';
748
+                    $sql .= implode(' AND ', $tmp).' ';
749 749
                     $sql .= 'LEFT JOIN '.$v->table->getFullName().' '.$getAlias($k).' ON ';
750 750
                     $tmp = [];
751 751
                     foreach ($v->pivot_keymap as $kk => $vv) {
752 752
                         $tmp[] = $getAlias($k).'.'.$vv.' = '.$alias.'.'.$kk.' ';
753 753
                     }
754
-                    $sql .= implode(' AND ', $tmp) . ' ';
754
+                    $sql .= implode(' AND ', $tmp).' ';
755 755
                 } else {
756 756
                     $alias = $getAlias($k);
757 757
                     $sql .= 'LEFT JOIN '.$v->table->getFullName().' '.$alias.' ON ';
@@ -760,10 +760,10 @@  discard block
 block discarded – undo
760 760
                         $tmp[] = $table.'.'.$kk.' = '.$alias.'.'.$vv.' ';
761 761
                     }
762 762
                     if ($v->sql) {
763
-                        $tmp[] = $v->sql . ' ';
763
+                        $tmp[] = $v->sql.' ';
764 764
                         $par = array_merge($par, $v->par ?? []);
765 765
                     }
766
-                    $sql .= implode(' AND ', $tmp) . ' ';
766
+                    $sql .= implode(' AND ', $tmp).' ';
767 767
                 }
768 768
             }
769 769
         }
@@ -772,12 +772,12 @@  discard block
 block discarded – undo
772 772
             if ($v->many) {
773 773
                 $jMany = true;
774 774
             }
775
-            $sql .= ($v->many ? 'LEFT ' : '' ) . 'JOIN '.$v->table->getFullName().' '.$k.' ON ';
775
+            $sql .= ($v->many ? 'LEFT ' : '').'JOIN '.$v->table->getFullName().' '.$k.' ON ';
776 776
             $tmp = [];
777 777
             foreach ($v->keymap as $kk => $vv) {
778 778
                 $tmp[] = $kk.' = '.$vv;
779 779
             }
780
-            $sql .= implode(' AND ', $tmp) . ' ';
780
+            $sql .= implode(' AND ', $tmp).' ';
781 781
         }
782 782
         if (!$jMany && !count($used_relations)) {
783 783
             $sql = str_replace('COUNT(DISTINCT ', 'COUNT(', $sql);
@@ -786,20 +786,20 @@  discard block
 block discarded – undo
786 786
             $sql .= 'WHERE ';
787 787
             $tmp = [];
788 788
             foreach ($w as $v) {
789
-                $tmp[] = '(' . $v[0] . ')';
789
+                $tmp[] = '('.$v[0].')';
790 790
                 $par = array_merge($par, $v[1]);
791 791
             }
792 792
             $sql .= implode(' AND ', $tmp).' ';
793 793
         }
794 794
         if (count($g)) {
795
-            $sql .= 'GROUP BY ' . $g[0] . ' ';
795
+            $sql .= 'GROUP BY '.$g[0].' ';
796 796
             $par = array_merge($par, $g[1]);
797 797
         }
798 798
         if (count($h)) {
799 799
             $sql .= 'HAVING ';
800 800
             $tmp = [];
801 801
             foreach ($h as $v) {
802
-                $tmp[] = '(' . $v[0] . ')';
802
+                $tmp[] = '('.$v[0].')';
803 803
                 $par = array_merge($par, $v[1]);
804 804
             }
805 805
             $sql .= implode(' AND ', $tmp).' ';
@@ -827,14 +827,14 @@  discard block
 block discarded – undo
827 827
                     } elseif (isset($this->joins[$table])) {
828 828
                         $cols = $this->joins[$table]->table->getColumns();
829 829
                     } else {
830
-                        throw new DBException('Invalid foreign table name: ' . $table);
830
+                        throw new DBException('Invalid foreign table name: '.$table);
831 831
                     }
832 832
                 } else {
833 833
                     array_pop($temp);
834 834
                     $this->with(implode('.', $temp));
835 835
                     $table = array_reduce(
836 836
                         $temp,
837
-                        function ($carry, $item) use (&$table) {
837
+                        function($carry, $item) use (&$table) {
838 838
                             return $table->getRelation($item)->table;
839 839
                         }
840 840
                     );
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
                 }
844 844
                 unset($fields[$k]);
845 845
                 foreach ($cols as $col) {
846
-                    $fields[] = $table . '.' . $col;
846
+                    $fields[] = $table.'.'.$col;
847 847
                 }
848 848
             }
849 849
         }
@@ -878,9 +878,9 @@  discard block
 block discarded – undo
878 878
         }
879 879
         $aliases = [];
880 880
         $aliases_ext = [];
881
-        $getAlias = function ($name) use (&$aliases, &$aliases_ext) {
881
+        $getAlias = function($name) use (&$aliases, &$aliases_ext) {
882 882
             // to bypass use: return $name;
883
-            $aliases[$name] = $aliases[$name] ?? 'alias' . static::SEP . count($aliases);
883
+            $aliases[$name] = $aliases[$name] ?? 'alias'.static::SEP.count($aliases);
884 884
             if (isset($aliases_ext[$name])) {
885 885
                 unset($aliases_ext[$name]);
886 886
             }
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
         $h = $this->having;
906 906
         $o = $this->order;
907 907
         $g = $this->group;
908
-        $j = array_map(function ($v) {
908
+        $j = array_map(function($v) {
909 909
             return clone $v;
910 910
         }, $this->joins);
911 911
 
@@ -919,32 +919,32 @@  discard block
 block discarded – undo
919 919
                 continue;
920 920
             }
921 921
             foreach ($f as $kk => $field) {
922
-                if (strpos($field, $k . '.') === 0) {
923
-                    $f[$kk] = str_replace($k . '.', $getAlias($k) . '.', $field);
922
+                if (strpos($field, $k.'.') === 0) {
923
+                    $f[$kk] = str_replace($k.'.', $getAlias($k).'.', $field);
924 924
                 }
925 925
             }
926 926
             foreach ($w as $kk => $v) {
927
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
928
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $v[0]);
927
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
928
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $v[0]);
929 929
                 }
930 930
             }
931 931
             foreach ($h as $kk => $v) {
932
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
933
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $v[0]);
932
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
933
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $v[0]);
934 934
                 }
935 935
             }
936
-            if (isset($o[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $o[0])) {
937
-                $o[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $o[0]);
936
+            if (isset($o[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $o[0])) {
937
+                $o[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $o[0]);
938 938
             }
939
-            if (isset($g[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $g[0])) {
940
-                $g[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $g[0]);
939
+            if (isset($g[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $g[0])) {
940
+                $g[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $g[0]);
941 941
             }
942 942
             foreach ($j as $kk => $v) {
943 943
                 foreach ($v->keymap as $kkk => $vv) {
944
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv)) {
944
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vv)) {
945 945
                         $j[$kk]->keymap[$kkk] = preg_replace(
946
-                            '(\b'.preg_quote($k . '.'). ')i',
947
-                            $getAlias($k) . '.',
946
+                            '(\b'.preg_quote($k.'.').')i',
947
+                            $getAlias($k).'.',
948 948
                             $vv
949 949
                         );
950 950
                     }
@@ -953,38 +953,38 @@  discard block
 block discarded – undo
953 953
         }
954 954
         foreach ($this->definition->getRelations() as $k => $relation) {
955 955
             foreach ($f as $kk => $field) {
956
-                if (strpos($field, $k . '.') === 0) {
957
-                    $relations[$k] = [ $relation, $table ];
958
-                    $f[$kk] = str_replace($k . '.', $getAlias($k) . '.', $field);
956
+                if (strpos($field, $k.'.') === 0) {
957
+                    $relations[$k] = [$relation, $table];
958
+                    $f[$kk] = str_replace($k.'.', $getAlias($k).'.', $field);
959 959
                 }
960 960
             }
961 961
             foreach ($w as $kk => $v) {
962
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
963
-                    $relations[$k] = [ $relation, $table ];
964
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $v[0]);
962
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
963
+                    $relations[$k] = [$relation, $table];
964
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $v[0]);
965 965
                 }
966 966
             }
967 967
             foreach ($h as $kk => $v) {
968
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
969
-                    $relations[$k] = [ $relation, $table ];
970
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $v[0]);
968
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
969
+                    $relations[$k] = [$relation, $table];
970
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $v[0]);
971 971
                 }
972 972
             }
973
-            if (isset($o[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $o[0])) {
974
-                $relations[$k] = [ $relation, $table ];
975
-                $o[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $o[0]);
973
+            if (isset($o[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $o[0])) {
974
+                $relations[$k] = [$relation, $table];
975
+                $o[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $o[0]);
976 976
             }
977
-            if (isset($g[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $g[0])) {
978
-                $relations[$k] = [ $relation, $table ];
979
-                $g[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $g[0]);
977
+            if (isset($g[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $g[0])) {
978
+                $relations[$k] = [$relation, $table];
979
+                $g[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $g[0]);
980 980
             }
981 981
             foreach ($j as $kk => $v) {
982 982
                 foreach ($v->keymap as $kkk => $vv) {
983
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv)) {
984
-                        $relations[$k] = [ $relation, $table ];
983
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vv)) {
984
+                        $relations[$k] = [$relation, $table];
985 985
                         $j[$kk]->keymap[$kkk] = preg_replace(
986
-                            '(\b'.preg_quote($k . '.'). ')i',
987
-                            $getAlias($k) . '.',
986
+                            '(\b'.preg_quote($k.'.').')i',
987
+                            $getAlias($k).'.',
988 988
                             $vv
989 989
                         );
990 990
                     }
@@ -993,32 +993,32 @@  discard block
 block discarded – undo
993 993
         }
994 994
         foreach ($aliases_ext as $k => $alias) {
995 995
             foreach ($f as $kk => $field) {
996
-                if (strpos($field, $k . '.') === 0) {
997
-                    $f[$kk] = str_replace($k . '.', $alias . '.', $field);
996
+                if (strpos($field, $k.'.') === 0) {
997
+                    $f[$kk] = str_replace($k.'.', $alias.'.', $field);
998 998
                 }
999 999
             }
1000 1000
             foreach ($w as $kk => $v) {
1001
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
1002
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $v[0]);
1001
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
1002
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $v[0]);
1003 1003
                 }
1004 1004
             }
1005 1005
             foreach ($h as $kk => $v) {
1006
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
1007
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $v[0]);
1006
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
1007
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $v[0]);
1008 1008
                 }
1009 1009
             }
1010
-            if (isset($o[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $o[0])) {
1011
-                $o[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $o[0]);
1010
+            if (isset($o[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $o[0])) {
1011
+                $o[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $o[0]);
1012 1012
             }
1013
-            if (isset($g[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $g[0])) {
1014
-                $g[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $g[0]);
1013
+            if (isset($g[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $g[0])) {
1014
+                $g[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $g[0]);
1015 1015
             }
1016 1016
             foreach ($j as $kk => $v) {
1017 1017
                 foreach ($v->keymap as $kkk => $vv) {
1018
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv)) {
1018
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vv)) {
1019 1019
                         $j[$kk]->keymap[$kkk] = preg_replace(
1020
-                            '(\b'.preg_quote($k . '.'). ')i',
1021
-                            $alias . '.',
1020
+                            '(\b'.preg_quote($k.'.').')i',
1021
+                            $alias.'.',
1022 1022
                             $vv
1023 1023
                         );
1024 1024
                     }
@@ -1027,12 +1027,12 @@  discard block
 block discarded – undo
1027 1027
         }
1028 1028
         $select = [];
1029 1029
         foreach ($f as $k => $field) {
1030
-            $select[] = $field . (!is_numeric($k) ? ' ' . $k : '');
1030
+            $select[] = $field.(!is_numeric($k) ? ' '.$k : '');
1031 1031
         }
1032 1032
         foreach ($this->withr as $name => $relation) {
1033 1033
             if ($relation[2]) {
1034 1034
                 foreach ($relation[0]->table->getColumns() as $column) {
1035
-                    $select[] = $getAlias($name) . '.' . $column . ' ' . $getAlias($name . static::SEP . $column);
1035
+                    $select[] = $getAlias($name).'.'.$column.' '.$getAlias($name.static::SEP.$column);
1036 1036
                 }
1037 1037
             }
1038 1038
         }
@@ -1053,13 +1053,13 @@  discard block
 block discarded – undo
1053 1053
                 foreach ($v->keymap as $kk => $vv) {
1054 1054
                     $tmp[] = $table.'.'.$kk.' = '.$alias.'.'.$vv.' ';
1055 1055
                 }
1056
-                $sql .= implode(' AND ', $tmp) . ' ';
1056
+                $sql .= implode(' AND ', $tmp).' ';
1057 1057
                 $sql .= 'LEFT JOIN '.$v->table->getFullName().' '.$getAlias($relation).' ON ';
1058 1058
                 $tmp = [];
1059 1059
                 foreach ($v->pivot_keymap as $kk => $vv) {
1060 1060
                     $tmp[] = $getAlias($relation).'.'.$vv.' = '.$alias.'.'.$kk.' ';
1061 1061
                 }
1062
-                $sql .= implode(' AND ', $tmp) . ' ';
1062
+                $sql .= implode(' AND ', $tmp).' ';
1063 1063
             } else {
1064 1064
                 $alias = $getAlias($relation);
1065 1065
 
@@ -1069,22 +1069,22 @@  discard block
 block discarded – undo
1069 1069
                     $tmp[] = $table.'.'.$kk.' = '.$alias.'.'.$vv.' ';
1070 1070
                 }
1071 1071
                 if ($v->sql) {
1072
-                    $tmp[] = $v->sql . ' ';
1072
+                    $tmp[] = $v->sql.' ';
1073 1073
                     $par = array_merge($par, $v->par ?? []);
1074 1074
                 }
1075
-                $sql .= implode(' AND ', $tmp) . ' ';
1075
+                $sql .= implode(' AND ', $tmp).' ';
1076 1076
             }
1077 1077
         }
1078 1078
         foreach ($j as $k => $v) {
1079 1079
             if ($v->many) {
1080 1080
                 $many = true;
1081 1081
             }
1082
-            $sql .= ($v->many ? 'LEFT ' : '' ) . 'JOIN '.$v->table->getFullName().' '.$k.' ON ';
1082
+            $sql .= ($v->many ? 'LEFT ' : '').'JOIN '.$v->table->getFullName().' '.$k.' ON ';
1083 1083
             $tmp = [];
1084 1084
             foreach ($v->keymap as $kk => $vv) {
1085 1085
                 $tmp[] = $kk.' = '.$vv;
1086 1086
             }
1087
-            $sql .= implode(' AND ', $tmp) . ' ';
1087
+            $sql .= implode(' AND ', $tmp).' ';
1088 1088
         }
1089 1089
         if ($many && count($porder) && $this->li_mt) {
1090 1090
             $ids = $this->ids();
@@ -1092,9 +1092,9 @@  discard block
 block discarded – undo
1092 1092
                 if (count($porder) > 1) {
1093 1093
                     $pkw = [];
1094 1094
                     foreach ($porder as $name) {
1095
-                        $pkw[] = $name . ' = ?';
1095
+                        $pkw[] = $name.' = ?';
1096 1096
                     }
1097
-                    $pkw = '(' . implode(' AND ', $pkw) . ')';
1097
+                    $pkw = '('.implode(' AND ', $pkw).')';
1098 1098
                     $pkp = [];
1099 1099
                     foreach ($ids as $id) {
1100 1100
                         foreach ($id as $p) {
@@ -1106,60 +1106,60 @@  discard block
 block discarded – undo
1106 1106
                         $pkp
1107 1107
                     ];
1108 1108
                 } else {
1109
-                    $w[] = [ $porder[0] . ' IN ('.implode(',', array_fill(0, count($ids), '?')).')', $ids ];
1109
+                    $w[] = [$porder[0].' IN ('.implode(',', array_fill(0, count($ids), '?')).')', $ids];
1110 1110
                 }
1111 1111
             } else {
1112
-                $w[] = [ '1=0', [] ];
1112
+                $w[] = ['1=0', []];
1113 1113
             }
1114 1114
         }
1115 1115
         if (count($w)) {
1116 1116
             $sql .= 'WHERE ';
1117 1117
             $tmp = [];
1118 1118
             foreach ($w as $v) {
1119
-                $tmp[] = '(' . $v[0] . ')';
1119
+                $tmp[] = '('.$v[0].')';
1120 1120
                 $par = array_merge($par, $v[1]);
1121 1121
             }
1122 1122
             $sql .= implode(' AND ', $tmp).' ';
1123 1123
         }
1124 1124
         if (count($g)) {
1125
-            $sql .= 'GROUP BY ' . $g[0] . ' ';
1125
+            $sql .= 'GROUP BY '.$g[0].' ';
1126 1126
             $par = array_merge($par, $g[1]);
1127 1127
         }
1128 1128
         if (count($h)) {
1129 1129
             $sql .= 'HAVING ';
1130 1130
             $tmp = [];
1131 1131
             foreach ($h as $v) {
1132
-                $tmp[] = '(' . $v[0] . ')';
1132
+                $tmp[] = '('.$v[0].')';
1133 1133
                 $par = array_merge($par, $v[1]);
1134 1134
             }
1135 1135
             $sql .= implode(' AND ', $tmp).' ';
1136 1136
         }
1137 1137
         $ordered = false;
1138 1138
         if (count($o)) {
1139
-            $sql .= 'ORDER BY ' . $o[0] . ' ';
1139
+            $sql .= 'ORDER BY '.$o[0].' ';
1140 1140
             $par = array_merge($par, $o[1]);
1141 1141
             $ordered = true;
1142 1142
         }
1143 1143
         if (!count($g) && count($porder)) {
1144 1144
             $pdir = (count($o) && strpos($o[0], 'DESC') !== false) ? 'DESC' : 'ASC';
1145
-            $porder = array_map(function ($v) use ($pdir) {
1146
-                return $v . ' ' . $pdir;
1145
+            $porder = array_map(function($v) use ($pdir) {
1146
+                return $v.' '.$pdir;
1147 1147
             }, $porder);
1148
-            $sql .= ($ordered ? ', ' : 'ORDER BY ') . implode(', ', $porder) . ' ';
1148
+            $sql .= ($ordered ? ', ' : 'ORDER BY ').implode(', ', $porder).' ';
1149 1149
             $ordered = true;
1150 1150
         }
1151 1151
         foreach ($this->withr as $k => $v) {
1152 1152
             if (isset($v[3])) {
1153
-                $sql .= ($ordered ? ', ' : 'ORDER BY ') . $getAlias($k) . '.' . $v[3] . ' ' . ($v[4] ? 'DESC' : 'ASC');
1153
+                $sql .= ($ordered ? ', ' : 'ORDER BY ').$getAlias($k).'.'.$v[3].' '.($v[4] ? 'DESC' : 'ASC');
1154 1154
                 $ordered = true;
1155 1155
             }
1156 1156
         }
1157 1157
         if ((!$many || !$this->li_mt || !count($porder)) && $this->li_of[0]) {
1158 1158
             if ($this->db->driverName() === 'oracle') {
1159
-                if ((int)$this->db->driverOption('version', 0) >= 12) {
1160
-                    $sql .= 'OFFSET ' . $this->li_of[1] . ' ROWS FETCH NEXT ' . $this->li_of[0] . ' ROWS ONLY';
1159
+                if ((int) $this->db->driverOption('version', 0) >= 12) {
1160
+                    $sql .= 'OFFSET '.$this->li_of[1].' ROWS FETCH NEXT '.$this->li_of[0].' ROWS ONLY';
1161 1161
                 } else {
1162
-                    $f = array_map(function ($v) {
1162
+                    $f = array_map(function($v) {
1163 1163
                         $v = explode(' ', trim($v), 2);
1164 1164
                         if (count($v) === 2) {
1165 1165
                             return $v[1];
@@ -1167,16 +1167,16 @@  discard block
 block discarded – undo
1167 1167
                         $v = explode('.', $v[0], 2);
1168 1168
                         return count($v) === 2 ? $v[1] : $v[0];
1169 1169
                     }, $select);
1170
-                    $sql = "SELECT " . implode(', ', $f) . "
1170
+                    $sql = "SELECT ".implode(', ', $f)."
1171 1171
                             FROM (
1172 1172
                                 SELECT tbl__.*, rownum rnum__ FROM (
1173
-                                    " . $sql . "
1173
+                                    " . $sql."
1174 1174
                                 ) tbl__
1175
-                                WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1]) . "
1175
+                                WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1])."
1176 1176
                             ) WHERE rnum__ > " . $this->li_of[1];
1177 1177
                 }
1178 1178
             } else {
1179
-                $sql .= 'LIMIT ' . $this->li_of[0] . ' OFFSET ' . $this->li_of[1];
1179
+                $sql .= 'LIMIT '.$this->li_of[0].' OFFSET '.$this->li_of[1];
1180 1180
             }
1181 1181
         }
1182 1182
         return $this->qiterator = new TableQueryIterator(
@@ -1226,12 +1226,12 @@  discard block
 block discarded – undo
1226 1226
                 $ret[$k] = str_repeat(' ', 255);
1227 1227
                 $par[] = &$ret[$k];
1228 1228
             }
1229
-            $sql .= ' RETURNING ' . implode(',', $primary) .
1230
-                ' INTO ' . implode(',', array_fill(0, count($primary), '?'));
1229
+            $sql .= ' RETURNING '.implode(',', $primary).
1230
+                ' INTO '.implode(',', array_fill(0, count($primary), '?'));
1231 1231
             $this->db->query($sql, $par);
1232 1232
             return $ret;
1233 1233
         } elseif ($this->db->driverName() === 'postgre') {
1234
-            $sql .= ' RETURNING ' . implode(',', $primary);
1234
+            $sql .= ' RETURNING '.implode(',', $primary);
1235 1235
             return $this->db->one($sql, $par, false);
1236 1236
         } else {
1237 1237
             $ret = [];
@@ -1262,9 +1262,9 @@  discard block
 block discarded – undo
1262 1262
         }
1263 1263
         $sql = 'UPDATE '.$table.' SET ';
1264 1264
         $par = [];
1265
-        $sql .= implode(', ', array_map(function ($v) {
1266
-            return $v . ' = ?';
1267
-        }, array_keys($update))) . ' ';
1265
+        $sql .= implode(', ', array_map(function($v) {
1266
+            return $v.' = ?';
1267
+        }, array_keys($update))).' ';
1268 1268
         $par = array_merge($par, array_values($update));
1269 1269
         if (count($this->where)) {
1270 1270
             $sql .= 'WHERE ';
@@ -1273,7 +1273,7 @@  discard block
 block discarded – undo
1273 1273
                 $tmp[] = $v[0];
1274 1274
                 $par = array_merge($par, $v[1]);
1275 1275
             }
1276
-            $sql .= implode(' AND ', $tmp) . ' ';
1276
+            $sql .= implode(' AND ', $tmp).' ';
1277 1277
         }
1278 1278
         if (count($this->order)) {
1279 1279
             $sql .= $this->order[0];
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
                 $tmp[] = $v[0];
1298 1298
                 $par = array_merge($par, $v[1]);
1299 1299
             }
1300
-            $sql .= implode(' AND ', $tmp) . ' ';
1300
+            $sql .= implode(' AND ', $tmp).' ';
1301 1301
         }
1302 1302
         if (count($this->order)) {
1303 1303
             $sql .= $this->order[0];
@@ -1328,15 +1328,15 @@  discard block
 block discarded – undo
1328 1328
             try {
1329 1329
                 $name = array_reduce(
1330 1330
                     $parts,
1331
-                    function ($carry, $item) use (&$table, $select) {
1331
+                    function($carry, $item) use (&$table, $select) {
1332 1332
                         if (!$table->hasRelation($item)) {
1333
-                            throw new DBException('Invalid relation name: '.$table->getName().' -> ' . $item);
1333
+                            throw new DBException('Invalid relation name: '.$table->getName().' -> '.$item);
1334 1334
                         }
1335 1335
                         $relation = $table->getRelation($item);
1336 1336
                         if (!$relation) {
1337
-                            throw new DBException('Invalid relation name: '.$table->getName().' -> ' . $item);
1337
+                            throw new DBException('Invalid relation name: '.$table->getName().' -> '.$item);
1338 1338
                         }
1339
-                        $name = $carry ? $carry . static::SEP . $item : $item;
1339
+                        $name = $carry ? $carry.static::SEP.$item : $item;
1340 1340
                         $this->withr[$name] = [
1341 1341
                             $relation,
1342 1342
                             $carry ?? $table->getName(),
@@ -1405,9 +1405,9 @@  discard block
 block discarded – undo
1405 1405
 
1406 1406
         $aliases = [];
1407 1407
         $aliases_ext = [];
1408
-        $getAlias = function ($name) use (&$aliases, &$aliases_ext) {
1408
+        $getAlias = function($name) use (&$aliases, &$aliases_ext) {
1409 1409
             // to bypass use: return $name;
1410
-            $aliases[$name] = $aliases[$name] ?? 'alias' . static::SEP . count($aliases);
1410
+            $aliases[$name] = $aliases[$name] ?? 'alias'.static::SEP.count($aliases);
1411 1411
             if (isset($aliases_ext[$name])) {
1412 1412
                 unset($aliases_ext[$name]);
1413 1413
             }
@@ -1427,7 +1427,7 @@  discard block
 block discarded – undo
1427 1427
         $w = $this->where;
1428 1428
         $h = $this->having;
1429 1429
         $o = $this->order;
1430
-        $j = array_map(function ($v) {
1430
+        $j = array_map(function($v) {
1431 1431
             return clone $v;
1432 1432
         }, $this->joins);
1433 1433
 
@@ -1436,24 +1436,24 @@  discard block
 block discarded – undo
1436 1436
                 continue;
1437 1437
             }
1438 1438
             foreach ($w as $kk => $v) {
1439
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
1440
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $v[0]);
1439
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
1440
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $v[0]);
1441 1441
                 }
1442 1442
             }
1443 1443
             foreach ($h as $kk => $v) {
1444
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
1445
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $v[0]);
1444
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
1445
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $v[0]);
1446 1446
                 }
1447 1447
             }
1448
-            if (isset($o[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $o[0])) {
1449
-                $o[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $o[0]);
1448
+            if (isset($o[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $o[0])) {
1449
+                $o[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $o[0]);
1450 1450
             }
1451 1451
             foreach ($j as $kk => $v) {
1452 1452
                 foreach ($v->keymap as $kkk => $vv) {
1453
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv)) {
1453
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vv)) {
1454 1454
                         $j[$kk]->keymap[$kkk] = preg_replace(
1455
-                            '(\b'.preg_quote($k . '.'). ')i',
1456
-                            $getAlias($k) . '.',
1455
+                            '(\b'.preg_quote($k.'.').')i',
1456
+                            $getAlias($k).'.',
1457 1457
                             $vv
1458 1458
                         );
1459 1459
                     }
@@ -1462,52 +1462,52 @@  discard block
 block discarded – undo
1462 1462
         }
1463 1463
         foreach ($this->definition->getRelations() as $k => $v) {
1464 1464
             foreach ($w as $kk => $vv) {
1465
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv[0])) {
1466
-                    $relations[$k] = [ $v, $table ];
1467
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $vv[0]);
1465
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $vv[0])) {
1466
+                    $relations[$k] = [$v, $table];
1467
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $vv[0]);
1468 1468
                 }
1469 1469
             }
1470
-            if (isset($o[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $o[0])) {
1471
-                $relations[$k] = [ $v, $table ];
1472
-                $o[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $o[0]);
1473
-                $o[2] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $o[2]);
1470
+            if (isset($o[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $o[0])) {
1471
+                $relations[$k] = [$v, $table];
1472
+                $o[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $o[0]);
1473
+                $o[2] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $o[2]);
1474 1474
             }
1475 1475
             foreach ($h as $kk => $vv) {
1476
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv[0])) {
1477
-                    $relations[$k] = [ $v, $table ];
1478
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $vv[0]);
1476
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $vv[0])) {
1477
+                    $relations[$k] = [$v, $table];
1478
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $vv[0]);
1479 1479
                 }
1480 1480
             }
1481 1481
             foreach ($j as $kk => $vv) {
1482 1482
                 foreach ($vv->keymap as $kkk => $vvv) {
1483
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vvv)) {
1484
-                        $relations[$k] = [ $v, $table ];
1483
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vvv)) {
1484
+                        $relations[$k] = [$v, $table];
1485 1485
                         $j[$kk]->keymap[$kkk] =
1486
-                            preg_replace('(\b'.preg_quote($k . '.'). ')i', $getAlias($k) . '.', $vvv);
1486
+                            preg_replace('(\b'.preg_quote($k.'.').')i', $getAlias($k).'.', $vvv);
1487 1487
                     }
1488 1488
                 }
1489 1489
             }
1490 1490
         }
1491 1491
         foreach ($aliases_ext as $k => $alias) {
1492 1492
             foreach ($w as $kk => $v) {
1493
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
1494
-                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $v[0]);
1493
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
1494
+                    $w[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $v[0]);
1495 1495
                 }
1496 1496
             }
1497 1497
             foreach ($h as $kk => $v) {
1498
-                if (preg_match('(\b'.preg_quote($k . '.'). ')i', $v[0])) {
1499
-                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $v[0]);
1498
+                if (preg_match('(\b'.preg_quote($k.'.').')i', $v[0])) {
1499
+                    $h[$kk][0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $v[0]);
1500 1500
                 }
1501 1501
             }
1502
-            if (isset($o[0]) && preg_match('(\b'.preg_quote($k . '.'). ')i', $o[0])) {
1503
-                $o[0] = preg_replace('(\b'.preg_quote($k . '.'). ')i', $alias . '.', $o[0]);
1502
+            if (isset($o[0]) && preg_match('(\b'.preg_quote($k.'.').')i', $o[0])) {
1503
+                $o[0] = preg_replace('(\b'.preg_quote($k.'.').')i', $alias.'.', $o[0]);
1504 1504
             }
1505 1505
             foreach ($j as $kk => $v) {
1506 1506
                 foreach ($v->keymap as $kkk => $vv) {
1507
-                    if (preg_match('(\b'.preg_quote($k . '.'). ')i', $vv)) {
1507
+                    if (preg_match('(\b'.preg_quote($k.'.').')i', $vv)) {
1508 1508
                         $j[$kk]->keymap[$kkk] = preg_replace(
1509
-                            '(\b'.preg_quote($k . '.'). ')i',
1510
-                            $alias . '.',
1509
+                            '(\b'.preg_quote($k.'.').')i',
1510
+                            $alias.'.',
1511 1511
                             $vv
1512 1512
                         );
1513 1513
                     }
@@ -1515,29 +1515,29 @@  discard block
 block discarded – undo
1515 1515
             }
1516 1516
         }
1517 1517
 
1518
-        $key = array_map(function ($v) use ($table) {
1519
-            return $table . '.' . $v;
1518
+        $key = array_map(function($v) use ($table) {
1519
+            return $table.'.'.$v;
1520 1520
         }, $this->pkey);
1521 1521
         $own = false;
1522 1522
         $dir = 'ASC';
1523 1523
         if (count($o)) {
1524 1524
             $dir = strpos($o[0], ' DESC') ? 'DESC' : 'ASC';
1525
-            $own = strpos($o[2], $table . '.') === 0;
1525
+            $own = strpos($o[2], $table.'.') === 0;
1526 1526
         }
1527 1527
 
1528 1528
         $dst = $key;
1529 1529
         if (count($o)) {
1530 1530
             if ($own) {
1531 1531
                 // if using own table - do not use max/min in order - that will prevent index usage
1532
-                $dst[] = $o[2] . ' orderbyfix___';
1532
+                $dst[] = $o[2].' orderbyfix___';
1533 1533
             } else {
1534
-                $dst[] = 'MAX(' . $o[2] . ') orderbyfix___';
1534
+                $dst[] = 'MAX('.$o[2].') orderbyfix___';
1535 1535
             }
1536 1536
         }
1537 1537
         $dst = array_unique($dst);
1538 1538
 
1539 1539
         $par = [];
1540
-        $sql  = 'SELECT DISTINCT '.implode(', ', $dst).' FROM '.$this->definition->getFullName().' ';
1540
+        $sql = 'SELECT DISTINCT '.implode(', ', $dst).' FROM '.$this->definition->getFullName().' ';
1541 1541
         foreach ($relations as $k => $v) {
1542 1542
             $table = $v[1] !== $this->definition->getName() ? $getAlias($v[1]) : $v[1];
1543 1543
             $v = $v[0];
@@ -1548,13 +1548,13 @@  discard block
 block discarded – undo
1548 1548
                 foreach ($v->keymap as $kk => $vv) {
1549 1549
                     $tmp[] = $table.'.'.$kk.' = '.$alias.'.'.$vv.' ';
1550 1550
                 }
1551
-                $sql .= implode(' AND ', $tmp) . ' ';
1551
+                $sql .= implode(' AND ', $tmp).' ';
1552 1552
                 $sql .= 'LEFT JOIN '.$v->table->getFullName().' '.$getAlias($k).' ON ';
1553 1553
                 $tmp = [];
1554 1554
                 foreach ($v->pivot_keymap as $kk => $vv) {
1555 1555
                     $tmp[] = $getAlias($k).'.'.$vv.' = '.$alias.'.'.$kk.' ';
1556 1556
                 }
1557
-                $sql .= implode(' AND ', $tmp) . ' ';
1557
+                $sql .= implode(' AND ', $tmp).' ';
1558 1558
             } else {
1559 1559
                 $alias = $getAlias($k);
1560 1560
                 $sql .= 'LEFT JOIN '.$v->table->getFullName().' '.$alias.' ON ';
@@ -1563,37 +1563,37 @@  discard block
 block discarded – undo
1563 1563
                     $tmp[] = $table.'.'.$kk.' = '.$alias.'.'.$vv.' ';
1564 1564
                 }
1565 1565
                 if ($v->sql) {
1566
-                    $tmp[] = $v->sql . ' ';
1566
+                    $tmp[] = $v->sql.' ';
1567 1567
                     $par = array_merge($par, $v->par ?? []);
1568 1568
                 }
1569
-                $sql .= implode(' AND ', $tmp) . ' ';
1569
+                $sql .= implode(' AND ', $tmp).' ';
1570 1570
             }
1571 1571
         }
1572 1572
         foreach ($j as $k => $v) {
1573
-            $sql .= ($v->many ? 'LEFT ' : '' ) . 'JOIN '.$v->table->getFullName().' '.$k.' ON ';
1573
+            $sql .= ($v->many ? 'LEFT ' : '').'JOIN '.$v->table->getFullName().' '.$k.' ON ';
1574 1574
             $tmp = [];
1575 1575
             foreach ($v->keymap as $kk => $vv) {
1576 1576
                 $tmp[] = $kk.' = '.$vv;
1577 1577
             }
1578
-            $sql .= implode(' AND ', $tmp) . ' ';
1578
+            $sql .= implode(' AND ', $tmp).' ';
1579 1579
         }
1580 1580
         if (count($w)) {
1581 1581
             $sql .= 'WHERE ';
1582 1582
             $tmp = [];
1583 1583
             foreach ($w as $v) {
1584
-                $tmp[] = '(' . $v[0] . ')';
1584
+                $tmp[] = '('.$v[0].')';
1585 1585
                 $par = array_merge($par, $v[1]);
1586 1586
             }
1587 1587
             $sql .= implode(' AND ', $tmp).' ';
1588 1588
         }
1589 1589
         if (!$own) {
1590
-            $sql .= 'GROUP BY ' . implode(', ', $key) . ' ';
1590
+            $sql .= 'GROUP BY '.implode(', ', $key).' ';
1591 1591
         }
1592 1592
         if (count($h)) {
1593 1593
             $sql .= 'HAVING ';
1594 1594
             $tmp = [];
1595 1595
             foreach ($h as $v) {
1596
-                $tmp[] = '(' . $v[0] . ')';
1596
+                $tmp[] = '('.$v[0].')';
1597 1597
                 $par = array_merge($par, $v[1]);
1598 1598
             }
1599 1599
             $sql .= implode(' AND ', $tmp).' ';
@@ -1601,38 +1601,38 @@  discard block
 block discarded – undo
1601 1601
         if (count($o)) {
1602 1602
             $sql .= 'ORDER BY ';
1603 1603
             if ($own) {
1604
-                $sql .= $o[2] . ' ' . $dir;
1604
+                $sql .= $o[2].' '.$dir;
1605 1605
             } else {
1606
-                $sql .= 'MAX('.$o[2].') ' . $dir;
1606
+                $sql .= 'MAX('.$o[2].') '.$dir;
1607 1607
             }
1608 1608
         }
1609 1609
         $porder = [];
1610 1610
         $pdir = (count($o) && strpos($o[0], 'DESC') !== false) ? 'DESC' : 'ASC';
1611 1611
         foreach ($this->definition->getPrimaryKey() as $field) {
1612
-            $porder[] = $this->getColumn($field)['name'] . ' ' . $pdir;
1612
+            $porder[] = $this->getColumn($field)['name'].' '.$pdir;
1613 1613
         }
1614 1614
         if (count($porder)) {
1615
-            $sql .= (count($o) ? ', ' : 'ORDER BY ') . implode(', ', $porder) . ' ';
1615
+            $sql .= (count($o) ? ', ' : 'ORDER BY ').implode(', ', $porder).' ';
1616 1616
         }
1617 1617
 
1618 1618
         if ($this->li_of[0]) {
1619 1619
             if ($this->db->driverName() === 'oracle') {
1620
-                if ((int)$this->db->driverOption('version', 12) >= 12) {
1621
-                    $sql .= 'OFFSET ' . $this->li_of[1] . ' ROWS FETCH NEXT ' . $this->li_of[0] . ' ROWS ONLY';
1620
+                if ((int) $this->db->driverOption('version', 12) >= 12) {
1621
+                    $sql .= 'OFFSET '.$this->li_of[1].' ROWS FETCH NEXT '.$this->li_of[0].' ROWS ONLY';
1622 1622
                 } else {
1623
-                    $sql = "SELECT " . implode(', ', $dst) . "
1623
+                    $sql = "SELECT ".implode(', ', $dst)."
1624 1624
                             FROM (
1625 1625
                                 SELECT tbl__.*, rownum rnum__ FROM (
1626
-                                    " . $sql . "
1626
+                                    " . $sql."
1627 1627
                                 ) tbl__
1628
-                                WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1]) . "
1628
+                                WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1])."
1629 1629
                             ) WHERE rnum__ > " . $this->li_of[1];
1630 1630
                 }
1631 1631
             } else {
1632
-                $sql .= 'LIMIT ' . $this->li_of[0] . ' OFFSET ' . $this->li_of[1];
1632
+                $sql .= 'LIMIT '.$this->li_of[0].' OFFSET '.$this->li_of[1];
1633 1633
             }
1634 1634
         }
1635
-        return array_map(function ($v) {
1635
+        return array_map(function($v) {
1636 1636
             if (array_key_exists('orderbyfix___', $v)) {
1637 1637
                 unset($v['orderbyfix___']);
1638 1638
             }
Please login to merge, or discard this patch.