Completed
Push — master ( 0c3707...a98725 )
by Ivan
02:20
created
src/driver/pdo/Result.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
     }
56 56
     public function next()
57 57
     {
58
-        $this->fetched ++;
58
+        $this->fetched++;
59 59
         $this->last = $this->statement->fetch(\PDO::FETCH_ASSOC);
60 60
     }
61 61
     public function valid()
Please login to merge, or discard this patch.
src/driver/pdo/Driver.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
                     isset($this->connection['opts']) ? $this->connection['opts'] : []
45 45
                 );
46 46
             } catch (\PDOException $e) {
47
-                throw new DBException('Connect error: ' . $e->getMessage());
47
+                throw new DBException('Connect error: '.$e->getMessage());
48 48
             }
49 49
         }
50 50
     }
Please login to merge, or discard this patch.
src/schema/TableColumn.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
             $instance->setDefault($data['default']);
48 48
         }
49 49
         if ($instance->getBasicType() === 'enum' && strpos($instance->getType(), 'enum(') === 0) {
50
-            $temp = array_map(function ($v) {
50
+            $temp = array_map(function($v) {
51 51
                 return str_replace("''", "'", $v);
52 52
             }, explode("','", substr($instance->getType(), 6, -2)));
53 53
             $instance->setValues($temp);
Please login to merge, or discard this patch.
src/schema/Table.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     public function setPrimaryKey($column) : Table
79 79
     {
80 80
         if (!is_array($column)) {
81
-            $column = [ $column ];
81
+            $column = [$column];
82 82
         }
83 83
         $this->data['primary'] = $column;
84 84
         return $this;
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
         }
166 166
 
167 167
         if (!isset($name)) {
168
-            $name = $toTable->getName() . '_' . implode('_', array_keys($keymap));
168
+            $name = $toTable->getName().'_'.implode('_', array_keys($keymap));
169 169
         }
170 170
         $this->addRelation(new TableRelation(
171 171
             $name,
Please login to merge, or discard this patch.
src/driver/mysql/Statement.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@
 block discarded – undo
83 83
             }
84 84
         }
85 85
         if (!$this->statement->execute()) {
86
-            throw new DBException('Prepared execute error: ' . $this->statement->error);
86
+            throw new DBException('Prepared execute error: '.$this->statement->error);
87 87
         }
88 88
         return new Result($this->statement);
89 89
     }
Please login to merge, or discard this patch.
src/DB.php 1 patch
Spacing   +13 added lines, -15 removed lines patch added patch discarded remove patch
@@ -74,8 +74,7 @@  discard block
 block discarded – undo
74 74
         }
75 75
         $connection['name'] = $connectionString;
76 76
         $connection['type'] = isset($aliases[$connection['type']]) ?
77
-            $aliases[$connection['type']] :
78
-            $connection['type'];
77
+            $aliases[$connection['type']] : $connection['type'];
79 78
         $tmp = '\\vakata\\database\\driver\\'.strtolower($connection['type']).'\\Driver';
80 79
         return new $tmp($connection);
81 80
     }
@@ -95,7 +94,7 @@  discard block
 block discarded – undo
95 94
         $new = '';
96 95
         $par = array_values($par);
97 96
         if (substr_count($sql, '?') === 2 && !is_array($par[0])) {
98
-            $par = [ $par ];
97
+            $par = [$par];
99 98
         }
100 99
         $parts = explode('??', $sql);
101 100
         $index = 0;
@@ -105,7 +104,7 @@  discard block
 block discarded – undo
105 104
             $index += count($tmp) - 1;
106 105
             if (isset($par[$index])) {
107 106
                 if (!is_array($par[$index])) {
108
-                    $par[$index] = [ $par[$index] ];
107
+                    $par[$index] = [$par[$index]];
109 108
                 }
110 109
                 $params = $par[$index];
111 110
                 array_splice($par, $index, 1, $params);
@@ -113,7 +112,7 @@  discard block
 block discarded – undo
113 112
                 $new .= implode(',', array_fill(0, count($params), '?'));
114 113
             }
115 114
         }
116
-        return [ $new, $par ];
115
+        return [$new, $par];
117 116
     }
118 117
     /**
119 118
      * Run a query (prepare & execute).
@@ -145,7 +144,7 @@  discard block
 block discarded – undo
145 144
     {
146 145
         $coll = Collection::from($this->query($sql, $par));
147 146
         if (($keys = $this->driver->option('mode')) && in_array($keys, ['strtoupper', 'strtolower'])) {
148
-            $coll->map(function ($v) use ($keys) {
147
+            $coll->map(function($v) use ($keys) {
149 148
                 $new = [];
150 149
                 foreach ($v as $k => $vv) {
151 150
                     $new[call_user_func($keys, $k)] = $vv;
@@ -154,13 +153,13 @@  discard block
 block discarded – undo
154 153
             });
155 154
         }
156 155
         if ($key !== null) {
157
-            $coll->mapKey(function ($v) use ($key) { return $v[$key]; });
156
+            $coll->mapKey(function($v) use ($key) { return $v[$key]; });
158 157
         }
159 158
         if ($skip) {
160
-            $coll->map(function ($v) use ($key) { unset($v[$key]); return $v; });
159
+            $coll->map(function($v) use ($key) { unset($v[$key]); return $v; });
161 160
         }
162 161
         if ($opti) {
163
-            $coll->map(function ($v) { return count($v) === 1 ? current($v) : $v; });
162
+            $coll->map(function($v) { return count($v) === 1 ? current($v) : $v; });
164 163
         }
165 164
         return $coll;
166 165
     }
@@ -233,8 +232,7 @@  discard block
 block discarded – undo
233 232
     public function definition(string $table, bool $detectRelations = true) : Table
234 233
     {
235 234
         return isset($this->tables[$table]) ?
236
-            $this->tables[$table] :
237
-            $this->driver->table($table, $detectRelations);
235
+            $this->tables[$table] : $this->driver->table($table, $detectRelations);
238 236
     }
239 237
     /**
240 238
      * Parse all tables from the database.
@@ -251,12 +249,12 @@  discard block
 block discarded – undo
251 249
      */
