Completed
Push — master ( be2ee3...343ee8 )
by Ivan
12:14
created
src/driver/postgre/Result.php 1 patch
Spacing   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@  discard block
 block discarded – undo
37 37
             $temp = @\pg_query(
38 38
                 $this->driver,
39 39
                 $sequence ?
40
-                    'SELECT currval('.@\pg_escape_string($this->driver, $sequence).')' :
41
-                    'SELECT lastval()'
40
+                    'SELECT currval('.@\pg_escape_string($this->driver, $sequence).')' : 'SELECT lastval()'
42 41
             );
43 42
             if ($temp) {
44 43
                 $res = \pg_fetch_row($temp);
@@ -76,8 +75,8 @@  discard block
 block discarded – undo
76 75
     }
77 76
     public function next(): void
78 77
     {
79
-        $this->fetched ++;
80
-        $this->last = \pg_fetch_array($this->statement, null, \PGSQL_ASSOC)?:null;
78
+        $this->fetched++;
79
+        $this->last = \pg_fetch_array($this->statement, null, \PGSQL_ASSOC) ?: null;
81 80
         if (is_array($this->last)) {
82 81
             $this->cast();
83 82
         }
@@ -90,11 +89,11 @@  discard block
 block discarded – undo
90 89
     protected function cast(): void
91 90
     {
92 91
         if (!count($this->types)) {
93
-            foreach (array_keys($this->last??[]) as $k => $v) {
92
+            foreach (array_keys($this->last ?? []) as $k => $v) {
94 93
                 $this->types[$v] = \pg_field_type($this->statement, $k);
95 94
             }
96 95
         }
97
-        foreach ($this->last??[] as $k => $v) {
96
+        foreach ($this->last ?? [] as $k => $v) {
98 97
             if (is_null($v) || !isset($this->types[$k])) {
99 98
                 continue;
100 99
             }
@@ -102,15 +101,15 @@  discard block
 block discarded – undo
102 101
                 case 'int2':
103 102
                 case 'int4':
104 103
                 case 'int8':
105
-                    $this->last[$k] = (int)$v;
104
+                    $this->last[$k] = (int) $v;
106 105
                     break;
107 106
                 case 'bit':
108 107
                 case 'bool':
109
-                    $this->last[$k] = $v !== 'f' && (int)$v ? true : false;
108
+                    $this->last[$k] = $v !== 'f' && (int) $v ? true : false;
110 109
                     break;
111 110
                 case 'float4':
112 111
                 case 'float8':
113
-                    $this->last[$k] = (float)$v;
112
+                    $this->last[$k] = (float) $v;
114 113
                     break;
115 114
                 case 'money':
116 115
                 case 'numeric':
Please login to merge, or discard this patch.
src/driver/mysql/Schema.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
             $table = $temp[1];
28 28
         }
29 29
 
30
-        if (isset($tables[$schema . '.' . $table])) {
31
-            return $tables[$schema . '.' . $table];
30
+        if (isset($tables[$schema.'.'.$table])) {
31
+            return $tables[$schema.'.'.$table];
32 32
         }
33 33
 
34 34
         static $comments = [];
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
             $comments[$schema] = Collection::from(
37 37
                 $this->query(
38 38
                     "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ?",
39
-                    [ $schema ]
39
+                    [$schema]
40 40
                 )
41 41
             )
42
-            ->mapKey(function (array $v): string {
42
+            ->mapKey(function(array $v): string {
43 43
                 return $v['TABLE_NAME'];
44 44
             })
45 45
             ->pluck('TABLE_COMMENT')
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
                      WHERE
62 62
                         (TABLE_SCHEMA = ? OR REFERENCED_TABLE_SCHEMA = ?) AND
63 63
                         TABLE_NAME IS NOT NULL AND REFERENCED_TABLE_NAME IS NOT NULL",
64
-                    [ $main, $main ]
64
+                    [$main, $main]
65 65
                 )
66 66
             )->toArray();
67 67
             foreach ($col as $row) {
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
                 if ($row['REFERENCED_TABLE_SCHEMA'] !== $main) {
72 72
                     $additional[] = $row['REFERENCED_TABLE_SCHEMA'];
73 73
                 }
74
-                $relationsT[$row['TABLE_SCHEMA'] . '.' . $row['TABLE_NAME']][] = $row;
75
-                $relationsR[$row['REFERENCED_TABLE_SCHEMA'] . '.' . $row['REFERENCED_TABLE_NAME']][] = $row;
74
+                $relationsT[$row['TABLE_SCHEMA'].'.'.$row['TABLE_NAME']][] = $row;
75
+                $relationsR[$row['REFERENCED_TABLE_SCHEMA'].'.'.$row['REFERENCED_TABLE_NAME']][] = $row;
76 76
             }
77 77
             foreach (array_filter(array_unique($additional)) as $s) {
78 78
                 $col = Collection::from(
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
                         WHERE
85 85
                             TABLE_SCHEMA = ? AND REFERENCED_TABLE_SCHEMA = ? AND
86 86
                             TABLE_NAME IS NOT NULL AND REFERENCED_TABLE_NAME IS NOT NULL",
87
-                        [ $s, $s ]
87
+                        [$s, $s]
88 88
                     )
89 89
                 )->toArray();
90 90
                 foreach ($col as $row) {
91
-                    $relationsT[$row['TABLE_SCHEMA'] . '.' . $row['TABLE_NAME']][] = $row;
92
-                    $relationsR[$row['REFERENCED_TABLE_SCHEMA'] . '.' . $row['REFERENCED_TABLE_NAME']][] = $row;
91
+                    $relationsT[$row['TABLE_SCHEMA'].'.'.$row['TABLE_NAME']][] = $row;
92
+                    $relationsR[$row['REFERENCED_TABLE_SCHEMA'].'.'.$row['REFERENCED_TABLE_NAME']][] = $row;
93 93
                 }
94 94
             }
95 95
         }
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
         if (!count($columns)) {
99 99
             throw new DBException('Table not found by name');
100 100
         }
101
-        $tables[$schema . '.' . $table] = $definition = (new Table($table, $schema))
101
+        $tables[$schema.'.'.$table] = $definition = (new Table($table, $schema))
102 102
             ->addColumns(
103 103
                 $columns
104 104
                     ->clone()
105
-                    ->mapKey(function (array $v): string {
105
+                    ->mapKey(function(array $v): string {
106 106
                         return $v['Field'];
107 107
                     })
108
-                    ->map(function (array $v): array {
108
+                    ->map(function(array $v): array {
109 109
                         $v['length'] = null;
110 110
                         if (!isset($v['Type'])) {
111 111
                             return $v;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                             default:
128 128
                                 if (strpos($type, 'char') !== false && strpos($type, '(') !== false) {
129 129
                                     // extract length from varchar
130
-                                    $v['length'] = (int)explode(')', explode('(', $type)[1])[0];
130
+                                    $v['length'] = (int) explode(')', explode('(', $type)[1])[0];
131 131
                                     $v['length'] = $v['length'] > 0 ? $v['length'] : null;
132 132
                                 }
133 133
                                 break;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
             ->setPrimaryKey(
140 140
                 $columns
141 141
                     ->clone()
142
-                    ->filter(function (array $v): bool {
142
+                    ->filter(function(array $v): bool {
143 143
                         return $v['Key'] === 'PRI';
144 144
                     })
145 145
                     ->pluck('Field')
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
             // assuming current table is on the "one" end having "many" records in the referencing table
154 154
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
155 155
             $relations = [];
156
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) {
157
-                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'] . '.' .
156
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) {
157
+                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'].'.'.
158 158
                     $relation['TABLE_NAME'];
159 159
                 $relations[$relation['CONSTRAINT_NAME']]['keymap'][$relation['REFERENCED_COLUMN_NAME']] =
160 160
                     $relation['COLUMN_NAME'];
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
                 $usedcol = [];
172 172
                 if (count($columns)) {
173 173
                     foreach (Collection::from($relationsT[$data['table']] ?? [])
174
-                        ->filter(function (array $v) use ($columns): bool {
174
+                        ->filter(function(array $v) use ($columns): bool {
175 175
                             return in_array($v['COLUMN_NAME'], $columns);
176 176
                         })
177
-                        ->map(function (array $v): array {
177
+                        ->map(function(array $v): array {
178 178
                             $new = [];
179 179
                             foreach ($v as $kk => $vv) {
180 180
                                 $new[strtoupper($kk)] = $vv;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
                             return $new;
183 183
                         }) as $relation
184 184
                     ) {
185
-                        $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'] . '.' .
185
+                        $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'].'.'.
186 186
                             $relation['REFERENCED_TABLE_NAME'];
187 187
                         $foreign[$relation['CONSTRAINT_NAME']]['keymap'][$relation['COLUMN_NAME']] =
188 188
                             $relation['REFERENCED_COLUMN_NAME'];
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
                     $orig = $relname;
200 200
                     $cntr = 1;
201 201
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
202
-                        $relname = $orig . '_' . (++ $cntr);
202
+                        $relname = $orig.'_'.(++$cntr);
203 203
                     }
204 204
                     $definition->addRelation(
205 205
                         new TableRelation(
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
                     $orig = $relname;
221 221
                     $cntr = 1;
222 222
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
223
-                        $relname = $orig . '_' . (++ $cntr);
223
+                        $relname = $orig.'_'.(++$cntr);
224 224
                     }
225 225
                     $definition->addRelation(
226 226
                         new TableRelation(
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
             // assuming current table is linked to "one" record in the referenced table
237 237
             // resulting in a "belongsTo" relationship
238 238
             $relations = [];
239
-            foreach (Collection::from($relationsT[$schema . '.' . $table] ?? [])
240
-                ->map(function (array $v): array {
239
+            foreach (Collection::from($relationsT[$schema.'.'.$table] ?? [])
240
+                ->map(function(array $v): array {
241 241
                     $new = [];
242 242
                     foreach ($v as $kk => $vv) {
243 243
                         $new[strtoupper($kk)] = $vv;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                     return $new;
246 246
                 }) as $relation
247 247
             ) {
248
-                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'] . '.' .
248
+                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'].'.'.
249 249
                     $relation['REFERENCED_TABLE_NAME'];
250 250
                 $relations[$relation['CONSTRAINT_NAME']]['keymap'][$relation['COLUMN_NAME']] =
251 251
                     $relation['REFERENCED_COLUMN_NAME'];
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
                 $orig = $relname;
260 260
                 $cntr = 1;
261 261
                 while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
262
-                    $relname = $orig . '_' . (++ $cntr);
262
+                    $relname = $orig.'_'.(++$cntr);
263 263
                 }
264 264
                 $definition->addRelation(
265 265
                     new TableRelation(
@@ -280,23 +280,23 @@  discard block
 block discarded – undo
280 280
                 "SELECT table_name FROM information_schema.tables where table_schema = ?",
281 281
                 [$this->connection['opts']['schema'] ?? $this->connection['name']]
282 282
             ))
283
-            ->map(function (array $v): array {
283
+            ->map(function(array $v): array {
284 284
                 $new = [];
285 285
                 foreach ($v as $kk => $vv) {
286 286
                     $new[strtoupper($kk)] = $vv;
287 287
                 }
288 288
                 return $new;
289 289
             })
290
-            ->mapKey(function (array $v): string {
290
+            ->mapKey(function(array $v): string {
291 291
                 return strtolower($v['TABLE_NAME']);
292 292
             })
293 293
             ->pluck('TABLE_NAME')
294
-            ->map(function (string $v): Table {
294
+            ->map(function(string $v): Table {
295 295
                 return $this->table($v)->toLowerCase();
296 296
             })
297 297
             ->toArray();
298 298
         foreach (array_keys($tables) as $k) {
299
-            $tables[($this->connection['opts']['schema'] ?? $this->connection['name']) . '.' . $k] = &$tables[$k];
299
+            $tables[($this->connection['opts']['schema'] ?? $this->connection['name']).'.'.$k] = &$tables[$k];
300 300
         }
301 301
         return $tables;
302 302
     }
Please login to merge, or discard this patch.
src/Schema.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -64,13 +64,13 @@  discard block
 block discarded – undo
64 64
     
65 65
     public function toArray(): array
66 66
     {
67
-        return array_map(function ($table) {
67
+        return array_map(function($table) {
68 68
             return [
69 69
                 'name' => $table->getName(),
70 70
                 'schema' => $table->getSchema(),
71 71
                 'pkey' => $table->getPrimaryKey(),
72 72
                 'comment' => $table->getComment(),
73
-                'columns' => array_map(function ($column) {
73
+                'columns' => array_map(function($column) {
74 74
                     return [
75 75
                         'name' => $column->getName(),
76 76
                         'type' => $column->getType(),
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
                         'nullable' => $column->isNullable()
82 82
                     ];
83 83
                 }, $table->getFullColumns()),
84
-                'relations' => array_map(function ($rel) {
84
+                'relations' => array_map(function($rel) {
85 85
                     $relation = clone $rel;
86
-                    $relation = (array)$relation;
86
+                    $relation = (array) $relation;
87 87
                     $relation['table'] = $rel->table->getName();
88 88
                     if ($rel->pivot) {
89 89
                         $relation['pivot'] = $rel->pivot->getName();
Please login to merge, or discard this patch.
src/driver/postgre/Statement.php 1 patch
Spacing   +12 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,17 +23,17 @@  discard block
 block discarded – undo
23 23
         if (strpos(strtolower($statement), 'prepare') === 0) {
24 24
             $this->drv->raw($this->statement);
25 25
             if (!isset($this->name)) {
26
-                $this->name = trim((preg_split('(\s+)', trim($this->statement))?:[])[1]??'', '"');
26
+                $this->name = trim((preg_split('(\s+)', trim($this->statement)) ?: [])[1] ?? '', '"');
27 27
             }
28 28
         } elseif ($this->name !== null) {
29 29
             $temp = \pg_prepare($this->driver, $this->name, $this->statement);
30 30
             if (!$temp) {
31 31
                 $log = $this->drv->option('log_file');
32
-                if ($log && (int)$this->drv->option('log_errors', 1)) {
32
+                if ($log && (int) $this->drv->option('log_errors', 1)) {
33 33
                     @file_put_contents(
34 34
                         $log,
35
-                        '--' . date('Y-m-d H:i:s') . ' ERROR PREPARING: ' . \pg_last_error($this->driver) . "\r\n" .
36
-                        $this->statement . "\r\n" .
35
+                        '--'.date('Y-m-d H:i:s').' ERROR PREPARING: '.\pg_last_error($this->driver)."\r\n".
36
+                        $this->statement."\r\n".
37 37
                         "\r\n",
38 38
                         FILE_APPEND
39 39
                     );
@@ -62,22 +62,20 @@  discard block
 block discarded – undo
62 62
         try {
63 63
             if ($this->name !== null) {
64 64
                 $temp = (is_array($data) && count($data)) ?
65
-                    \pg_execute($this->driver, $this->name, $data) :
66
-                    \pg_execute($this->driver, $this->name, array());
65
+                    \pg_execute($this->driver, $this->name, $data) : \pg_execute($this->driver, $this->name, array());
67 66
             } else {
68 67
                 $temp = (is_array($data) && count($data)) ?
69
-                    \pg_query_params($this->driver, $this->statement, $data) :
70
-                    \pg_query_params($this->driver, $this->statement, array());
68
+                    \pg_query_params($this->driver, $this->statement, $data) : \pg_query_params($this->driver, $this->statement, array());
71 69
             }
72 70
         } catch (\Exception $e) {
73 71
             $temp = false;
74 72
         }
75 73
         if (!$temp) {
76
-            if ($log && (int)$this->drv->option('log_errors', 1)) {
74
+            if ($log && (int) $this->drv->option('log_errors', 1)) {
77 75
                 @file_put_contents(
78 76
                     $log,
79
-                    '--' . date('Y-m-d H:i:s') . ' ERROR: ' . \pg_last_error($this->driver) . "\r\n" .
80
-                    $this->statement . "\r\n" .
77
+                    '--'.date('Y-m-d H:i:s').' ERROR: '.\pg_last_error($this->driver)."\r\n".
78
+                    $this->statement."\r\n".
81 79
                     "\r\n",
82 80
                     FILE_APPEND
83 81
                 );
@@ -86,11 +84,11 @@  discard block
 block discarded – undo
86 84
         }
87 85
         if ($log) {
88 86
             $tm = microtime(true) - $tm;
89
-            if ($tm >= (float)$this->drv->option('log_slow', 0)) {
87
+            if ($tm >= (float) $this->drv->option('log_slow', 0)) {
90 88
                 @file_put_contents(
91 89
                     $log,
92
-                    '--' . date('Y-m-d H:i:s') . ' ' . sprintf('%01.6f', $tm) . "s\r\n" .
93
-                    $this->statement . "\r\n" .
90
+                    '--'.date('Y-m-d H:i:s').' '.sprintf('%01.6f', $tm)."s\r\n".
91
+                    $this->statement."\r\n".
94 92
                     "\r\n",
95 93
                     FILE_APPEND
96 94
                 );
Please login to merge, or discard this patch.
src/driver/mysql/Statement.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
             foreach ($lng as $index) {
78 78
                 if (is_resource($data[$index]) && get_resource_type($data[$index]) === 'stream') {
79 79
                     while (!feof($data[$index])) {
80
-                        $this->statement->send_long_data($index, (string)fread($data[$index], $lds));
80
+                        $this->statement->send_long_data($index, (string) fread($data[$index], $lds));
81 81
                     }
82 82
                 } else {
83 83
                     $data[$index] = str_split($data[$index], $lds);
@@ -97,24 +97,24 @@  discard block
 block discarded – undo
97 97
             $res = false;
98 98
         }
99 99
         if (!$res) {
100
-            if ($log && (int)$this->driver->option('log_errors', 1)) {
100
+            if ($log && (int) $this->driver->option('log_errors', 1)) {
101 101
                 @file_put_contents(
102 102
                     $log,
103
-                    '--' . date('Y-m-d H:i:s') . ' ERROR: ' . $this->statement->error . "\r\n" .
104
-                    $this->sql . "\r\n" .
103
+                    '--'.date('Y-m-d H:i:s').' ERROR: '.$this->statement->error."\r\n".
104
+                    $this->sql."\r\n".
105 105
                     "\r\n",
106 106
                     FILE_APPEND
107 107
                 );
108 108
             }
109
-            throw new DBException('Prepared execute error: ' . $this->statement->error);
109
+            throw new DBException('Prepared execute error: '.$this->statement->error);
110 110
         }
111 111
         if ($log) {
112 112
             $tm = microtime(true) - $tm;
113
-            if ($tm >= (float)$this->driver->option('log_slow', 0)) {
113
+            if ($tm >= (float) $this->driver->option('log_slow', 0)) {
114 114
                 @file_put_contents(
115 115
                     $log,
116
-                    '--' . date('Y-m-d H:i:s') . ' ' . sprintf('%01.6f', $tm) . "s\r\n" .
117
-                    $this->sql . "\r\n" .
116
+                    '--'.date('Y-m-d H:i:s').' '.sprintf('%01.6f', $tm)."s\r\n".
117
+                    $this->sql."\r\n".
118 118
                     "\r\n",
119 119
                     FILE_APPEND
120 120
                 );
Please login to merge, or discard this patch.
src/driver/sqlite/Driver.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
         if ($this->lnk === null) {
39 39
             try {
40 40
                 $this->lnk = new \SQLite3($this->connection['name']);
41
-                $this->lnk->exec('PRAGMA encoding = "'.$this->option('charset', 'utf-8') . '"');
41
+                $this->lnk->exec('PRAGMA encoding = "'.$this->option('charset', 'utf-8').'"');
42 42
             } catch (\Exception $e) {
43 43
                 if ($this->lnk !== null) {
44 44
                     throw new DBException('Connect error: '.$this->lnk->lastErrorMsg());
Please login to merge, or discard this patch.
src/schema/TableColumn.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             $instance->setNullable($data['nullable']);
43 43
         }
44 44
         if (isset($data['notnull'])) {
45
-            $instance->setNullable(!((int)$data['notnull']));
45
+            $instance->setNullable(!((int) $data['notnull']));
46 46
         }
47 47
         if (isset($data['Default'])) {
48 48
             $instance->setDefault($data['Default']);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
             $instance->setLength($data['length']);
58 58
         }
59 59
         if ($instance->getBasicType() === 'enum' && strpos($instance->getType(), 'enum(') === 0) {
60
-            $temp = array_map(function ($v) {
60
+            $temp = array_map(function($v) {
61 61
                 return str_replace("''", "'", $v);
62 62
             }, explode("','", substr($instance->getType(), 6, -2)));
63 63
             $instance->setValues($temp);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
                 $instance->setDefault(null);
87 87
             }
88 88
         }
89
-        if ($instance->getBasicType() === 'text' && isset($data['CHAR_LENGTH']) && (int)$data['CHAR_LENGTH']) {
89
+        if ($instance->getBasicType() === 'text' && isset($data['CHAR_LENGTH']) && (int) $data['CHAR_LENGTH']) {
90 90
             $instance->setLength($data['CHAR_LENGTH']);
91 91
         }
92 92
         return $instance;
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
     }
184 184
     public function getLength(): int
185 185
     {
186
-        return (int)$this->length;
186
+        return (int) $this->length;
187 187
     }
188 188
     public function setLength(int $length): static
189 189
     {
Please login to merge, or discard this patch.
src/driver/sqlite/Schema.php 1 patch
Spacing   +22 added lines, -22 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,15 +86,15 @@  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('');
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
             // assuming current table is on the "one" end having "many" records in the referencing table
105 105
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
106 106
             $relations = [];
107
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $k => $relation) {
108
-                $relations[$relation['constraint_name']]['table'] = 'main.' . $relation['table'];
107
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $k => $relation) {
108
+                $relations[$relation['constraint_name']]['table'] = 'main.'.$relation['table'];
109 109
                 $relations[$relation['constraint_name']]['keymap'][$relation['to']] = $relation['from'];
110 110
             }
111 111
             foreach ($relations as $data) {
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
                 $usedcol = [];
121 121
                 if (count($columns)) {
122 122
                     foreach (Collection::from($relationsT[$data['table']] ?? [])
123
-                        ->filter(function ($v) use ($columns) {
123
+                        ->filter(function($v) use ($columns) {
124 124
                             return in_array($v['from'], $columns);
125 125
                         }) as $relation
126 126
                     ) {
127
-                        $foreign[$relation['constraint_name']]['table'] = 'main.' .
127
+                        $foreign[$relation['constraint_name']]['table'] = 'main.'.
128 128
                             $relation['referenced_table'];
129 129
                         $foreign[$relation['constraint_name']]['keymap'][$relation['from']] = $relation['to'];
130 130
                         $usedcol[] = $relation['from'];
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                         $definition->getName() == $relname ||
144 144
                         $definition->getColumn($relname)
145 145
                     ) {
146
-                        $relname = $orig . '_' . (++ $cntr);
146
+                        $relname = $orig.'_'.(++$cntr);
147 147
                     }
148 148
                     $definition->addRelation(
149 149
                         new TableRelation(
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
                         $definition->getName() == $relname ||
168 168
                         $definition->getColumn($relname)
169 169
                     ) {
170
-                        $relname = $orig . '_' . (++ $cntr);
170
+                        $relname = $orig.'_'.(++$cntr);
171 171
                     }
172 172
                     $definition->addRelation(
173 173
                         new TableRelation(
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
             // assuming current table is linked to "one" record in the referenced table
184 184
             // resulting in a "belongsTo" relationship
185 185
             $relations = [];
186
-            foreach ($relationsT[$schema . '.' . $table] ?? [] as $relation) {
187
-                $relations[$relation['constraint_name']]['table'] = 'main.' . $relation['referenced_table'];
186
+            foreach ($relationsT[$schema.'.'.$table] ?? [] as $relation) {
187
+                $relations[$relation['constraint_name']]['table'] = 'main.'.$relation['referenced_table'];
188 188
                 $relations[$relation['constraint_name']]['keymap'][$relation['from']] = $relation['to'];
189 189
             }
190 190
             foreach ($relations as $name => $data) {
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
                     $definition->getName() == $relname ||
200 200
                     $definition->getColumn($relname)
201 201
                 ) {
202
-                    $relname = $orig . '_' . (++ $cntr);
202
+                    $relname = $orig.'_'.(++$cntr);
203 203
                 }
204 204
                 $definition->addRelation(
205 205
                     new TableRelation(
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
                 "SELECT tbl_name
221 221
                  FROM sqlite_schema
222 222
                  WHERE (type = ? OR type = ?) AND tbl_name NOT LIKE 'sqlite_%';",
223
-                [ 'table', 'view' ]
223
+                ['table', 'view']
224 224
             ))
225
-            ->mapKey(function ($v) {
225
+            ->mapKey(function($v) {
226 226
                 return strtolower($v['tbl_name']);
227 227
             })
228 228
             ->pluck('tbl_name')
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
             $tables[$k] = $this->table($v, true, array_keys($tables))->toLowerCase();
232 232
         }
233 233
         foreach (array_keys($tables) as $k) {
234
-            $tables[($this->connection['opts']['schema'] ?? 'main') . '.' . $k] = &$tables[$k];
234
+            $tables[($this->connection['opts']['schema'] ?? 'main').'.'.$k] = &$tables[$k];
235 235
         }
236 236
         return $tables;
237 237
     }
Please login to merge, or discard this patch.
src/driver/postgre/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;
@@ -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,20 +127,20 @@  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
                 return $v;
134 134
             })
135 135
             ->toArray();
136 136
         if (!count($columns)) {
137
-            throw new DBException('Table not found by name: ' . implode('.', [$schema,$table]));
137
+            throw new DBException('Table not found by name: '.implode('.', [$schema, $table]));
138 138
         }
139 139
         $pkname = Collection::from($this
140 140
             ->query(
141 141
                 "SELECT constraint_name FROM information_schema.table_constraints
142 142
                 WHERE table_name = ? AND constraint_type = ? AND table_schema = ? AND table_catalog = ?",
143
-                [ $table, 'PRIMARY KEY', $schema, $catalog ]
143
+                [$table, 'PRIMARY KEY', $schema, $catalog]
144 144
             ))
145 145
             ->pluck('constraint_name')
146 146
             ->value();
@@ -150,12 +150,12 @@  discard block
 block discarded – undo
150 150
                 ->query(
151 151
                     "SELECT column_name FROM information_schema.constraint_column_usage
152 152
                      WHERE table_name = ? AND constraint_name = ? AND table_schema = ? AND table_catalog = ?",
153
-                    [ $table, $pkname, $schema, $catalog ]
153
+                    [$table, $pkname, $schema, $catalog]
154 154
                 ))
155 155
                 ->pluck('column_name')
156 156
                 ->toArray();
157 157
         }
158
-        $tables[$schema . '.' .$table] = $definition = (new Table($table, $schema))
158
+        $tables[$schema.'.'.$table] = $definition = (new Table($table, $schema))
159 159
             ->addColumns($columns)
160 160
             ->setPrimaryKey($primary)
161 161
             ->setComment('');
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
             // assuming current table is on the "one" end having "many" records in the referencing table
166 166
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
167 167
             $relations = [];
168
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) {
169
-                $relations[$relation['constraint_name']]['table'] = $relation['table_schema'] . '.' .
168
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) {
169
+                $relations[$relation['constraint_name']]['table'] = $relation['table_schema'].'.'.
170 170
                     $relation['table_name'];
171 171
                 $relations[$relation['constraint_name']]['keymap'][$relation['referenced_column_name']] =
172 172
                     $relation['column_name'];
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
                 $usedcol = [];
184 184
                 if (count($columns)) {
185 185
                     foreach (Collection::from($relationsT[$data['table']] ?? [])
186
-                        ->filter(function ($v) use ($columns) {
186
+                        ->filter(function($v) use ($columns) {
187 187
                             return in_array($v['column_name'], $columns);
188 188
                         }) as $relation
189 189
                     ) {
190
-                        $foreign[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'] . '.' .
190
+                        $foreign[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'].'.'.
191 191
                             $relation['referenced_table_name'];
192 192
                         $foreign[$relation['constraint_name']]['keymap'][$relation['column_name']] =
193 193
                             $relation['referenced_column_name'];
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
                         $definition->getName() == $relname ||
208 208
                         $definition->getColumn($relname)
209 209
                     ) {
210
-                        $relname = $orig . '_' . (++ $cntr);
210
+                        $relname = $orig.'_'.(++$cntr);
211 211
                     }
212 212
                     $definition->addRelation(
213 213
                         new TableRelation(
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
                         $definition->getName() == $relname ||
232 232
                         $definition->getColumn($relname)
233 233
                     ) {
234
-                        $relname = $orig . '_' . (++ $cntr);
234
+                        $relname = $orig.'_'.(++$cntr);
235 235
                     }
236 236
                     $definition->addRelation(
237 237
                         new TableRelation(
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
             // assuming current table is linked to "one" record in the referenced table
248 248
             // resulting in a "belongsTo" relationship
249 249
             $relations = [];
250
-            foreach ($relationsT[$schema . '.' . $table] ?? [] as $relation) {
251
-                $relations[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'] . '.' .
250
+            foreach ($relationsT[$schema.'.'.$table] ?? [] as $relation) {
251
+                $relations[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'].'.'.
252 252
                     $relation['referenced_table_name'];
253 253
                 $relations[$relation['constraint_name']]['keymap'][$relation['column_name']] =
254 254
                     $relation['referenced_column_name'];
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
                     $definition->getName() == $relname ||
266 266
                     $definition->getColumn($relname)
267 267
                 ) {
268
-                    $relname = $orig . '_' . (++ $cntr);
268
+                    $relname = $orig.'_'.(++$cntr);
269 269
                 }
270 270
                 $definition->addRelation(
271 271
                     new TableRelation(
@@ -284,19 +284,19 @@  discard block
 block discarded – undo
284 284
         $tables = Collection::from($this
285 285
             ->query(
286 286
                 "SELECT table_name FROM information_schema.tables where table_schema = ? AND table_catalog = ?",
287
-                [ $this->connection['opts']['schema'] ?? 'public', $this->connection['name'] ]
287
+                [$this->connection['opts']['schema'] ?? 'public', $this->connection['name']]
288 288
             ))
289
-            ->mapKey(function ($v) {
289
+            ->mapKey(function($v) {
290 290
                 return strtolower($v['table_name']);
291 291
             })
292 292
             ->pluck('table_name')
293
-            ->map(function ($v) {
293
+            ->map(function($v) {
294 294
                 return $this->table($v)->toLowerCase();
295 295
             })
296 296
             ->toArray();
297 297
 
298 298
         foreach (array_keys($tables) as $k) {
299
-            $tables[($this->connection['opts']['schema'] ?? 'public') . '.' . $k] = &$tables[$k];
299
+            $tables[($this->connection['opts']['schema'] ?? 'public').'.'.$k] = &$tables[$k];
300 300
         }
301 301
         return $tables;
302 302
     }
Please login to merge, or discard this patch.