Completed
Push — master ( 432e88...763477 )
by Ivan
23:15 queued 08:19
created
src/driver/oracle/Result.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     }
25 25
     public function affected() : int
26 26
     {
27
-        return (int)\oci_num_rows($this->statement);
27
+        return (int) \oci_num_rows($this->statement);
28 28
     }
29 29
     public function insertID(string $sequence = null): mixed
30 30
     {
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
     public function count(): int
39 39
     {
40
-        return (int)\oci_num_rows($this->statement);
40
+        return (int) \oci_num_rows($this->statement);
41 41
     }
42 42
 
43 43
     public function key(): mixed
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
     }
66 66
     public function next(): void
67 67
     {
68
-        $this->fetched ++;
69
-        $this->last = \oci_fetch_array($this->statement, \OCI_ASSOC + \OCI_RETURN_NULLS + \OCI_RETURN_LOBS)?:null;
68
+        $this->fetched++;
69
+        $this->last = \oci_fetch_array($this->statement, \OCI_ASSOC +\OCI_RETURN_NULLS +\OCI_RETURN_LOBS) ?: null;
70 70
         if (is_array($this->last)) {
71 71
             $this->cast();
72 72
         }
@@ -78,23 +78,23 @@  discard block
 block discarded – undo
78 78
     protected function cast(): void
79 79
     {
80 80
         if (!count($this->types)) {
81
-            foreach (array_keys($this->last??[]) as $k => $v) {
81
+            foreach (array_keys($this->last ?? []) as $k => $v) {
82 82
                 $this->types[$v] = \oci_field_type($this->statement, $k + 1);
83 83
                 if ($this->types[$v] === 'NUMBER') {
84 84
                     $scale = \oci_field_scale($this->statement, $k + 1);
85 85
                     $precision = \oci_field_precision($this->statement, $k + 1);
86 86
                     // true float
87
-                    if ((int)$scale === -127 && (int)$precision !== 0) {
87
+                    if ((int) $scale === -127 && (int) $precision !== 0) {
88 88
                         $this->types[$v] = 'FLOAT';
89 89
                     }
90 90
                     // TODO: decimal
91
-                    if ((int)$scale > 0) {
91
+                    if ((int) $scale > 0) {
92 92
                         $this->types[$v] = 'DECIMAL';
93 93
                     }
94 94
                 }
95 95
             }
96 96
         }
97
-        foreach ($this->last??[] as $k => $v) {
97
+        foreach ($this->last ?? [] as $k => $v) {
98 98
             if (!isset($this->types[$k])) {
99 99
                 continue;
100 100
             }
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
             }
110 110
             switch ($this->types[$k]) {
111 111
                 case 'NUMBER':
112
-                    $this->last[$k] = (int)$v;
112
+                    $this->last[$k] = (int) $v;
113 113
                     break;
114 114
                 case 'FLOAT':
115
-                    $this->last[$k] = (float)$v;
115
+                    $this->last[$k] = (float) $v;
116 116
                     break;
117 117
             }
118 118
         }
Please login to merge, or discard this patch.
src/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
         }
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
             ->query(
112 112
                 "SELECT * FROM information_schema.columns
113 113
                  WHERE table_name = ? AND table_schema = ? AND table_catalog = ?",
114
-                [ $table, $schema, $catalog ]
114
+                [$table, $schema, $catalog]
115 115
             ))
116
-            ->mapKey(function ($v) {
116
+            ->mapKey(function($v) {
117 117
                 return $v['column_name'];
118 118
             })
119
-            ->map(function ($v) {
119
+            ->map(function($v) {
120 120
                 $v['length'] = null;
121 121
                 if (!isset($v['data_type'])) {
122 122
                     return $v;
@@ -124,20 +124,20 @@  discard block
 block discarded – undo
124 124
                 switch ($v['data_type']) {
125 125
                     case 'character':
126 126
                     case 'character varying':
127
-                        $v['length'] = (int)$v['character_maximum_length'];
127
+                        $v['length'] = (int) $v['character_maximum_length'];
128 128
                         break;
129 129
                 }
130 130
                 return $v;
131 131
             })
132 132
             ->toArray();
133 133
         if (!count($columns)) {
134
-            throw new DBException('Table not found by name: ' . implode('.', [$schema,$table]));
134
+            throw new DBException('Table not found by name: '.implode('.', [$schema, $table]));
135 135
         }
136 136
         $pkname = Collection::from($this
137 137
             ->query(
138 138
                 "SELECT constraint_name FROM information_schema.table_constraints
139 139
                 WHERE table_name = ? AND constraint_type = ? AND table_schema = ? AND table_catalog = ?",
140
-                [ $table, 'PRIMARY KEY', $schema, $catalog ]
140
+                [$table, 'PRIMARY KEY', $schema, $catalog]
141 141
             ))
142 142
             ->pluck('constraint_name')
143 143
             ->value();
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
                 ->query(
148 148
                     "SELECT column_name FROM information_schema.constraint_column_usage
149 149
                      WHERE table_name = ? AND constraint_name = ? AND table_schema = ? AND table_catalog = ?",
150
-                    [ $table, $pkname, $schema, $catalog ]
150
+                    [$table, $pkname, $schema, $catalog]
151 151
                 ))
152 152
                 ->pluck('column_name')
153 153
                 ->toArray();
154 154
         }
155
-        $tables[$schema . '.' .$table] = $definition = (new Table($table, $schema))
155
+        $tables[$schema.'.'.$table] = $definition = (new Table($table, $schema))
156 156
             ->addColumns($columns)
157 157
             ->setPrimaryKey($primary)
158 158
             ->setComment('');
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
             // assuming current table is on the "one" end having "many" records in the referencing table
163 163
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
164 164
             $relations = [];
165
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) {
166
-                $relations[$relation['constraint_name']]['table'] = $relation['table_schema'] . '.' .
165
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) {
166
+                $relations[$relation['constraint_name']]['table'] = $relation['table_schema'].'.'.
167 167
                     $relation['table_name'];
168 168
                 $relations[$relation['constraint_name']]['keymap'][$relation['referenced_column_name']] =
169 169
                     $relation['column_name'];
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
                 $usedcol = [];
181 181
                 if (count($columns)) {
182 182
                     foreach (Collection::from($relationsT[$data['table']] ?? [])
183
-                        ->filter(function ($v) use ($columns) {
183
+                        ->filter(function($v) use ($columns) {
184 184
                             return in_array($v['column_name'], $columns);
185 185
                         }) as $relation
186 186
                     ) {
187
-                        $foreign[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'] . '.' .
187
+                        $foreign[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'].'.'.
188 188
                             $relation['referenced_table_name'];
189 189
                         $foreign[$relation['constraint_name']]['keymap'][$relation['column_name']] =
190 190
                             $relation['referenced_column_name'];
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
                         $definition->getName() == $relname ||
205 205
                         $definition->getColumn($relname)
206 206
                     ) {
207
-                        $relname = $orig . '_' . (++ $cntr);
207
+                        $relname = $orig.'_'.(++$cntr);
208 208
                     }
209 209
                     $definition->addRelation(
210 210
                         new TableRelation(
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
                         $definition->getName() == $relname ||
229 229
                         $definition->getColumn($relname)
230 230
                     ) {
231
-                        $relname = $orig . '_' . (++ $cntr);
231
+                        $relname = $orig.'_'.(++$cntr);
232 232
                     }
233 233
                     $definition->addRelation(
234 234
                         new TableRelation(
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
             // assuming current table is linked to "one" record in the referenced table
245 245
             // resulting in a "belongsTo" relationship
246 246
             $relations = [];
247
-            foreach ($relationsT[$schema . '.' . $table] ?? [] as $relation) {
248
-                $relations[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'] . '.' .
247
+            foreach ($relationsT[$schema.'.'.$table] ?? [] as $relation) {
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'];
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
                     $definition->getName() == $relname ||
263 263
                     $definition->getColumn($relname)
264 264
                 ) {
265
-                    $relname = $orig . '_' . (++ $cntr);
265
+                    $relname = $orig.'_'.(++$cntr);
266 266
                 }
267 267
                 $definition->addRelation(
268 268
                     new TableRelation(
@@ -281,19 +281,19 @@  discard block
 block discarded – undo
281 281
         $tables = Collection::from($this
282 282
             ->query(
283 283
                 "SELECT table_name FROM information_schema.tables where table_schema = ? AND table_catalog = ?",
284
-                [ $this->connection['opts']['schema'] ?? 'public', $this->connection['name'] ]
284
+                [$this->connection['opts']['schema'] ?? 'public', $this->connection['name']]
285 285
             ))
286
-            ->mapKey(function ($v) {
286
+            ->mapKey(function($v) {
287 287
                 return strtolower($v['table_name']);
288 288
             })
289 289
             ->pluck('table_name')
290
-            ->map(function ($v) {
290
+            ->map(function($v) {
291 291
                 return $this->table($v)->toLowerCase();
292 292
             })
293 293
             ->toArray();
294 294
 
295 295
         foreach (array_keys($tables) as $k) {
296
-            $tables[($this->connection['opts']['schema'] ?? 'public') . '.' . $k] = &$tables[$k];
296
+            $tables[($this->connection['opts']['schema'] ?? 'public').'.'.$k] = &$tables[$k];
297 297
         }
298 298
         return $tables;
299 299
     }
Please login to merge, or discard this patch.
src/driver/postgre/Driver.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
             if (isset($this->connection['opts']['search_path'])) {
46 46
                 @\pg_query(
47 47
                     $this->lnk,
48
-                    "SET search_path TO " . pg_escape_string($this->connection['opts']['search_path'])
48
+                    "SET search_path TO ".pg_escape_string($this->connection['opts']['search_path'])
49 49
                 );
50 50
             }
51 51
             if (!isset($this->connection['opts']['search_path']) && isset($this->connection['opts']['schema'])) {
52
-                @\pg_query($this->lnk, "SET search_path TO " . pg_escape_string($this->connection['opts']['schema']));
52
+                @\pg_query($this->lnk, "SET search_path TO ".pg_escape_string($this->connection['opts']['schema']));
53 53
             }
54 54
             if (isset($this->connection['opts']['timezone'])) {
55 55
                 @\pg_query($this->lnk, "SET TIME ZONE '".pg_escape_string($this->connection['opts']['timezone'])."'");
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
         $res = \pg_query($this->lnk, $sql);
88 88
         if ($log) {
89 89
             $tm = microtime(true) - $tm;
90
-            if ($tm >= (float)$this->option('log_slow', 0)) {
90
+            if ($tm >= (float) $this->option('log_slow', 0)) {
91 91
                 @file_put_contents(
92 92
                     $log,
93
-                    '--' . date('Y-m-d H:i:s') . ' ' . sprintf('%01.6f', $tm) . "s\r\n" .
94
-                    $sql . "\r\n" .
93
+                    '--'.date('Y-m-d H:i:s').' '.sprintf('%01.6f', $tm)."s\r\n".
94
+                    $sql."\r\n".
95 95
                     "\r\n",
96 96
                     FILE_APPEND
97 97
                 );
Please login to merge, or discard this patch.
src/driver/postgre/Result.php 1 patch
Spacing   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@  discard block
 block discarded – undo
37 37
             $temp = @\pg_query(
38 38
                 $this->driver,
39 39
                 $sequence ?
40
-                    'SELECT currval('.@\pg_escape_string($this->driver, $sequence).')' :
41
-                    'SELECT lastval()'
40
+                    'SELECT currval('.@\pg_escape_string($this->driver, $sequence).')' : 'SELECT lastval()'
42 41
             );
43 42
             if ($temp) {
44 43
                 $res = \pg_fetch_row($temp);
@@ -76,8 +75,8 @@  discard block
 block discarded – undo
76 75
     }
77 76
     public function next(): void
78 77
     {
79
-        $this->fetched ++;
80
-        $this->last = \pg_fetch_array($this->statement, null, \PGSQL_ASSOC)?:null;
78
+        $this->fetched++;
79
+        $this->last = \pg_fetch_array($this->statement, null, \PGSQL_ASSOC) ?: null;
81 80
         if (is_array($this->last)) {
82 81
             $this->cast();
83 82
         }
@@ -90,11 +89,11 @@  discard block
 block discarded – undo
90 89
     protected function cast(): void
91 90
     {
92 91
         if (!count($this->types)) {
93
-            foreach (array_keys($this->last??[]) as $k => $v) {
92
+            foreach (array_keys($this->last ?? []) as $k => $v) {
94 93
                 $this->types[$v] = \pg_field_type($this->statement, $k);
95 94
             }
96 95
         }
97
-        foreach ($this->last??[] as $k => $v) {
96
+        foreach ($this->last ?? [] as $k => $v) {
98 97
             if (is_null($v) || !isset($this->types[$k])) {
99 98
                 continue;
100 99
             }
@@ -102,15 +101,15 @@  discard block
 block discarded – undo
102 101
                 case 'int2':
103 102
                 case 'int4':
104 103
                 case 'int8':
105
-                    $this->last[$k] = (int)$v;
104
+                    $this->last[$k] = (int) $v;
106 105
                     break;
107 106
                 case 'bit':
108 107
                 case 'bool':
109
-                    $this->last[$k] = $v !== 'f' && (int)$v ? true : false;
108
+                    $this->last[$k] = $v !== 'f' && (int) $v ? true : false;
110 109
                     break;
111 110
                 case 'float4':
112 111
                 case 'float8':
113
-                    $this->last[$k] = (float)$v;
112
+                    $this->last[$k] = (float) $v;
114 113
                     break;
115 114
                 case 'money':
116 115
                 case 'numeric':
Please login to merge, or discard this patch.
src/driver/mysql/Schema.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
             $table = $temp[1];
28 28
         }
29 29
 
30
-        if (isset($tables[$schema . '.' . $table])) {
31
-            return $tables[$schema . '.' . $table];
30
+        if (isset($tables[$schema.'.'.$table])) {
31
+            return $tables[$schema.'.'.$table];
32 32
         }
33 33
 
34 34
         static $comments = [];
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
             $comments[$schema] = Collection::from(
37 37
                 $this->query(
38 38
                     "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ?",
39
-                    [ $schema ]
39
+                    [$schema]
40 40
                 )
41 41
             )
42
-            ->mapKey(function (array $v): string {
42
+            ->mapKey(function(array $v): string {
43 43
                 return $v['TABLE_NAME'];
44 44
             })
45 45
             ->pluck('TABLE_COMMENT')
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
                      WHERE
62 62
                         (TABLE_SCHEMA = ? OR REFERENCED_TABLE_SCHEMA = ?) AND
63 63
                         TABLE_NAME IS NOT NULL AND REFERENCED_TABLE_NAME IS NOT NULL",
64
-                    [ $main, $main ]
64
+                    [$main, $main]
65 65
                 )
66 66
             )->toArray();
67 67
             foreach ($col as $row) {
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
                 if ($row['REFERENCED_TABLE_SCHEMA'] !== $main) {
72 72
                     $additional[] = $row['REFERENCED_TABLE_SCHEMA'];
73 73
                 }
74
-                $relationsT[$row['TABLE_SCHEMA'] . '.' . $row['TABLE_NAME']][] = $row;
75
-                $relationsR[$row['REFERENCED_TABLE_SCHEMA'] . '.' . $row['REFERENCED_TABLE_NAME']][] = $row;
74
+                $relationsT[$row['TABLE_SCHEMA'].'.'.$row['TABLE_NAME']][] = $row;
75
+                $relationsR[$row['REFERENCED_TABLE_SCHEMA'].'.'.$row['REFERENCED_TABLE_NAME']][] = $row;
76 76
             }
77 77
             foreach (array_filter(array_unique($additional)) as $s) {
78 78
                 $col = Collection::from(
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
                         WHERE
85 85
                             TABLE_SCHEMA = ? AND REFERENCED_TABLE_SCHEMA = ? AND
86 86
                             TABLE_NAME IS NOT NULL AND REFERENCED_TABLE_NAME IS NOT NULL",
87
-                        [ $s, $s ]
87
+                        [$s, $s]
88 88
                     )
89 89
                 )->toArray();
90 90
                 foreach ($col as $row) {
91
-                    $relationsT[$row['TABLE_SCHEMA'] . '.' . $row['TABLE_NAME']][] = $row;
92
-                    $relationsR[$row['REFERENCED_TABLE_SCHEMA'] . '.' . $row['REFERENCED_TABLE_NAME']][] = $row;
91
+                    $relationsT[$row['TABLE_SCHEMA'].'.'.$row['TABLE_NAME']][] = $row;
92
+                    $relationsR[$row['REFERENCED_TABLE_SCHEMA'].'.'.$row['REFERENCED_TABLE_NAME']][] = $row;
93 93
                 }
94 94
             }
95 95
         }
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
         if (!count($columns)) {
99 99
             throw new DBException('Table not found by name');
100 100
         }
101
-        $tables[$schema . '.' . $table] = $definition = (new Table($table, $schema))
101
+        $tables[$schema.'.'.$table] = $definition = (new Table($table, $schema))
102 102
             ->addColumns(
103 103
                 $columns
104 104
                     ->clone()
105
-                    ->mapKey(function (array $v): string {
105
+                    ->mapKey(function(array $v): string {
106 106
                         return $v['Field'];
107 107
                     })
108
-                    ->map(function (array $v): array {
108
+                    ->map(function(array $v): array {
109 109
                         $v['length'] = null;
110 110
                         if (!isset($v['Type'])) {
111 111
                             return $v;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                             default:
128 128
                                 if (strpos($type, 'char') !== false && strpos($type, '(') !== false) {
129 129
                                     // extract length from varchar
130
-                                    $v['length'] = (int)explode(')', explode('(', $type)[1])[0];
130
+                                    $v['length'] = (int) explode(')', explode('(', $type)[1])[0];
131 131
                                     $v['length'] = $v['length'] > 0 ? $v['length'] : null;
132 132
                                 }
133 133
                                 break;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
             ->setPrimaryKey(
140 140
                 $columns
141 141
                     ->clone()
142
-                    ->filter(function (array $v): bool {
142
+                    ->filter(function(array $v): bool {
143 143
                         return $v['Key'] === 'PRI';
144 144
                     })
145 145
                     ->pluck('Field')
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
             // assuming current table is on the "one" end having "many" records in the referencing table
154 154
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
155 155
             $relations = [];
156
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) {
157
-                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'] . '.' .
156
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) {
157
+                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'].'.'.
158 158
                     $relation['TABLE_NAME'];
159 159
                 $relations[$relation['CONSTRAINT_NAME']]['keymap'][$relation['REFERENCED_COLUMN_NAME']] =
160 160
                     $relation['COLUMN_NAME'];
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
                 $usedcol = [];
172 172
                 if (count($columns)) {
173 173
                     foreach (Collection::from($relationsT[$data['table']] ?? [])
174
-                        ->filter(function (array $v) use ($columns): bool {
174
+                        ->filter(function(array $v) use ($columns): bool {
175 175
                             return in_array($v['COLUMN_NAME'], $columns);
176 176
                         })
177
-                        ->map(function (array $v): array {
177
+                        ->map(function(array $v): array {
178 178
                             $new = [];
179 179
                             foreach ($v as $kk => $vv) {
180 180
                                 $new[strtoupper($kk)] = $vv;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
                             return $new;
183 183
                         }) as $relation
184 184
                     ) {
185
-                        $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'] . '.' .
185
+                        $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'].'.'.
186 186
                             $relation['REFERENCED_TABLE_NAME'];
187 187
                         $foreign[$relation['CONSTRAINT_NAME']]['keymap'][$relation['COLUMN_NAME']] =
188 188
                             $relation['REFERENCED_COLUMN_NAME'];
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
                     $orig = $relname;
200 200
                     $cntr = 1;
201 201
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
202
-                        $relname = $orig . '_' . (++ $cntr);
202
+                        $relname = $orig.'_'.(++$cntr);
203 203
                     }
204 204
                     $definition->addRelation(
205 205
                         new TableRelation(
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
                     $orig = $relname;
221 221
                     $cntr = 1;
222 222
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
223
-                        $relname = $orig . '_' . (++ $cntr);
223
+                        $relname = $orig.'_'.(++$cntr);
224 224
                     }
225 225
                     $definition->addRelation(
226 226
                         new TableRelation(
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
             // assuming current table is linked to "one" record in the referenced table
237 237
             // resulting in a "belongsTo" relationship
238 238
             $relations = [];
239
-            foreach (Collection::from($relationsT[$schema . '.' . $table] ?? [])
240
-                ->map(function (array $v): array {
239
+            foreach (Collection::from($relationsT[$schema.'.'.$table] ?? [])
240
+                ->map(function(array $v): array {
241 241
                     $new = [];
242 242
                     foreach ($v as $kk => $vv) {
243 243
                         $new[strtoupper($kk)] = $vv;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                     return $new;
246 246
                 }) as $relation
247 247
             ) {
248
-                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'] . '.' .
248
+                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'].'.'.
249 249
                     $relation['REFERENCED_TABLE_NAME'];
250 250
                 $relations[$relation['CONSTRAINT_NAME']]['keymap'][$relation['COLUMN_NAME']] =
251 251
                     $relation['REFERENCED_COLUMN_NAME'];
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
                 $orig = $relname;
260 260
                 $cntr = 1;
261 261
                 while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
262
-                    $relname = $orig . '_' . (++ $cntr);
262
+                    $relname = $orig.'_'.(++$cntr);
263 263
                 }
264 264
                 $definition->addRelation(
265 265
                     new TableRelation(
@@ -280,23 +280,23 @@  discard block
 block discarded – undo
280 280
                 "SELECT table_name FROM information_schema.tables where table_schema = ?",
281 281
                 [$this->connection['opts']['schema'] ?? $this->connection['name']]
282 282
             ))
283
-            ->map(function (array $v): array {
283
+            ->map(function(array $v): array {
284 284
                 $new = [];
285 285
                 foreach ($v as $kk => $vv) {
286 286
                     $new[strtoupper($kk)] = $vv;
287 287
                 }
288 288
                 return $new;
289 289
             })
290
-            ->mapKey(function (array $v): string {
290
+            ->mapKey(function(array $v): string {
291 291
                 return strtolower($v['TABLE_NAME']);
292 292
             })
293 293
             ->pluck('TABLE_NAME')
294
-            ->map(function (string $v): Table {
294
+            ->map(function(string $v): Table {
295 295
                 return $this->table($v)->toLowerCase();
296 296
             })
297 297
             ->toArray();
298 298
         foreach (array_keys($tables) as $k) {
299
-            $tables[($this->connection['opts']['schema'] ?? $this->connection['name']) . '.' . $k] = &$tables[$k];
299
+            $tables[($this->connection['opts']['schema'] ?? $this->connection['name']).'.'.$k] = &$tables[$k];
300 300
         }
301 301
         return $tables;
302 302
     }
Please login to merge, or discard this patch.
src/schema/Mapper.php 1 patch
Spacing   +7 added lines, -8 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     public function collection(TableQueryIterator $iterator, Table $definition) : Collection
53 53
     {
54 54
         return Collection::from($iterator)
55
-            ->map(function ($v) use ($definition) {
55
+            ->map(function($v) use ($definition) {
56 56
                 return $this->entity($definition, $v);
57 57
             });
58 58
     }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         $definition = $entity->definition();
137 137
         foreach ($definition->getColumns() as $column) {
138 138
             if (!array_key_exists($column, $data)) {
139
-                $entity->__lazyProperty($column, function () use ($definition, $primary, $column) {
139
+                $entity->__lazyProperty($column, function() use ($definition, $primary, $column) {
140 140
                     $query = $this->db->table($definition->getFullName());
141 141
                     foreach ($primary as $k => $v) {
142 142
                         $query->filter($k, $v);
@@ -150,12 +150,12 @@  discard block
 block discarded – undo
150 150
                 $name,
151 151
                 array_key_exists($name, $data) && isset($data[$name]) ?
152 152
                     ($relation->many ?
153
-                        array_map(function ($v) use ($relation) {
153
+                        array_map(function($v) use ($relation) {
154 154
                             return $this->entity($relation->table, $v);
155 155
                         }, $data[$name]) :
156 156
                         $this->entity($relation->table, $data[$name])
157 157
                     ) :
158
-                    function (
158
+                    function(
159 159
                         array $columns = null,
160 160
                         string $order = null,
161 161
                         bool $desc = false
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
                             $query->columns($columns);
171 171
                         }
172 172
                         if ($relation->sql) {
173
-                            $query->where($relation->sql, $relation->par?:[]);
173
+                            $query->where($relation->sql, $relation->par ?: []);
174 174
                         }
175 175
                         if ($relation->pivot) {
176 176
                             $nm = null;
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
                                 );
191 191
                             }
192 192
                             foreach ($definition->getPrimaryKey() as $v) {
193
-                                $query->filter($nm . '.' . $v, $data[$v] ?? null);
193
+                                $query->filter($nm.'.'.$v, $data[$v] ?? null);
194 194
                             }
195 195
                         } else {
196 196
                             foreach ($relation->keymap as $k => $v) {
@@ -201,8 +201,7 @@  discard block
 block discarded – undo
201 201
                             $query->sort($order, $desc);
202 202
                         }
203 203
                         return $relation->many ?
204
-                            $query->iterator() :
205
-                            $query[0];
204
+                            $query->iterator() : $query[0];
206 205
                     }
207 206
             );
208 207
         }
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/DB.php 1 patch
Spacing   +22 added lines, -24 removed lines patch added patch discarded remove patch
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
                 ];
64 64
             }
65 65
         }
66
-        $connection['type'] = isset($temp['scheme']) && strlen((string)$temp['scheme']) ? $temp['scheme'] : null;
67
-        $connection['user'] = isset($temp['user']) && strlen((string)$temp['user']) ? $temp['user'] : null;
68
-        $connection['pass'] = isset($temp['pass']) && strlen((string)$temp['pass']) ? $temp['pass'] : null;
69
-        $connection['host'] = isset($temp['host']) && strlen((string)$temp['host']) ? $temp['host'] : null;
70
-        $connection['name'] = isset($temp['path']) && strlen((string)$temp['path']) ?
71
-            trim((string)$temp['path'], '/') : null;
72
-        $connection['port'] = isset($temp['port']) && (int)$temp['port'] ? (int)$temp['port'] : null;
73
-        if (isset($temp['query']) && strlen((string)$temp['query'])) {
74
-            parse_str((string)$temp['query'], $connection['opts']);
66
+        $connection['type'] = isset($temp['scheme']) && strlen((string) $temp['scheme']) ? $temp['scheme'] : null;
67
+        $connection['user'] = isset($temp['user']) && strlen((string) $temp['user']) ? $temp['user'] : null;
68
+        $connection['pass'] = isset($temp['pass']) && strlen((string) $temp['pass']) ? $temp['pass'] : null;
69
+        $connection['host'] = isset($temp['host']) && strlen((string) $temp['host']) ? $temp['host'] : null;
70
+        $connection['name'] = isset($temp['path']) && strlen((string) $temp['path']) ?
71
+            trim((string) $temp['path'], '/') : null;
72
+        $connection['port'] = isset($temp['port']) && (int) $temp['port'] ? (int) $temp['port'] : null;
73
+        if (isset($temp['query']) && strlen((string) $temp['query'])) {
74
+            parse_str((string) $temp['query'], $connection['opts']);
75 75
         }
76 76
         // create the driver
77 77
         $connection['type'] = $aliases[$connection['type']] ?? $connection['type'];
78
-        $tmp = '\\vakata\\database\\driver\\'.strtolower((string)$connection['type']).'\\Driver';
78
+        $tmp = '\\vakata\\database\\driver\\'.strtolower((string) $connection['type']).'\\Driver';
79 79
         if (!class_exists($tmp)) {
80 80
             throw new DBException('Unknown DB backend');
81 81
         }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         $new = '';
114 114
         $par = array_values($par);
115 115
         if (substr_count($sql, '?') === 2 && !is_array($par[0])) {
116
-            $par = [ $par ];
116
+            $par = [$par];
117 117
         }
118 118
         $parts = explode('??', $sql);
119 119
         $index = 0;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
             $index += count($tmp) - 1;
124 124
             if (isset($par[$index])) {
125 125
                 if (!is_array($par[$index])) {
126
-                    $par[$index] = [ $par[$index] ];
126
+                    $par[$index] = [$par[$index]];
127 127
                 }
128 128
                 $params = $par[$index];
129 129
                 array_splice($par, $index, 1, $params);
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
                 $new .= implode(',', array_fill(0, count($params), '?'));
132 132
             }
133 133
         }
134
-        return [ $new, $par ];
134
+        return [$new, $par];
135 135
     }
136 136
     /**
137 137
      * Run a query (prepare & execute).
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
     ): Collection {
181 181
         $coll = Collection::from($this->query($sql, $par, $buff));
182 182
         if (($keys = $this->driver->option('mode')) && in_array($keys, ['strtoupper', 'strtolower'])) {
183
-            $coll->map(function ($v) use ($keys) {
183
+            $coll->map(function($v) use ($keys) {
184 184
                 $new = [];
185 185
                 foreach ($v as $k => $vv) {
186 186
                     $new[call_user_func($keys, $k)] = $vv;
@@ -189,18 +189,18 @@  discard block
 block discarded – undo
189 189
             });
190 190
         }
191 191
         if ($key !== null) {
192
-            $coll->mapKey(function ($v) use ($key) {
192
+            $coll->mapKey(function($v) use ($key) {
193 193
                 return $v[$key];
194 194
             });
195 195
         }
196 196
         if ($skip) {
197
-            $coll->map(function ($v) use ($key) {
197
+            $coll->map(function($v) use ($key) {
198 198
                 unset($v[$key]);
199 199
                 return $v;
200 200
             });
201 201
         }
202 202
         if ($opti) {
203
-            $coll->map(function ($v) {
203
+            $coll->map(function($v) {
204 204
                 return count($v) === 1 ? current($v) : $v;
205 205
             });
206 206
         }
@@ -309,8 +309,7 @@  discard block
 block discarded – undo
309 309
     public function definition(string $table, bool $detectRelations = true) : Table
310 310
     {
311 311
         return isset($this->schema) ?
312
-            $this->schema->getTable($table) :
313
-            $this->driver->table($table, $detectRelations);
312
+            $this->schema->getTable($table) : $this->driver->table($table, $detectRelations);
314 313
     }
315 314
 
316 315
     public function hasSchema(): bool
@@ -359,11 +358,10 @@  discard block
 block discarded – undo
359 358
     {
360 359
         return new TableQueryMapped($this, $this->definition($table), $findRelations);
361 360
     }
362
-    public function __call(string $method, array $args): TableQuery|TableQueryMapped
361
+    public function __call(string $method, array $args): TableQuery | TableQueryMapped
363 362
     {
364 363
         return ($args[0] ?? false) ?
365
-            $this->tableMapped($method, $args[1] ?? false) :
366
-            $this->table($method, $args[1] ?? false);
364
+            $this->tableMapped($method, $args[1] ?? false) : $this->table($method, $args[1] ?? false);
367 365
     }
368 366
     public function findRelation(string $start, string $end): array
369 367
     {
@@ -399,12 +397,12 @@  discard block
 block discarded – undo
399 397
                     $relations[$t] = $w;
400 398
                 }
401 399
                 if (!isset($schema[$name])) {
402
-                    $schema[$name] = [ 'edges' => [] ];
400
+                    $schema[$name] = ['edges' => []];
403 401
                 }
404 402
                 foreach ($relations as $t => $w) {
405 403
                     $schema[$name]['edges'][$t] = $w;
406 404
                     if (!isset($schema[$t])) {
407
-                        $schema[$t] = [ 'edges' => [] ];
405
+                        $schema[$t] = ['edges' => []];
408 406
                     }
409 407
                     $schema[$t]['edges'][$name] = $w;
410 408
                 }
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.