Completed
Push — master ( e57116...d2067a )
by Ivan
13:38
created
src/driver/postgre/Schema.php 1 patch
Spacing   +44 added lines, -44 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
             // relations where the current table references another table
175 175
             // assuming current table is linked to "one" record in the referenced table
176 176
             // resulting in a "belongsTo" relationship
177 177
             $relations = [];
178
-            foreach ($relationsT[$schema . '.' . $table] ?? [] as $relation) {
179
-                $relations[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'] . '.' .
178
+            foreach ($relationsT[$schema.'.'.$table] ?? [] as $relation) {
179
+                $relations[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'].'.'.
180 180
                     $relation['referenced_table_name'];
181 181
                 $relations[$relation['constraint_name']]['keymap'][$relation['column_name']] =
182 182
                     $relation['referenced_column_name'];
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
                     $relname = $temp[1];
189 189
                 }
190 190
                 if ($duplicated[$data['table']]) {
191
-                    $relname = array_keys($data['keymap'])[0] . '_' . $relname;
191
+                    $relname = array_keys($data['keymap'])[0].'_'.$relname;
192 192
                 }
193 193
                 $orig = $relname;
194 194
                 $cntr = 1;
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
                     $definition->getName() == $relname ||
197 197
                     $definition->getColumn($relname)
198 198
                 ) {
199
-                    $relname = $orig . '_' . (++ $cntr);
199
+                    $relname = $orig.'_'.(++$cntr);
200 200
                 }
201 201
                 $definition->addRelation(
202 202
                     new TableRelation(
@@ -212,13 +212,13 @@  discard block
 block discarded – undo
212 212
             // assuming current table is on the "one" end having "many" records in the referencing table
213 213
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
214 214
             $relations = [];
215
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) {
216
-                $relations[$relation['constraint_name']]['table'] = $relation['table_schema'] . '.' .
215
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) {
216
+                $relations[$relation['constraint_name']]['table'] = $relation['table_schema'].'.'.
217 217
                     $relation['table_name'];
218 218
                 $relations[$relation['constraint_name']]['keymap'][$relation['referenced_column_name']] =
219 219
                     $relation['column_name'];
220 220
             }
221
-            foreach ([ true, false ] as $pivot) {
221
+            foreach ([true, false] as $pivot) {
222 222
                 foreach ($relations as $data) {
223 223
                     $rtable = $this->table($data['table'], true);
224 224
                     $columns = [];
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
                     $usedcol = [];
232 232
                     if (count($columns)) {
233 233
                         foreach (Collection::from($relationsT[$data['table']] ?? [])
234
-                            ->filter(function ($v) use ($columns) {
234
+                            ->filter(function($v) use ($columns) {
235 235
                                 return in_array($v['column_name'], $columns);
236 236
                             }) as $relation
237 237
                         ) {
238
-                            $foreign[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'] . '.' .
238
+                            $foreign[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'].'.'.
239 239
                                 $relation['referenced_table_name'];
240 240
                             $foreign[$relation['constraint_name']]['keymap'][$relation['column_name']] =
241 241
                                 $relation['referenced_column_name'];
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
                             $definition->getName() == $relname ||
256 256
                             $definition->getColumn($relname)
257 257
                         ) {
258
-                            $relname = $orig . '_' . (++ $cntr);
258
+                            $relname = $orig.'_'.(++$cntr);
259 259
                         }
260 260
                         $definition->addRelation(
261 261
                             new TableRelation(
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
                             $definition->getName() == $relname ||
284 284
                             $definition->getColumn($relname)
285 285
                         ) {
286
-                            $relname .= '_' . array_values($data['keymap'])[0];
286
+                            $relname .= '_'.array_values($data['keymap'])[0];
287 287
                         }
288 288
                         $orig = $relname;
289 289
                         $cntr = 1;
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
                             $definition->getName() == $relname ||
292 292
                             $definition->getColumn($relname)
293 293
                         ) {
294
-                            $relname = $orig . '_' . (++ $cntr);
294
+                            $relname = $orig.'_'.(++$cntr);
295 295
                         }
296 296
                         $definition->addRelation(
297 297
                             new TableRelation(
@@ -342,20 +342,20 @@  discard block
 block discarded – undo
342 342
                     attr.attnum > 0
343 343
                  order by
344 344
                     attr.attnum",
345
-                [ $table, $schema ]
345
+                [$table, $schema]
346 346
             ))
347
-            ->mapKey(function ($v): string {
347
+            ->mapKey(function($v): string {
348 348
                 return $v['column_name'];
349 349
             })
350
-            ->map(function ($v) {
350
+            ->map(function($v) {
351 351
                 $v['length'] = null;
352 352
                 return $v;
353 353
             })
354 354
             ->toArray();
355 355
         if (!count($columns)) {
356
-            throw new DBException('View not found by name: ' . implode('.', [$schema,$table]));
356
+            throw new DBException('View not found by name: '.implode('.', [$schema, $table]));
357 357
         }
358
-        $tables[$schema . '.' .$table] = $definition = (new Table($table, $schema))
358
+        $tables[$schema.'.'.$table] = $definition = (new Table($table, $schema))
359 359
             ->addColumns($columns)
360 360
             ->setComment('');
361 361
         return $definition;
@@ -365,13 +365,13 @@  discard block
 block discarded – undo
365 365
         $tables = Collection::from($this
366 366
             ->query(
367 367
                 "SELECT table_name FROM information_schema.tables where table_schema = ? AND table_catalog = ?",
368
-                [ $this->connection['opts']['schema'] ?? 'public', $this->connection['name'] ]
368
+                [$this->connection['opts']['schema'] ?? 'public', $this->connection['name']]
369 369
             ))
370
-            ->mapKey(function ($v) {
370
+            ->mapKey(function($v) {
371 371
                 return strtolower($v['table_name']);
372 372
             })
373 373
             ->pluck('table_name')
374
-            ->map(function ($v) {
374
+            ->map(function($v) {
375 375
                 return $this->table($v)->toLowerCase();
376 376
             })
377 377
             ->toArray();
@@ -382,19 +382,19 @@  discard block
 block discarded – undo
382 382
                  FROM pg_catalog.pg_class cls
383 383
                  join pg_catalog.pg_namespace as ns on ns.oid = cls.relnamespace
384 384
                  WHERE cls.relkind = 'm' and ns.nspname = ?",
385
-                [ $this->connection['opts']['schema'] ?? 'public' ]
385
+                [$this->connection['opts']['schema'] ?? 'public']
386 386
             ))
387
-            ->mapKey(function ($v) {
387
+            ->mapKey(function($v) {
388 388
                 return strtolower($v['table_name']);
389 389
             })
390 390
             ->pluck('table_name')
391
-            ->map(function ($v) {
391
+            ->map(function($v) {
392 392
                 return $this->view($v)->toLowerCase();
393 393
             })
394 394
             ->toArray();
395 395
         $tables = array_merge($views, $tables);
396 396
         foreach (array_keys($tables) as $k) {
397
-            $tables[($this->connection['opts']['schema'] ?? 'public') . '.' . $k] = &$tables[$k];
397
+            $tables[($this->connection['opts']['schema'] ?? 'public').'.'.$k] = &$tables[$k];
398 398
         }
399 399
         return $tables;
400 400
     }
Please login to merge, or discard this patch.
src/driver/sqlite/Schema.php 1 patch
Spacing   +29 added lines, -29 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
             // relations where the current table references another table
113 113
             // assuming current table is linked to "one" record in the referenced table
114 114
             // resulting in a "belongsTo" relationship
115 115
             $relations = [];
116
-            foreach ($relationsT[$schema . '.' . $table] ?? [] as $relation) {
117
-                $relations[$relation['constraint_name']]['table'] = 'main.' . $relation['referenced_table'];
116
+            foreach ($relationsT[$schema.'.'.$table] ?? [] as $relation) {
117
+                $relations[$relation['constraint_name']]['table'] = 'main.'.$relation['referenced_table'];
118 118
                 $relations[$relation['constraint_name']]['keymap'][$relation['from']] = $relation['to'];
119 119
             }
120 120
             foreach ($relations as $name => $data) {
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
                     $relname = $temp[1];
125 125
                 }
126 126
                 if ($duplicated[$data['table']]) {
127
-                    $relname = array_keys($data['keymap'])[0] . '_' . $relname;
127
+                    $relname = array_keys($data['keymap'])[0].'_'.$relname;
128 128
                 }
129 129
                 $orig = $relname;
130 130
                 $cntr = 1;
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
                     $definition->getName() == $relname ||
133 133
                     $definition->getColumn($relname)
134 134
                 ) {
135
-                    $relname = $orig . '_' . (++ $cntr);
135
+                    $relname = $orig.'_'.(++$cntr);
136 136
                 }
137 137
                 $definition->addRelation(
138 138
                     new TableRelation(
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
             // assuming current table is on the "one" end having "many" records in the referencing table
149 149
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
150 150
             $relations = [];
151
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $k => $relation) {
152
-                $relations[$relation['constraint_name']]['table'] = 'main.' . $relation['table'];
151
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $k => $relation) {
152
+                $relations[$relation['constraint_name']]['table'] = 'main.'.$relation['table'];
153 153
                 $relations[$relation['constraint_name']]['keymap'][$relation['to']] = $relation['from'];
154 154
             }
155
-            foreach ([ true, false ] as $pivot) {
155
+            foreach ([true, false] as $pivot) {
156 156
                 foreach ($relations as $data) {
157 157
                     $rtable = $this->table($data['table'], true);
158 158
                     $columns = [];
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
                     $usedcol = [];
166 166
                     if (count($columns)) {
167 167
                         foreach (Collection::from($relationsT[$data['table']] ?? [])
168
-                            ->filter(function ($v) use ($columns) {
168
+                            ->filter(function($v) use ($columns) {
169 169
                                 return in_array($v['from'], $columns);
170 170
                             }) as $relation
171 171
                         ) {
172
-                            $foreign[$relation['constraint_name']]['table'] = 'main.' .
172
+                            $foreign[$relation['constraint_name']]['table'] = 'main.'.
173 173
                                 $relation['referenced_table'];
174 174
                             $foreign[$relation['constraint_name']]['keymap'][$relation['from']] = $relation['to'];
175 175
                             $usedcol[] = $relation['from'];
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
                             $definition->getName() == $relname ||
189 189
                             $definition->getColumn($relname)
190 190
                         ) {
191
-                            $relname = $orig . '_' . (++ $cntr);
191
+                            $relname = $orig.'_'.(++$cntr);
192 192
                         }
193 193
                         $definition->addRelation(
194 194
                             new TableRelation(
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
                             $definition->getName() == $relname ||
217 217
                             $definition->getColumn($relname)
218 218
                         ) {
219
-                            $relname .= '_' . array_values($data['keymap'])[0];
219
+                            $relname .= '_'.array_values($data['keymap'])[0];
220 220
                         }
221 221
                         $orig = $relname;
222 222
                         $cntr = 1;
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
                             $definition->getName() == $relname ||
225 225
                             $definition->getColumn($relname)
226 226
                         ) {
227
-                            $relname = $orig . '_' . (++ $cntr);
227
+                            $relname = $orig.'_'.(++$cntr);
228 228
                         }
229 229
                         $definition->addRelation(
230 230
                             new TableRelation(
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
                 "SELECT tbl_name
254 254
                  FROM sqlite_schema
255 255
                  WHERE (type = ? OR type = ?) AND tbl_name NOT LIKE 'sqlite_%';",
256
-                [ 'table', 'view' ]
256
+                ['table', 'view']
257 257
             ))
258
-            ->mapKey(function ($v) {
258
+            ->mapKey(function($v) {
259 259
                 return strtolower($v['tbl_name']);
260 260
             })
261 261
             ->pluck('tbl_name')
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
             $tables[$k] = $this->table($v, true, array_keys($tables))->toLowerCase();
265 265
         }
266 266
         foreach (array_keys($tables) as $k) {
267
-            $tables[($this->connection['opts']['schema'] ?? 'main') . '.' . $k] = &$tables[$k];
267
+            $tables[($this->connection['opts']['schema'] ?? 'main').'.'.$k] = &$tables[$k];
268 268
         }
269 269
         return $tables;
270 270
     }
Please login to merge, or discard this patch.
src/driver/mysql/Schema.php 1 patch
Spacing   +36 added lines, -36 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
             // relations where the current table references another table
163 163
             // assuming current table is linked to "one" record in the referenced table
164 164
             // resulting in a "belongsTo" relationship
165 165
             $relations = [];
166
-            foreach ($relationsT[$schema . '.' . $table] ?? [] as $relation) {
167
-                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'] . '.' .
166
+            foreach ($relationsT[$schema.'.'.$table] ?? [] as $relation) {
167
+                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'].'.'.
168 168
                     $relation['REFERENCED_TABLE_NAME'];
169 169
                 $relations[$relation['CONSTRAINT_NAME']]['keymap'][$relation['COLUMN_NAME']] =
170 170
                     $relation['REFERENCED_COLUMN_NAME'];
@@ -176,12 +176,12 @@  discard block
 block discarded – undo
176 176
                     $relname = $temp[1];
177 177
                 }
178 178
                 if ($duplicated[$data['table']]) {
179
-                    $relname = array_keys($data['keymap'])[0] . '_' . $relname;
179
+                    $relname = array_keys($data['keymap'])[0].'_'.$relname;
180 180
                 }
181 181
                 $orig = $relname;
182 182
                 $cntr = 1;
183 183
                 while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
184
-                    $relname = $orig . '_' . (++ $cntr);
184
+                    $relname = $orig.'_'.(++$cntr);
185 185
                 }
186 186
                 $definition->addRelation(
187 187
                     new TableRelation(
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
             // assuming current table is on the "one" end having "many" records in the referencing table
198 198
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
199 199
             $relations = [];
200
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) {
201
-                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'] . '.' .
200
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) {
201
+                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'].'.'.
202 202
                     $relation['TABLE_NAME'];
203 203
                 $relations[$relation['CONSTRAINT_NAME']]['keymap'][$relation['REFERENCED_COLUMN_NAME']] =
204 204
                     $relation['COLUMN_NAME'];
205 205
             }
206
-            foreach ([ true, false ] as $pivot) {
206
+            foreach ([true, false] as $pivot) {
207 207
                 foreach ($relations as $data) {
208 208
                     $rtable = $this->table($data['table'], true);
209 209
                     $columns = [];
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
                     $usedcol = [];
217 217
                     if (count($columns)) {
218 218
                         foreach (Collection::from($relationsT[$data['table']] ?? [])
219
-                            ->filter(function (array $v) use ($columns): bool {
219
+                            ->filter(function(array $v) use ($columns): bool {
220 220
                                 return in_array($v['COLUMN_NAME'], $columns);
221 221
                             })
222
-                            ->map(function (array $v): array {
222
+                            ->map(function(array $v): array {
223 223
                                 $new = [];
224 224
                                 foreach ($v as $kk => $vv) {
225 225
                                     $new[strtoupper($kk)] = $vv;
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
                                 return $new;
228 228
                             }) as $relation
229 229
                         ) {
230
-                            $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'] . '.' .
230
+                            $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'].'.'.
231 231
                                 $relation['REFERENCED_TABLE_NAME'];
232 232
                             $foreign[$relation['CONSTRAINT_NAME']]['keymap'][$relation['COLUMN_NAME']] =
233 233
                                 $relation['REFERENCED_COLUMN_NAME'];
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
                         $orig = $relname;
245 245
                         $cntr = 1;
246 246
                         while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
247
-                            $relname = $orig . '_' . (++ $cntr);
247
+                            $relname = $orig.'_'.(++$cntr);
248 248
                         }
249 249
                         $definition->addRelation(
250 250
                             new TableRelation(
@@ -272,12 +272,12 @@  discard block
 block discarded – undo
272 272
                             $definition->getName() == $relname ||
273 273
                             $definition->getColumn($relname)
274 274
                         ) {
275
-                            $relname .= '_' . array_values($data['keymap'])[0];
275
+                            $relname .= '_'.array_values($data['keymap'])[0];
276 276
                         }
277 277
                         $orig = $relname;
278 278
                         $cntr = 1;
279 279
                         while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
280
-                            $relname = $orig . '_' . (++ $cntr);
280
+                            $relname = $orig.'_'.(++$cntr);
281 281
                         }
282 282
                         $definition->addRelation(
283 283
                             new TableRelation(
@@ -306,23 +306,23 @@  discard block
 block discarded – undo
306 306
                 "SELECT table_name FROM information_schema.tables where table_schema = ?",
307 307
                 [$this->connection['opts']['schema'] ?? $this->connection['name']]
308 308
             ))
309
-            ->map(function (array $v): array {
309
+            ->map(function(array $v): array {
310 310
                 $new = [];
311 311
                 foreach ($v as $kk => $vv) {
312 312
                     $new[strtoupper($kk)] = $vv;
313 313
                 }
314 314
                 return $new;
315 315
             })
316
-            ->mapKey(function (array $v): string {
316
+            ->mapKey(function(array $v): string {
317 317
                 return strtolower($v['TABLE_NAME']);
318 318
             })
319 319
             ->pluck('TABLE_NAME')
320
-            ->map(function (string $v): Table {
320
+            ->map(function(string $v): Table {
321 321
                 return $this->table($v)->toLowerCase();
322 322
             })
323 323
             ->toArray();
324 324
         foreach (array_keys($tables) as $k) {
325
-            $tables[($this->connection['opts']['schema'] ?? $this->connection['name']) . '.' . $k] = &$tables[$k];
325
+            $tables[($this->connection['opts']['schema'] ?? $this->connection['name']).'.'.$k] = &$tables[$k];
326 326
         }
327 327
         return $tables;
328 328
     }
Please login to merge, or discard this patch.
src/driver/oracle/Schema.php 1 patch
Spacing   +29 added lines, -29 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;
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
                     ->query(
172 172
                         "SELECT COLUMN_NAME FROM user_cons_columns
173 173
                          WHERE CONSTRAINT_NAME = ? ORDER BY POSITION",
174
-                        [ current($data['keymap']) ]
174
+                        [current($data['keymap'])]
175 175
                     ))
176
-                    ->map(function ($v) {
176
+                    ->map(function($v) {
177 177
                         $new = [];
178 178
                         foreach ($v as $kk => $vv) {
179 179
                             $new[strtoupper($kk)] = $vv;
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
                 }
188 188
                 $relname = $data['table'];
189 189
                 if ($duplicated[$data['table']]) {
190
-                    $relname = array_keys($data['keymap'])[0] . '_' . $relname;
190
+                    $relname = array_keys($data['keymap'])[0].'_'.$relname;
191 191
                 }
192 192
                 $orig = $relname;
193 193
                 $cntr = 1;
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
                     $definition->getName() == $relname ||
197 197
                     $definition->getColumn($relname)
198 198
                 ) {
199
-                    $relname = $orig . '_' . (++ $cntr);
199
+                    $relname = $orig.'_'.(++$cntr);
200 200
                 }
201 201
                 $definition->addRelation(
202 202
                     new TableRelation(
@@ -214,10 +214,10 @@  discard block
 block discarded – undo
214 214
             $relations = [];
215 215
             foreach ($relationsR as $relation) {
216 216
                 $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_NAME'];
217
-                $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int)$relation['POSITION']-1]] =
217
+                $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int) $relation['POSITION'] - 1]] =
218 218
                     $relation['COLUMN_NAME'];
219 219
             }
220
-            foreach ([ true, false ] as $pivot) {
220
+            foreach ([true, false] as $pivot) {
221 221
                 foreach ($relations as $data) {
222 222
                     $rtable = $this->table($data['table'], true);
223 223
                     $columns = [];
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
                                     ac.TABLE_NAME = ? AND ac.CONSTRAINT_TYPE = ? AND
246 246
                                     cc.COLUMN_NAME IN (??)
247 247
                                 ORDER BY POSITION",
248
-                                [ $data['table'], 'R', $columns ]
248
+                                [$data['table'], 'R', $columns]
249 249
                             ))
250
-                            ->map(function ($v) {
250
+                            ->map(function($v) {
251 251
                                 $new = [];
252 252
                                 foreach ($v as $kk => $vv) {
253 253
                                     $new[strtoupper($kk)] = $vv;
@@ -267,9 +267,9 @@  discard block
 block discarded – undo
267 267
                             ->query(
268 268
                                 "SELECT COLUMN_NAME FROM user_cons_columns
269 269
                                 WHERE CONSTRAINT_NAME = ? ORDER BY POSITION",
270
-                                [ current($foreign['keymap']) ]
270
+                                [current($foreign['keymap'])]
271 271
                             ))
272
-                            ->map(function ($v) {
272
+                            ->map(function($v) {
273 273
                                 $new = [];
274 274
                                 foreach ($v as $kk => $vv) {
275 275
                                     $new[strtoupper($kk)] = $vv;
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
                         $relname = $foreign['table'];
285 285
                         $cntr = 1;
286 286
                         while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
287
-                            $relname = $foreign['table'] . '_' . (++ $cntr);
287
+                            $relname = $foreign['table'].'_'.(++$cntr);
288 288
                         }
289 289
                         $definition->addRelation(
290 290
                             new TableRelation(
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
                             $definition->getName() == $relname ||
309 309
                             $definition->getColumn($relname)
310 310
                         ) {
311
-                            $relname .= '_' . array_values($data['keymap'])[0];
311
+                            $relname .= '_'.array_values($data['keymap'])[0];
312 312
                         }
313 313
                         $orig = $relname;
314 314
                         $cntr = 1;
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
                             $definition->getName() == $relname ||
318 318
                             $definition->getColumn($relname)
319 319
                         ) {
320
-                            $relname = $orig . '_' . (++ $cntr);
320
+                            $relname = $orig.'_'.(++$cntr);
321 321
                         }
322 322
                         $definition->addRelation(
323 323
                             new TableRelation(
@@ -348,18 +348,18 @@  discard block
 block discarded – undo
348 348
                  SELECT VIEW_NAME AS TABLE_NAME FROM USER_VIEWS",
349 349
                 []
350 350
             ))
351
-            ->map(function ($v) {
351
+            ->map(function($v) {
352 352
                 $new = [];
353 353
                 foreach ($v as $kk => $vv) {
354 354
                     $new[strtoupper($kk)] = $vv;
355 355
                 }
356 356
                 return $new;
357 357
             })
358
-            ->mapKey(function ($v) {
358
+            ->mapKey(function($v) {
359 359
                 return strtolower($v['TABLE_NAME']);
360 360
             })
361 361
             ->pluck('TABLE_NAME')
362
-            ->map(function ($v) {
362
+            ->map(function($v) {
363 363
                 return $this->table($v)->toLowerCase();
364 364
             })
365 365
             ->toArray();
Please login to merge, or discard this patch.