Completed
Push — master ( aba273...18247e )
by Ivan
02:46
created
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/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/driver/odbc/Result.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@
 block discarded – undo
74 74
     }
75 75
     public function next()
76 76
     {
77
-        $this->fetched ++;
77
+        $this->fetched++;
78 78
         $temp = \odbc_fetch_row($this->statement);
79 79
         if (!$temp) {
80 80
             $this->last = false;
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -18,6 +18,9 @@
 block discarded – undo
18 18
     protected $fetched = -1;
19 19
     protected $iid = null;
20 20
 
21
+    /**
22
+     * @param resource $statement
23
+     */
21 24
     public function __construct($statement, $data, $iid, $charIn = null, $charOut = null)
22 25
     {
23 26
         $this->statement = $statement;
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
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                 $fields = [];
71 71
                 $exists = false;
72 72
                 foreach ($relation->table->getColumns() as $column) {
73
-                    $nm = $name . static::SEP . $column;
73
+                    $nm = $name.static::SEP.$column;
74 74
                     if (isset($this->aliases[$nm])) {
75 75
                         $nm = $this->aliases[$nm];
76 76
                     }
@@ -84,16 +84,16 @@  discard block
 block discarded – undo
84 84
                 $parts = explode(static::SEP, $name);
85 85
                 $name  = array_pop($parts);
86 86
                 if (!$exists && !count($parts) && !isset($temp[$name])) {
87
-                    $temp[$name] = $relation->many ? [ '___clean' => true ] : null;
87
+                    $temp[$name] = $relation->many ? ['___clean' => true] : null;
88 88
                 }
89 89
                 if ($exists) {
90
-                    $full  = '';
90
+                    $full = '';
91 91
                     foreach ($parts as $item) {
92
-                        $full = $full ? $full . static::SEP . $item : $item;
92
+                        $full = $full ? $full.static::SEP.$item : $item;
93 93
                         $temp = &$temp[$item];
94 94
                         $rpk = [];
95 95
                         foreach ($this->relations[$full][0]->table->getPrimaryKey() as $pkey) {
96
-                            $nm = $full . static::SEP . $pkey;
96
+                            $nm = $full.static::SEP.$pkey;
97 97
                             if (isset($this->aliases[$nm])) {
98 98
                                 $nm = $this->aliases[$nm];
99 99
                             }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
                         $temp = &$temp[json_encode($rpk)];
103 103
                     }
104 104
                     if (!isset($temp[$name])) {
105
-                        $temp[$name] = $relation->many ? [ '___clean' => true ] : null;
105
+                        $temp[$name] = $relation->many ? ['___clean' => true] : null;
106 106
                     }
107 107
                     $temp = &$temp[$name];
108 108
                     if ($relation->many) {
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                 return;
161 161
             }
162 162
         }
163
-        $this->fetched ++;
163
+        $this->fetched++;
164 164
         while ($this->result->valid()) {
165 165
             $row = $this->result->current();
166 166
             $pk = [];
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
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
             $instance->setLength($data['length']);
52 52
         }
53 53
         if ($instance->getBasicType() === 'enum' && strpos($instance->getType(), 'enum(') === 0) {
54
-            $temp = array_map(function ($v) {
54
+            $temp = array_map(function($v) {
55 55
                 return str_replace("''", "'", $v);
56 56
             }, explode("','", substr($instance->getType(), 6, -2)));
57 57
             $instance->setValues($temp);
Please login to merge, or discard this patch.
src/driver/pdo/Statement.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,28 +24,28 @@
 block discarded – undo
24 24
         foreach ($data as $i => $v) {
25 25
             switch (gettype($v)) {
26 26
                 case 'boolean':
27
-                    $this->statement->bindValue($i+1, $v, \PDO::PARAM_BOOL);
27
+                    $this->statement->bindValue($i + 1, $v, \PDO::PARAM_BOOL);
28 28
                     break;
29 29
                 case 'integer':
30
-                    $this->statement->bindValue($i+1, $v, \PDO::PARAM_INT);
30
+                    $this->statement->bindValue($i + 1, $v, \PDO::PARAM_INT);
31 31
                     break;
32 32
                 case 'NULL':
33
-                    $this->statement->bindValue($i+1, $v, \PDO::PARAM_NULL);
33
+                    $this->statement->bindValue($i + 1, $v, \PDO::PARAM_NULL);
34 34
                     break;
35 35
                 case 'double':
36
-                    $this->statement->bindValue($i+1, $v);
36
+                    $this->statement->bindValue($i + 1, $v);
37 37
                     break;
38 38
                 default:
39 39
                     // keep in mind oracle needs a transaction when inserting LOBs, aside from the specific syntax:
40 40
                     // INSERT INTO table (column, lobcolumn) VALUES (?, ?, EMPTY_BLOB()) RETURNING lobcolumn INTO ?
41 41
                     if (is_resource($v) && get_resource_type($v) === 'stream') {
42
-                        $this->statement->bindParam($i+1, $v, \PDO::PARAM_LOB);
42
+                        $this->statement->bindParam($i + 1, $v, \PDO::PARAM_LOB);
43 43
                         break;
44 44
                     }
45 45
                     if (!is_string($data[$i])) {
46 46
                         $data[$i] = serialize($data[$i]);
47 47
                     }
48
-                    $this->statement->bindValue($i+1, $v);
48
+                    $this->statement->bindValue($i + 1, $v);
49 49
                     break;
50 50
             }
51 51
         }
Please login to merge, or discard this patch.
src/DB.php 1 patch
Spacing   +14 added lines, -17 removed lines patch added patch discarded remove patch
@@ -75,8 +75,7 @@  discard block
 block discarded – undo
75 75
         }
76 76
         $connection['name'] = $connectionString;
77 77
         $connection['type'] = isset($aliases[$connection['type']]) ?
78
-            $aliases[$connection['type']] :
79
-            $connection['type'];
78
+            $aliases[$connection['type']] : $connection['type'];
80 79
         $tmp = '\\vakata\\database\\driver\\'.strtolower($connection['type']).'\\Driver';
81 80
         return new $tmp($connection);
82 81
     }
@@ -105,7 +104,7 @@  discard block
 block discarded – undo
105 104
         $new = '';
106 105
         $par = array_values($par);
107 106
         if (substr_count($sql, '?') === 2 && !is_array($par[0])) {
108
-            $par = [ $par ];
107
+            $par = [$par];
109 108
         }
110 109
         $parts = explode('??', $sql);
111 110
         $index = 0;
@@ -115,7 +114,7 @@  discard block
 block discarded – undo
115 114
             $index += count($tmp) - 1;
116 115
             if (isset($par[$index])) {
117 116
                 if (!is_array($par[$index])) {
118
-                    $par[$index] = [ $par[$index] ];
117
+                    $par[$index] = [$par[$index]];
119 118
                 }
120 119
                 $params = $par[$index];
121 120
                 array_splice($par, $index, 1, $params);
@@ -123,7 +122,7 @@  discard block
 block discarded – undo
123 122
                 $new .= implode(',', array_fill(0, count($params), '?'));
124 123
             }
125 124
         }
126
-        return [ $new, $par ];
125
+        return [$new, $par];
127 126
     }
128 127
     /**
129 128
      * Run a query (prepare & execute).
@@ -155,7 +154,7 @@  discard block
 block discarded – undo
155 154
     {
156 155
         $coll = Collection::from($this->query($sql, $par));
157 156
         if (($keys = $this->driver->option('mode')) && in_array($keys, ['strtoupper', 'strtolower'])) {
158
-            $coll->map(function ($v) use ($keys) {
157
+            $coll->map(function($v) use ($keys) {
159 158
                 $new = [];
160 159
                 foreach ($v as $k => $vv) {
161 160
                     $new[call_user_func($keys, $k)] = $vv;
@@ -164,13 +163,13 @@  discard block
 block discarded – undo
164 163
             });
165 164
         }
166 165
         if ($key !== null) {
167
-            $coll->mapKey(function ($v) use ($key) { return $v[$key]; });
166
+            $coll->mapKey(function($v) use ($key) { return $v[$key]; });
168 167
         }
169 168
         if ($skip) {
170
-            $coll->map(function ($v) use ($key) { unset($v[$key]); return $v; });
169
+            $coll->map(function($v) use ($key) { unset($v[$key]); return $v; });
171 170
         }
172 171
         if ($opti) {
173
-            $coll->map(function ($v) { return count($v) === 1 ? current($v) : $v; });
172
+            $coll->map(function($v) { return count($v) === 1 ? current($v) : $v; });
174 173
         }
175 174
         return $coll;
176 175
     }
@@ -254,8 +253,7 @@  discard block
 block discarded – undo
254 253
     public function definition(string $table, bool $detectRelations = true) : Table
255 254
     {
256 255
         return isset($this->tables[$table]) ?
257
-            $this->tables[$table] :
258
-            $this->driver->table($table, $detectRelations);
256
+            $this->tables[$table] : $this->driver->table($table, $detectRelations);
259 257
     }
260 258
     /**
261 259
      * Parse all tables from the database.
@@ -272,12 +270,12 @@  discard block
 block discarded – undo
272 270
      */
273 271
     public function getSchema($asPlainArray = true)
274 272
     {
275
-        return !$asPlainArray ? $this->tables : array_map(function ($table) {
273
+        return !$asPlainArray ? $this->tables : array_map(function($table) {
276 274
             return [
277 275
                 'name' => $table->getName(),
278 276
                 'pkey' => $table->getPrimaryKey(),
279 277
                 'comment' => $table->getComment(),
280
-                'columns' => array_map(function ($column) {
278
+                'columns' => array_map(function($column) {
281 279
                     return [
282 280
                         'name' => $column->getName(),
283 281
                         'type' => $column->getType(),
@@ -288,13 +286,13 @@  discard block
 block discarded – undo
288 286
                         'nullable' => $column->isNullable()
289 287
                     ];
290 288
                 }, $table->getFullColumns()),
291
-                'relations' => array_map(function ($rel) {
289
+                'relations' => array_map(function($rel) {
292 290
                     $relation = clone $rel;
293 291
                     $relation->table = $relation->table->getName();
294 292
                     if ($relation->pivot) {
295 293
                         $relation->pivot = $relation->pivot->getName();
296 294
                     }
297
-                    return (array)$relation;
295
+                    return (array) $relation;
298 296
                 }, $table->getRelations())
299 297
             ];
300 298
         }, $this->tables);
@@ -342,8 +340,7 @@  discard block
 block discarded – undo
342 340
     public function table($table, bool $mapped = false)
343 341
     {
344 342
         return $mapped ?
345
-            new TableQueryMapped($this, $this->definition($table)) :
346
-            new TableQuery($this, $this->definition($table));
343
+            new TableQueryMapped($this, $this->definition($table)) : new TableQuery($this, $this->definition($table));
347 344
     }
348 345
     public function __call($method, $args)
349 346
     {
Please login to merge, or discard this patch.
src/schema/Mapper.php 1 patch
Spacing   +7 added lines, -9 removed lines patch added patch discarded remove patch
@@ -79,8 +79,7 @@  discard block
 block discarded – undo
79 79
                 if (isset($this->definition->getRelations()[$method])) {
80 80
                     if (isset($this->fetched[$method])) {
81 81
                         return is_callable($this->fetched[$method]) ?
82
-                            $this->fetched[$method] = call_user_func($this->fetched[$method], $args[0] ?? null) :
83
-                            $this->fetched[$method];
82
+                            $this->fetched[$method] = call_user_func($this->fetched[$method], $args[0] ?? null) : $this->fetched[$method];
84 83
                     }
85 84
                 }
86 85
                 return null;
@@ -164,7 +163,7 @@  discard block
 block discarded – undo
164 163
     public function collection(TableQueryIterator $iterator, Table $definition) : Collection
165 164
     {
166 165
         return Collection::from($iterator)
167
-            ->map(function ($v) use ($definition) {
166
+            ->map(function($v) use ($definition) {
168 167
                 return $this->entity($definition, $v);
169 168
             });
170 169
     }
@@ -239,7 +238,7 @@  discard block
 block discarded – undo
239 238
         $definition = $entity->definition();
240 239
         foreach ($definition->getColumns() as $column) {
241 240
             if (!isset($data[$column])) {
242
-                $entity->__lazyProperty($column, function () use ($entity, $definition, $primary, $column) {
241
+                $entity->__lazyProperty($column, function() use ($entity, $definition, $primary, $column) {
243 242
                     $query = $this->db->table($definition->getName());
244 243
                     foreach ($primary as $k => $v) {
245 244
                         $query->filter($k, $v);
@@ -253,12 +252,12 @@  discard block
 block discarded – undo
253 252
                 $name,
254 253
                 isset($data[$name]) ?
255 254
                     ($relation->many ? 
256
-                        array_map(function ($v) use ($relation) {
255
+                        array_map(function($v) use ($relation) {
257 256
                             return $this->entity($relation->table, $v);
258 257
                         }, $data[$name]) :
259 258
                         $this->entity($relation->table, $data[$name])
260 259
                     ) :
261
-                    function (array $columns = null) use ($entity, $definition, $primary, $relation, $data) {
260
+                    function(array $columns = null) use ($entity, $definition, $primary, $relation, $data) {
262 261
                         $query = $this->db->table($relation->table->getName(), true);
263 262
                         if ($columns !== null) {
264 263
                             $query->columns($columns);
@@ -284,7 +283,7 @@  discard block
 block discarded – undo
284 283
                                 );
285 284
                             }
286 285
                             foreach ($definition->getPrimaryKey() as $v) {
287
-                                $query->filter($nm . '.' . $v, $data[$v] ?? null);
286
+                                $query->filter($nm.'.'.$v, $data[$v] ?? null);
288 287
                             }
289 288
                         } else {
290 289
                             foreach ($relation->keymap as $k => $v) {
@@ -292,8 +291,7 @@  discard block
 block discarded – undo
292 291
                             }
293 292
                         }
294 293
                         return $relation->many ?
295
-                            $query->iterator() :
296
-                            $query[0];
294
+                            $query->iterator() : $query[0];
297 295
                     }
298 296
             );
299 297
         }
Please login to merge, or discard this patch.