252 250
     public function getSchema($asPlainArray = true)
253 251
     {
254
-        return !$asPlainArray ? $this->tables : array_map(function ($table) {
252
+        return !$asPlainArray ? $this->tables : array_map(function($table) {
255 253
             return [
256 254
                 'name' => $table->getName(),
257 255
                 'pkey' => $table->getPrimaryKey(),
258 256
                 'comment' => $table->getComment(),
259
-                'columns' => array_map(function ($column) {
257
+                'columns' => array_map(function($column) {
260 258
                     return [
261 259
                         'name' => $column->getName(),
262 260
                         'type' => $column->getType(),
@@ -266,13 +264,13 @@  discard block
 block discarded – undo
266 264
                         'nullable' => $column->isNullable()
267 265
                     ];
268 266
                 }, $table->getFullColumns()),
269
-                'relations' => array_map(function ($rel) {
267
+                'relations' => array_map(function($rel) {
270 268
                     $relation = clone $rel;
271 269
                     $relation->table = $relation->table->getName();
272 270
                     if ($relation->pivot) {
273 271
                         $relation->pivot = $relation->pivot->getName();
274 272
                     }
275
-                    return (array)$relation;
273
+                    return (array) $relation;
276 274
                 }, $table->getRelations())
277 275
             ];
278 276
         }, $this->tables);
Please login to merge, or discard this patch.
src/schema/TableQueryIterator.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -65,27 +65,27 @@  discard block
 block discarded – undo
65 65
                 $fields = [];
66 66
                 $exists = false;
67 67
                 foreach ($relation->table->getColumns() as $column) {
68
-                    $fields[$column] = $row[$name . static::SEP . $column];
69
-                    if (!$exists && $row[$name . static::SEP . $column] !== null) {
68
+                    $fields[$column] = $row[$name.static::SEP.$column];
69
+                    if (!$exists && $row[$name.static::SEP.$column] !== null) {
70 70
                         $exists = true;
71 71
                     }
72
-                    $remove[] = $name . static::SEP . $column;
72
+                    $remove[] = $name.static::SEP.$column;
73 73
                 }
74 74
                 $temp  = &$result;
75 75
                 $parts = explode(static::SEP, $name);
76 76
                 $name  = array_pop($parts);
77 77
                 $full  = '';
78 78
                 foreach ($parts as $item) {
79
-                    $full = $full ? $full . static::SEP . $item : $item;
79
+                    $full = $full ? $full.static::SEP.$item : $item;
80 80
                     $temp = &$temp[$item];
81 81
                     $rpk = [];
82 82
                     foreach ($this->relations[$full][0]->table->getPrimaryKey() as $pkey) {
83
-                        $rpk[$pkey] = $row[$full . static::SEP . $pkey];
83
+                        $rpk[$pkey] = $row[$full.static::SEP.$pkey];
84 84
                     }
85 85
                     $temp = &$temp[json_encode($rpk)];
86 86
                 }
87 87
                 if (!isset($temp[$name])) {
88
-                    $temp[$name] = $relation->many ? [ '___clean' => true ] : null;
88
+                    $temp[$name] = $relation->many ? ['___clean' => true] : null;
89 89
                 }
90 90
                 $temp = &$temp[$name];
91 91
                 if ($exists) {
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
                 return;
145 145
             }
146 146
         }
147
-        $this->fetched ++;
147
+        $this->fetched++;
148 148
         while ($this->result->valid()) {
149 149
             $row = $this->result->current();
150 150
             $pk = [];
Please login to merge, or discard this patch.
src/driver/oracle/Driver.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -124,16 +124,16 @@  discard block
 block discarded – undo
124 124
         $columns = Collection::from($this
125 125
             ->query(
126 126
                 "SELECT * FROM all_tab_cols WHERE table_name = ? AND owner = ?",
127
-                [ strtoupper($table), $this->name() ]
127
+                [strtoupper($table), $this->name()]
128 128
             ))
129
-            ->map(function ($v) {
129
+            ->map(function($v) {
130 130
                 $new = [];
131 131
                 foreach ($v as $kk => $vv) {
132 132
                     $new[strtoupper($kk)] = $vv;
133 133
                 }
134 134
                 return $new;
135 135
             })
136
-            ->mapKey(function ($v) { return $v['COLUMN_NAME']; })
136
+            ->mapKey(function($v) { return $v['COLUMN_NAME']; })
137 137
             ->toArray();
138 138
         if (!count($columns)) {
139 139
             throw new DBException('Table not found by name');
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
             ->query(
144 144
                 "SELECT constraint_name FROM all_constraints
145 145
                 WHERE table_name = ? AND constraint_type = ? AND owner = ?",
146
-                [ strtoupper($table), 'P', $owner ]
146
+                [strtoupper($table), 'P', $owner]
147 147
             ))
148
-            ->map(function ($v) {
148
+            ->map(function($v) {
149 149
                 $new = [];
150 150
                 foreach ($v as $kk => $vv) {
151 151
                     $new[strtoupper($kk)] = $vv;
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
                 ->query(
161 161
                     "SELECT column_name FROM all_cons_columns
162 162
                     WHERE table_name = ? AND constraint_name = ? AND owner = ?",
163
-                    [ strtoupper($table), $pkname, $owner ]
163
+                    [strtoupper($table), $pkname, $owner]
164 164
                 ))
165
-                ->map(function ($v) {
165
+                ->map(function($v) {
166 166
                     $new = [];
167 167
                     foreach ($v as $kk => $vv) {
168 168
                         $new[strtoupper($kk)] = $vv;
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
                     LEFT JOIN all_cons_columns cc ON cc.OWNER = ac.OWNER AND cc.CONSTRAINT_NAME = ac.CONSTRAINT_NAME
190 190
                     WHERE ac.OWNER = ? AND ac.R_OWNER = ? AND ac.R_CONSTRAINT_NAME = ? AND ac.CONSTRAINT_TYPE = ?
191 191
                     ORDER BY cc.POSITION",
192
-                    [ $owner, $owner, $pkname, 'R' ]
192
+                    [$owner, $owner, $pkname, 'R']
193 193
                 ))
194
-                ->map(function ($v) {
194
+                ->map(function($v) {
195 195
                     $new = [];
196 196
                     foreach ($v as $kk => $vv) {
197 197
                         $new[strtoupper($kk)] = $vv;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
                  as $relation
202 202
             ) {
203 203
                 $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_NAME'];
204
-                $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int)$relation['POSITION']-1]] = $relation['COLUMN_NAME'];
204
+                $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int) $relation['POSITION'] - 1]] = $relation['COLUMN_NAME'];
205 205
             }
206 206
             foreach ($relations as $data) {
207 207
                 $rtable = $this->table($data['table'], true);
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
                                 ac.OWNER = ? AND ac.R_OWNER = ? AND ac.TABLE_NAME = ? AND ac.CONSTRAINT_TYPE = ? AND
226 226
                                 cc.COLUMN_NAME IN (??)
227 227
                             ORDER BY POSITION",
228
-                            [ $owner, $owner, $data['table'], 'R', $columns ]
228
+                            [$owner, $owner, $data['table'], 'R', $columns]
229 229
                         ))
230
-                        ->map(function ($v) {
230
+                        ->map(function($v) {
231 231
                             $new = [];
232 232
                             foreach ($v as $kk => $vv) {
233 233
                                 $new[strtoupper($kk)] = $vv;
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
                     $rcolumns = Collection::from($this
246 246
                         ->query(
247 247
                             "SELECT COLUMN_NAME FROM all_cons_columns WHERE OWNER = ? AND CONSTRAINT_NAME = ? ORDER BY POSITION",
248
-                            [ $owner, current($foreign['keymap']) ]
248
+                            [$owner, current($foreign['keymap'])]
249 249
                         ))
250
-                        ->map(function ($v) {
250
+                        ->map(function($v) {
251 251
                             $new = [];
252 252
                             foreach ($v as $kk => $vv) {
253 253
                                 $new[strtoupper($kk)] = $vv;
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
                     $relname = $foreign['table'];
263 263
                     $cntr = 1;
264 264
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
265
-                        $relname = $foreign['table'] . '_' . (++ $cntr);
265
+                        $relname = $foreign['table'].'_'.(++$cntr);
266 266
                     }
267 267
                     $definition->addRelation(
268 268
                         new TableRelation(
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
                     $relname = $data['table'];
279 279
                     $cntr = 1;
280 280
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
281
-                        $relname = $data['table'] . '_' . (++ $cntr);
281
+                        $relname = $data['table'].'_'.(++$cntr);
282 282
                     }
283 283
                     $definition->addRelation(
284 284
                         new TableRelation(
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
                     LEFT JOIN all_cons_columns cc ON cc.OWNER = ac.OWNER AND cc.CONSTRAINT_NAME = ac.CONSTRAINT_NAME
303 303
                     WHERE ac.OWNER = ? AND ac.R_OWNER = ? AND ac.TABLE_NAME = ? AND ac.CONSTRAINT_TYPE = ?
304 304
                     ORDER BY cc.POSITION",
305
-                    [ $owner, $owner, strtoupper($table), 'R' ]
305
+                    [$owner, $owner, strtoupper($table), 'R']
306 306
                 ))
307
-                ->map(function ($v) {
307
+                ->map(function($v) {
308 308
                     $new = [];
309 309
                     foreach ($v as $kk => $vv) {
310 310
                         $new[strtoupper($kk)] = $vv;
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
                 $rcolumns = Collection::from($this
321 321
                     ->query(
322 322
                         "SELECT COLUMN_NAME FROM all_cons_columns WHERE OWNER = ? AND CONSTRAINT_NAME = ? ORDER BY POSITION",
323
-                        [ $owner, current($data['keymap']) ]
323
+                        [$owner, current($data['keymap'])]
324 324
                     ))
325
-                    ->map(function ($v) {
325
+                    ->map(function($v) {
326 326
                         $new = [];
327 327
                         foreach ($v as $kk => $vv) {
328 328
                             $new[strtoupper($kk)] = $vv;
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
                 $relname = $data['table'];
338 338
                 $cntr = 1;
339 339
                 while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
340
-                    $relname = $data['table'] . '_' . (++ $cntr);
340
+                    $relname = $data['table'].'_'.(++$cntr);
341 341
                 }
342 342
                 $definition->addRelation(
343 343
                     new TableRelation(
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
                 "SELECT TABLE_NAME FROM ALL_TABLES where OWNER = ?",
359 359
                 [$this->connection['name']]
360 360
             ))
361
-            ->map(function ($v) {
361
+            ->map(function($v) {
362 362
                 $new = [];
363 363
                 foreach ($v as $kk => $vv) {
364 364
                     $new[strtoupper($kk)] = $vv;
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
                 return $new;
367 367
             })
368 368
             ->pluck('TABLE_NAME')
369
-            ->map(function ($v) {
369
+            ->map(function($v) {
370 370
                 return $this->table($v);
371 371
             })
372 372
             ->toArray();
Please login to merge, or discard this patch.
src/schema/TableQuery.php 1 patch
Spacing   +85 added lines, -88 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     /**
44 44
      * @var int[]
45 45
      */
46
-    protected $li_of = [0,0];
46
+    protected $li_of = [0, 0];
47 47
     /**
48 48
      * @var array
49 49
      */
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     public function __construct(DBInterface $db, $table)
70 70
     {
71 71
         $this->db = $db;
72
-        $this->definition = $table instanceof Table ? $table : $this->db->definition((string)$table);
72
+        $this->definition = $table instanceof Table ? $table : $this->db->definition((string) $table);
73 73
         $primary = $this->definition->getPrimaryKey();
74 74
         $columns = $this->definition->getColumns();
75 75
         $this->pkey = count($primary) ? $primary : $columns;
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     {
93 93
         $column = explode('.', $column);
94 94
         if (count($column) === 1) {
95
-            $column = [ $this->definition->getName(), $column[0] ];
95
+            $column = [$this->definition->getName(), $column[0]];
96 96
             $col = $this->definition->getColumn($column[1]);
97 97
             if (!$col) {
98 98
                 throw new DBException('Invalid column name in own table');
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
                         throw new DBException('Invalid column name in related table');
116 116
                     }
117 117
                 } else {
118
-                    throw new DBException('Invalid foreign table name: ' . implode(',', $column));
118
+                    throw new DBException('Invalid foreign table name: '.implode(',', $column));
119 119
                 }
120 120
             }
121 121
         } else {
@@ -124,15 +124,15 @@  discard block
 block discarded – undo
124 124
             $table = $this->definition;
125 125
             $table = array_reduce(
126 126
                 $column,
127
-                function ($carry, $item) use (&$table) {
127
+                function($carry, $item) use (&$table) {
128 128
                     $table = $table->getRelation($item)->table;
129 129
                     return $table;
130 130
                 }
131 131
             );
132 132
             $col = $table->getColumn($name);
133
-            $column = [ implode(static::SEP, $column), $name ];
133
+            $column = [implode(static::SEP, $column), $name];
134 134
         }
135
-        return [ 'name' => implode('.', $column), 'data' => $col ];
135
+        return ['name' => implode('.', $column), 'data' => $col];
136 136
     }
137 137
     protected function normalizeValue(TableColumn $col, $value)
138 138
     {
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
                 }
180 180
                 return $value;
181 181
             case 'int':
182
-                return (int)$value;
182
+                return (int) $value;
183 183
             default:
184 184
                 return $value;
185 185
         }
@@ -197,18 +197,16 @@  discard block
 block discarded – undo
197 197
         list($name, $column) = array_values($this->getColumn($column));
198 198
         if (is_null($value)) {
199 199
             return $negate ?
200
-                $this->where($name . ' IS NOT NULL') :
201
-                $this->where($name . ' IS NULL');
200
+                $this->where($name.' IS NOT NULL') : $this->where($name.' IS NULL');
202 201
         }
203 202
         if (!is_array($value)) {
204 203
             return $negate ?
205 204
                 $this->where(
206
-                    $name . ' <> ?',
207
-                    [ $this->normalizeValue($column, $value) ]
208
-                ) :
209
-                $this->where(
210
-                    $name . ' = ?',
211
-                    [ $this->normalizeValue($column, $value) ]
205
+                    $name.' <> ?',
206
+                    [$this->normalizeValue($column, $value)]
207
+                ) : $this->where(
208
+                    $name.' = ?',
209
+                    [$this->normalizeValue($column, $value)]
212 210
                 );
213 211
         }
214 212
         if (isset($value['beg']) && isset($value['end'])) {
@@ -219,8 +217,7 @@  discard block
 block discarded – undo
219 217
                         $this->normalizeValue($column, $value['beg']),
220 218
                         $this->normalizeValue($column, $value['end'])
221 219
                     ]
222
-                ) :
223
-                $this->where(
220
+                ) : $this->where(
224 221
                     $name.' BETWEEN ? AND ?',
225 222
                     [
226 223
                         $this->normalizeValue($column, $value['beg']),
@@ -231,38 +228,38 @@  discard block
 block discarded – undo
231 228
         if (isset($value['gt']) || isset($value['lt']) || isset($value['gte']) || isset($value['lte'])) {
232 229
             if (isset($value['gt'])) {
233 230
                 $this->where(
234
-                    $name. ' ' . ($negate ? '<=' : '>') . ' ?',
235
-                    [ $this->normalizeValue($column, $value['gt']) ]
231
+                    $name.' '.($negate ? '<=' : '>').' ?',
232
+                    [$this->normalizeValue($column, $value['gt'])]
236 233
                 );
237 234
             }
238 235
             if (isset($value['gte'])) {
239 236
                 $this->where(
240
-                    $name. ' ' . ($negate ? '<' : '>=') . ' ?',
241
-                    [ $this->normalizeValue($column, $value['gte']) ]
237
+                    $name.' '.($negate ? '<' : '>=').' ?',
238
+                    [$this->normalizeValue($column, $value['gte'])]
242 239
                 );
243 240
             }
244 241
             if (isset($value['lt'])) {
245 242
                 $this->where(
246
-                    $name. ' ' . ($negate ? '>=' : '<') . ' ?',
247
-                    [ $this->normalizeValue($column, $value['lt']) ]
243
+                    $name.' '.($negate ? '>=' : '<').' ?',
244
+                    [$this->normalizeValue($column, $value['lt'])]
248 245
                 );
249 246
             }
250 247
             if (isset($value['lte'])) {
251 248
                 $this->where(
252
-                    $name. ' ' . ($negate ? '>' : '<=') . ' ?',
253
-                    [ $this->normalizeValue($column, $value['lte']) ]
249
+                    $name.' '.($negate ? '>' : '<=').' ?',
250
+                    [$this->normalizeValue($column, $value['lte'])]
254 251
                 );
255 252
             }
256 253
             return $this;
257 254
         }
258 255
         return $negate ?
259 256
             $this->where(
260
-                $name . ' NOT IN (??)',
261
-                [ array_map(function ($v) use ($column) { return $this->normalizeValue($column, $v); }, $value) ]
257
+                $name.' NOT IN (??)',
258
+                [array_map(function($v) use ($column) { return $this->normalizeValue($column, $v); }, $value)]
262 259
             ) :
263 260
             $this->where(
264
-                $name . ' IN (??)',
265
-                [ array_map(function ($v) use ($column) { return $this->normalizeValue($column, $v); }, $value) ]
261
+                $name.' IN (??)',
262
+                [array_map(function($v) use ($column) { return $this->normalizeValue($column, $v); }, $value)]
266 263
             );
267 264
     }
268 265
     /**
@@ -273,7 +270,7 @@  discard block
 block discarded – undo
273 270
      */
274 271
     public function sort(string $column, bool $desc = false) : TableQuery
275 272
     {
276
-        return $this->order($this->getColumn($column)['name'] . ' ' . ($desc ? 'DESC' : 'ASC'));
273
+        return $this->order($this->getColumn($column)['name'].' '.($desc ? 'DESC' : 'ASC'));
277 274
     }
278 275
     /**
279 276
      * Group by a column (or columns)
@@ -283,7 +280,7 @@  discard block
 block discarded – undo
283 280
     public function group($column) : TableQuery
284 281
     {
285 282
         if (!is_array($column)) {
286
-            $column = [ $column ];
283
+            $column = [$column];
287 284
         }
288 285
         foreach ($column as $k => $v) {
289 286
             $column[$k] = $this->getColumn($v)['name'];
@@ -324,7 +321,7 @@  discard block
 block discarded – undo
324 321
         $this->withr = [];
325 322
         $this->order = [];
326 323
         $this->having = [];
327
-        $this->li_of = [0,0];
324
+        $this->li_of = [0, 0];
328 325
         $this->qiterator = null;
329 326
         return $this;
330 327
     }
@@ -337,7 +334,7 @@  discard block
 block discarded – undo
337 334
     public function groupBy(string $sql, array $params = []) : TableQuery
338 335
     {
339 336
         $this->qiterator = null;
340
-        $this->group = [ $sql, $params ];
337
+        $this->group = [$sql, $params];
341 338
         return $this;
342 339
     }
343 340
     /**
@@ -350,7 +347,7 @@  discard block
 block discarded – undo
350 347
      */
351 348
     public function join($table, array $fields, string $name = null, bool $multiple = true)
352 349
     {
353
-        $table = $table instanceof Table ? $table : $this->db->definition((string)$table);
350
+        $table = $table instanceof Table ? $table : $this->db->definition((string) $table);
354 351
         $name = $name ?? $table->getName();
355 352
         if (isset($this->joins[$name]) || $this->definition->hasRelation($name)) {
356 353
             throw new DBException('Alias / table name already in use');
@@ -359,7 +356,7 @@  discard block
 block discarded – undo
359 356
         foreach ($fields as $k => $v) {
360 357
             $k = explode('.', $k, 2);
361 358
             $k = count($k) == 2 ? $k[1] : $k[0];
362
-            $this->joins[$name]->keymap[$this->getColumn($name . '.' . $k)['name']] = $this->getColumn($v)['name'];
359
+            $this->joins[$name]->keymap[$this->getColumn($name.'.'.$k)['name']] = $this->getColumn($v)['name'];
363 360
         }
364 361
         return $this;
365 362
     }
@@ -372,7 +369,7 @@  discard block
 block discarded – undo
372 369
     public function where(string $sql, array $params = []) : TableQuery
373 370
     {
374 371
         $this->qiterator = null;
375
-        $this->where[] = [ $sql, $params ];
372
+        $this->where[] = [$sql, $params];
376 373
         return $this;
377 374
     }
378 375
     /**
@@ -384,7 +381,7 @@  discard block
 block discarded – undo
384 381
     public function having(string $sql, array $params = []) : TableQuery
385 382
     {
386 383
         $this->qiterator = null;
387
-        $this->having[] = [ $sql, $params ];
384
+        $this->having[] = [$sql, $params];
388 385
         return $this;
389 386
     }
390 387
     /**
@@ -396,7 +393,7 @@  discard block
 block discarded – undo
396 393
     public function order(string $sql, array $params = []) : TableQuery
397 394
     {
398 395
         $this->qiterator = null;
399
-        $this->order = [ $sql, $params ];
396
+        $this->order = [$sql, $params];
400 397
         return $this;
401 398
     }
402 399
     /**
@@ -408,7 +405,7 @@  discard block
 block discarded – undo
408 405
     public function limit(int $limit, int $offset = 0) : TableQuery
409 406
     {
410 407
         $this->qiterator = null;
411
-        $this->li_of = [ $limit, $offset ];
408
+        $this->li_of = [$limit, $offset];
412 409
         return $this;
413 410
     }
414 411
     /**
@@ -424,22 +421,22 @@  discard block
 block discarded – undo
424 421
         $relations = $this->withr;
425 422
         foreach ($this->definition->getRelations() as $k => $v) {
426 423
             foreach ($this->where as $vv) {
427
-                if (strpos($vv[0], $k . '.') !== false) {
428
-                    $relations[$k] = [ $v, $table ];
424
+                if (strpos($vv[0], $k.'.') !== false) {
425
+                    $relations[$k] = [$v, $table];
429 426
                 }
430 427
             }
431
-            if (isset($this->order[0]) && strpos($this->order[0], $k . '.') !== false) {
432
-                $relations[$k] = [ $v, $table ];
428
+            if (isset($this->order[0]) && strpos($this->order[0], $k.'.') !== false) {
429
+                $relations[$k] = [$v, $table];
433 430
             }
434 431
         }
435 432
 
436 433
         foreach ($this->joins as $k => $v) {
437
-            $sql .= ($v->many ? 'LEFT ' : '' ) . 'JOIN '.$v->table->getName().' '.$k.' ON ';
434
+            $sql .= ($v->many ? 'LEFT ' : '').'JOIN '.$v->table->getName().' '.$k.' ON ';
438 435
             $tmp = [];
439 436
             foreach ($v->keymap as $kk => $vv) {
440 437
                 $tmp[] = $kk.' = '.$vv;
441 438
             }
442
-            $sql .= implode(' AND ', $tmp) . ' ';
439
+            $sql .= implode(' AND ', $tmp).' ';
443 440
         }
444 441
         foreach ($relations as $k => $v) {
445 442
             $table = $v[1];
@@ -450,13 +447,13 @@  discard block
 block discarded – undo
450 447
                 foreach ($v->keymap as $kk => $vv) {
451 448
                     $tmp[] = $table.'.'.$kk.' = '.$k.'_pivot.'.$vv.' ';
452 449
                 }
453
-                $sql .= implode(' AND ', $tmp) . ' ';
450
+                $sql .= implode(' AND ', $tmp).' ';
454 451
                 $sql .= 'LEFT JOIN '.$v->table->getName().' '.$k.' ON ';
455 452
                 $tmp = [];
456 453
                 foreach ($v->pivot_keymap as $kk => $vv) {
457 454
                     $tmp[] = $k.'.'.$vv.' = '.$k.'_pivot.'.$kk.' ';
458 455
                 }
459
-                $sql .= implode(' AND ', $tmp) . ' ';
456
+                $sql .= implode(' AND ', $tmp).' ';
460 457
             } else {
461 458
                 $sql .= 'LEFT JOIN '.$v->table->getName().' '.$k.' ON ';
462 459
                 $tmp = [];
@@ -464,30 +461,30 @@  discard block
 block discarded – undo
464 461
                     $tmp[] = $table.'.'.$kk.' = '.$k.'.'.$vv.' ';
465 462
                 }
466 463
                 if ($v->sql) {
467
-                    $tmp[] = $v->sql . ' ';
464
+                    $tmp[] = $v->sql.' ';
468 465
                     $par = array_merge($par, $v->par ?? []);
469 466
                 }
470
-                $sql .= implode(' AND ', $tmp) . ' ';
467
+                $sql .= implode(' AND ', $tmp).' ';
471 468
             }
472 469
         }
473 470
         if (count($this->where)) {
474 471
             $sql .= 'WHERE ';
475 472
             $tmp = [];
476 473
             foreach ($this->where as $v) {
477
-                $tmp[] = '(' . $v[0] . ')';
474
+                $tmp[] = '('.$v[0].')';
478 475
                 $par = array_merge($par, $v[1]);
479 476
             }
480 477
             $sql .= implode(' AND ', $tmp).' ';
481 478
         }
482 479
         if (count($this->group)) {
483
-            $sql .= 'GROUP BY ' . $this->group[0] . ' ';
480
+            $sql .= 'GROUP BY '.$this->group[0].' ';
484 481
             $par = array_merge($par, $this->group[1]);
485 482
         }
486 483
         if (count($this->having)) {
487 484
             $sql .= 'HAVING ';
488 485
             $tmp = [];
489 486
             foreach ($this->having as $v) {
490
-                $tmp[] = '(' . $v[0] . ')';
487
+                $tmp[] = '('.$v[0].')';
491 488
                 $par = array_merge($par, $v[1]);
492 489
             }
493 490
             $sql .= implode(' AND ', $tmp).' ';
@@ -521,7 +518,7 @@  discard block
 block discarded – undo
521 518
                     $this->with(implode('.', $temp));
522 519
                     $table = array_reduce(
523 520
                         $temp,
524
-                        function ($carry, $item) use (&$table) {
521
+                        function($carry, $item) use (&$table) {
525 522
                             return $table->getRelation($item)->table;
526 523
                         }
527 524
                     );
@@ -530,7 +527,7 @@  discard block
 block discarded – undo
530 527
                 }
531 528
                 unset($fields[$k]);
532 529
                 foreach ($cols as $col) {
533
-                    $fields[] = $table . '.' . $col;
530
+                    $fields[] = $table.'.'.$col;
534 531
                 }
535 532
             }
536 533
         }
@@ -568,37 +565,37 @@  discard block
 block discarded – undo
568 565
         $relations = $this->withr;
569 566
         foreach ($this->definition->getRelations() as $k => $relation) {
570 567
             foreach ($this->fields as $field) {
571
-                if (strpos($field, $k . '.') === 0) {
572
-                    $relations[$k] = [ $relation, $table ];
568
+                if (strpos($field, $k.'.') === 0) {
569
+                    $relations[$k] = [$relation, $table];
573 570
                 }
574 571
             }
575 572
             foreach ($this->where as $v) {
576
-                if (strpos($v[0], $k . '.') !== false) {
577
-                    $relations[$k] = [ $relation, $table ];
573
+                if (strpos($v[0], $k.'.') !== false) {
574
+                    $relations[$k] = [$relation, $table];
578 575
                 }
579 576
             }
580
-            if (isset($this->order[0]) && strpos($this->order[0], $k . '.') !== false) {
581
-                $relations[$k] = [ $relation, $table ];
577
+            if (isset($this->order[0]) && strpos($this->order[0], $k.'.') !== false) {
578
+                $relations[$k] = [$relation, $table];
582 579
             }
583 580
         }
584 581
         $select = [];
585 582
         foreach ($this->fields as $k => $field) {
586
-            $select[] = $field . (!is_numeric($k) ? ' ' . $k : '');
583
+            $select[] = $field.(!is_numeric($k) ? ' '.$k : '');
587 584
         }
588 585
         foreach ($this->withr as $name => $relation) {
589 586
             foreach ($relation[0]->table->getColumns() as $column) {
590
-                $select[] = $name . '.' . $column . ' ' . $name . static::SEP . $column;
587
+                $select[] = $name.'.'.$column.' '.$name.static::SEP.$column;
591 588
             }
592 589
         }
593 590
         $sql = 'SELECT '.implode(', ', $select).' FROM '.$table.' ';
594 591
         $par = [];
595 592
         foreach ($this->joins as $k => $v) {
596
-            $sql .= ($v->many ? 'LEFT ' : '' ) . 'JOIN '.$v->table->getName().' '.$k.' ON ';
593
+            $sql .= ($v->many ? 'LEFT ' : '').'JOIN '.$v->table->getName().' '.$k.' ON ';
597 594
             $tmp = [];
598 595
             foreach ($v->keymap as $kk => $vv) {
599 596
                 $tmp[] = $kk.' = '.$vv;
600 597
             }
601
-            $sql .= implode(' AND ', $tmp) . ' ';
598
+            $sql .= implode(' AND ', $tmp).' ';
602 599
         }
603 600
         foreach ($relations as $relation => $v) {
604 601
             $table = $v[1];
@@ -609,13 +606,13 @@  discard block
 block discarded – undo
609 606
                 foreach ($v->keymap as $kk => $vv) {
610 607
                     $tmp[] = $table.'.'.$kk.' = '.$relation.'_pivot.'.$vv.' ';
611 608
                 }
612
-                $sql .= implode(' AND ', $tmp) . ' ';
609
+                $sql .= implode(' AND ', $tmp).' ';
613 610
                 $sql .= 'LEFT JOIN '.$v->table->getName().' '.$relation.' ON ';
614 611
                 $tmp = [];
615 612
                 foreach ($v->pivot_keymap as $kk => $vv) {
616 613
                     $tmp[] = $relation.'.'.$vv.' = '.$relation.'_pivot.'.$kk.' ';
617 614
                 }
618
-                $sql .= implode(' AND ', $tmp) . ' ';
615
+                $sql .= implode(' AND ', $tmp).' ';
619 616
             } else {
620 617
                 $sql .= 'LEFT JOIN '.$v->table->getName().' '.$relation.' ON ';
621 618
                 $tmp = [];
@@ -623,36 +620,36 @@  discard block
 block discarded – undo
623 620
                     $tmp[] = $table.'.'.$kk.' = '.$relation.'.'.$vv.' ';
624 621
                 }
625 622
                 if ($v->sql) {
626
-                    $tmp[] = $v->sql . ' ';
623
+                    $tmp[] = $v->sql.' ';
627 624
                     $par = array_merge($par, $v->par ?? []);
628 625
                 }
629
-                $sql .= implode(' AND ', $tmp) . ' ';
626
+                $sql .= implode(' AND ', $tmp).' ';
630 627
             }
631 628
         }
632 629
         if (count($this->where)) {
633 630
             $sql .= 'WHERE ';
634 631
             $tmp = [];
635 632
             foreach ($this->where as $v) {
636
-                $tmp[] = '(' . $v[0] . ')';
633
+                $tmp[] = '('.$v[0].')';
637 634
                 $par = array_merge($par, $v[1]);
638 635
             }
639 636
             $sql .= implode(' AND ', $tmp).' ';
640 637
         }
641 638
         if (count($this->group)) {
642
-            $sql .= 'GROUP BY ' . $this->group[0] . ' ';
639
+            $sql .= 'GROUP BY '.$this->group[0].' ';
643 640
             $par = array_merge($par, $this->group[1]);
644 641
         }
645 642
         if (count($this->having)) {
646 643
             $sql .= 'HAVING ';
647 644
             $tmp = [];
648 645
             foreach ($this->having as $v) {
649
-                $tmp[] = '(' . $v[0] . ')';
646
+                $tmp[] = '('.$v[0].')';
650 647
                 $par = array_merge($par, $v[1]);
651 648
             }
652 649
             $sql .= implode(' AND ', $tmp).' ';
653 650
         }
654 651
         if (count($this->order)) {
655
-            $sql .= 'ORDER BY ' . $this->order[0] . ' ';
652
+            $sql .= 'ORDER BY '.$this->order[0].' ';
656 653
             $par = array_merge($par, $this->order[1]);
657 654
         }
658 655
         $porder = [];
@@ -660,30 +657,30 @@  discard block
 block discarded – undo
660 657
             $porder[] = $this->getColumn($field)['name'];
661 658
         }
662 659
         if (count($porder)) {
663
-            $sql .= (count($this->order) ? ', ' : 'ORDER BY ') . implode(', ', $porder) . ' ';
660
+            $sql .= (count($this->order) ? ', ' : 'ORDER BY ').implode(', ', $porder).' ';
664 661
         }
665 662
 
666 663
         if ($this->li_of[0]) {
667 664
             if ($this->db->driverName() === 'oracle') {
668
-                if ((int)$this->db->driverOption('version', 0) >= 12) {
669
-                    $sql .= 'OFFSET ' . $this->li_of[1] . ' ROWS FETCH NEXT ' . $this->li_of[0] . ' ROWS ONLY';
665
+                if ((int) $this->db->driverOption('version', 0) >= 12) {
666
+                    $sql .= 'OFFSET '.$this->li_of[1].' ROWS FETCH NEXT '.$this->li_of[0].' ROWS ONLY';
670 667
                 } else {
671
-                    $f = array_map(function ($v) {
668
+                    $f = array_map(function($v) {
672 669
                         $v = explode(' ', trim($v), 2);
673 670
                         if (count($v) === 2) { return $v[1]; }
674 671
                         $v = explode('.', $v[0], 2);
675 672
                         return count($v) === 2 ? $v[1] : $v[0];
676 673
                     }, $select);
677
-                    $sql = "SELECT " . implode(', ', $f) . " 
674
+                    $sql = "SELECT ".implode(', ', $f)." 
678 675
                             FROM (
679 676
                                 SELECT tbl__.*, rownum rnum__ FROM (
680
-                                    " . $sql . "
677
+                                    " . $sql."
681 678
                                 ) tbl__ 
682
-                                WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1]) . "
679
+                                WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1])."
683 680
                             ) WHERE rnum__ > " . $this->li_of[1];
684 681
                 }
685 682
             } else {
686
-                $sql .= 'LIMIT ' . $this->li_of[0] . ' OFFSET ' . $this->li_of[1];
683
+                $sql .= 'LIMIT '.$this->li_of[0].' OFFSET '.$this->li_of[1];
687 684
             }
688 685
         }
689 686
         return $this->qiterator = new TableQueryIterator(
@@ -732,7 +729,7 @@  discard block
 block discarded – undo
732 729
                 $ret[$k] = str_repeat(' ', 255);
733 730
                 $par[] = &$ret[$k];
734 731
             }
735
-            $sql .= ' RETURNING ' . implode(',', $primary) . ' INTO ' . implode(',', array_fill(0, count($primary), '?'));
732
+            $sql .= ' RETURNING '.implode(',', $primary).' INTO '.implode(',', array_fill(0, count($primary), '?'));
736 733
             $this->db->query($sql, $par);
737 734
             return $ret;
738 735
         } else {
@@ -764,7 +761,7 @@  discard block
 block discarded – undo
764 761
         }
765 762
         $sql = 'UPDATE '.$table.' SET ';
766 763
         $par = [];
767
-        $sql .= implode(', ', array_map(function ($v) { return $v . ' = ?'; }, array_keys($update))) . ' ';
764
+        $sql .= implode(', ', array_map(function($v) { return $v.' = ?'; }, array_keys($update))).' ';
768 765
         $par = array_merge($par, array_values($update));
769 766
         if (count($this->where)) {
770 767
             $sql .= 'WHERE ';
@@ -773,7 +770,7 @@  discard block
 block discarded – undo
773 770
                 $tmp[] = $v[0];
774 771
                 $par = array_merge($par, $v[1]);
775 772
             }
776
-            $sql .= implode(' AND ', $tmp) . ' ';
773
+            $sql .= implode(' AND ', $tmp).' ';
777 774
         }
778 775
         if (count($this->order)) {
779 776
             $sql .= $this->order[0];
@@ -797,7 +794,7 @@  discard block
 block discarded – undo
797 794
                 $tmp[] = $v[0];
798 795
                 $par = array_merge($par, $v[1]);
799 796
             }
800
-            $sql .= implode(' AND ', $tmp) . ' ';
797
+            $sql .= implode(' AND ', $tmp).' ';
801 798
         }
802 799
         if (count($this->order)) {
803 800
             $sql .= $this->order[0];
@@ -817,13 +814,13 @@  discard block
 block discarded – undo
817 814
         $table = $this->definition;
818 815
         array_reduce(
819 816
             $parts,
820
-            function ($carry, $item) use (&$table) {
817
+            function($carry, $item) use (&$table) {
821 818
                 $relation = $table->getRelation($item);
822 819
                 if (!$relation) {
823 820
                     throw new DBException('Invalid relation name');
824 821
                 }
825
-                $name = $carry ? $carry . static::SEP . $item : $item;
826
-                $this->withr[$name] = [ $relation, $carry ?? $table->getName() ];
822
+                $name = $carry ? $carry.static::SEP.$item : $item;
823
+                $this->withr[$name] = [$relation, $carry ?? $table->getName()];
827 824
                 $table = $relation->table;
828 825
                 return $name;
829 826
             }
Please login to merge, or discard this patch.