Completed
Push — master ( 56d969...e6de36 )
by Ivan
11:25
created
src/driver/ibase/Driver.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@
 block discarded – undo
71 71
         $this->softDetect($sql);
72 72
         $statement = \ibase_prepare($this->transaction !== null ? $this->transaction : $this->lnk, $sql);
73 73
         if ($statement === false) {
74
-            throw new DBException('Prepare error: ' . \ibase_errmsg());
74
+            throw new DBException('Prepare error: '.\ibase_errmsg());
75 75
         }
76 76
         return new Statement(
77 77
             $statement,
Please login to merge, or discard this patch.
src/driver/oracle/Driver.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
                 $this->query("ALTER SESSION SET time_zone = '".addslashes($timezone)."'");
45 45
             }
46 46
             if ($schema = $this->option('schema')) {
47
-                $this->query("ALTER SESSION SET CURRENT_SCHEMA = " . $schema);
47
+                $this->query("ALTER SESSION SET CURRENT_SCHEMA = ".$schema);
48 48
             }
49 49
         }
50 50
     }
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
         );
82 82
         if ($log) {
83 83
             $tm = microtime(true) - $tm;
84
-            if ($tm >= (float)$this->option('log_slow', 0)) {
84
+            if ($tm >= (float) $this->option('log_slow', 0)) {
85 85
                 @file_put_contents(
86 86
                     $log,
87
-                    '--' . date('Y-m-d H:i:s') . ' ' . sprintf('%01.6f', $tm) . "s\r\n" .
88
-                    $sql . "\r\n" .
87
+                    '--'.date('Y-m-d H:i:s').' '.sprintf('%01.6f', $tm)."s\r\n".
88
+                    $sql."\r\n".
89 89
                     "\r\n",
90 90
                     FILE_APPEND
91 91
                 );
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/sqlite/Driver.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
         if ($this->lnk === null) {
39 39
             try {
40 40
                 $this->lnk = new \SQLite3($this->connection['name']);
41
-                $this->lnk->exec('PRAGMA encoding = "'.$this->option('charset', 'utf-8') . '"');
41
+                $this->lnk->exec('PRAGMA encoding = "'.$this->option('charset', 'utf-8').'"');
42 42
             } catch (\Exception $e) {
43 43
                 if ($this->lnk !== null) {
44 44
                     throw new DBException('Connect error: '.$this->lnk->lastErrorMsg());
Please login to merge, or discard this patch.
src/schema/TableColumn.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             $instance->setNullable($data['nullable']);
43 43
         }
44 44
         if (isset($data['notnull'])) {
45
-            $instance->setNullable(!((int)$data['notnull']));
45
+            $instance->setNullable(!((int) $data['notnull']));
46 46
         }
47 47
         if (isset($data['Default'])) {
48 48
             $instance->setDefault($data['Default']);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
             $instance->setLength($data['length']);
58 58
         }
59 59
         if ($instance->getBasicType() === 'enum' && strpos($instance->getType(), 'enum(') === 0) {
60
-            $temp = array_map(function ($v) {
60
+            $temp = array_map(function($v) {
61 61
                 return str_replace("''", "'", $v);
62 62
             }, explode("','", substr($instance->getType(), 6, -2)));
63 63
             $instance->setValues($temp);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
                 $instance->setDefault(null);
87 87
             }
88 88
         }
89
-        if ($instance->getBasicType() === 'text' && isset($data['CHAR_LENGTH']) && (int)$data['CHAR_LENGTH']) {
89
+        if ($instance->getBasicType() === 'text' && isset($data['CHAR_LENGTH']) && (int) $data['CHAR_LENGTH']) {
90 90
             $instance->setLength($data['CHAR_LENGTH']);
91 91
         }
92 92
         return $instance;
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
     }
184 184
     public function getLength(): int
185 185
     {
186
-        return (int)$this->length;
186
+        return (int) $this->length;
187 187
     }
188 188
     public function setLength(int $length): static
189 189
     {
Please login to merge, or discard this patch.
src/schema/MapperInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,12 +58,12 @@
 block discarded – undo
58 58
      * @param array|T $entity
59 59
      * @return bool
60 60
      */
61
-    public function deleted(array|object $entity): bool;
61
+    public function deleted(array | object $entity): bool;
62 62
     /**
63 63
      * @param array|T $entity
64 64
      * @return bool
65 65
      */
66
-    public function exists(array|object $entity): bool;
66
+    public function exists(array | object $entity): bool;
67 67
     /**
68 68
      * @return array<int,T>
69 69
      */
Please login to merge, or discard this patch.
src/schema/Mapper.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -539,7 +539,7 @@
 block discarded – undo
539 539
                                         (isset($value) && is_array($value) && !in_array($e, $value, true)) ||
540 540
                                         (($value instanceof Collection) && !$value->contains($e))
541 541
                                     )
542
-                                 ) {
542
+                                    ) {
543 543
                                     $mapper->delete($e, true);
544 544
                                 }
545 545
                             }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -21 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      * @param class-string<T> $clss
29 29
      * @return void
30 30
      */
31
-    public function __construct(DBInterface $db, string|Table|null $table = '', string $clss = Entity::class)
31
+    public function __construct(DBInterface $db, string | Table | null $table = '', string $clss = Entity::class)
32 32
     {
33 33
         $this->db = $db;
34 34
         if (!$table) {
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         $temp = [];
65 65
         foreach ($this->table->getPrimaryKey() as $column) {
66 66
             try {
67
-                $temp[(string)$column] = $entity->{$column} ?? null;
67
+                $temp[(string) $column] = $entity->{$column} ?? null;
68 68
                 /** @phpstan-ignore-next-line */
69 69
             } catch (\Throwable $ignore) {
70 70
             }
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 
95 95
         // BEG: ugly hack to get relations changed directly on the object (not hydrated)
96 96
         $hack = [];
97
-        foreach ((array)$entity as $k => $v) {
97
+        foreach ((array) $entity as $k => $v) {
98 98
             $hack[$k[0] === "\0" ? substr($k, strrpos($k, "\0", 1) + 1) : $k] = $v;
99 99
         }
100 100
         $hack = $hack['changed'] ?? [];
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
         foreach ($columns as $column) {
106 106
             try {
107 107
                 if (in_array($column, $fetched) || array_key_exists($column, $hack) || $fetch) {
108
-                    $temp[(string)$column] = $entity->{$column};
108
+                    $temp[(string) $column] = $entity->{$column};
109 109
                 }
110 110
             } catch (\Throwable $ignore) {
111 111
             }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         foreach ($relations as $relation) {
116 116
             try {
117 117
                 if (array_key_exists($relation, $fetched) || array_key_exists($relation, $hack) || $fetch) {
118
-                    $temp[(string)$relation] = $entity->{$relation};
118
+                    $temp[(string) $relation] = $entity->{$relation};
119 119
                 }
120 120
             } catch (\Throwable $ignore) {
121 121
             }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
                         $v = [];
137 137
                     }
138 138
                     if ($v instanceof Entity) {
139
-                        $v = [ $v ];
139
+                        $v = [$v];
140 140
                     }
141 141
                     if (is_array($v)) {
142 142
                         foreach ($v as $kk => $vv) {
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
         $temp = [];
211 211
         foreach ($this->table->getColumns() as $column) {
212 212
             if (array_key_exists($column, $data)) {
213
-                $temp[(string)$column] = $data[$column];
213
+                $temp[(string) $column] = $data[$column];
214 214
             } else {
215 215
                 if ($empty) {
216
-                    $temp[(string)$column] = null;
216
+                    $temp[(string) $column] = null;
217 217
                 }
218 218
             }
219 219
         }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
         $lazy = [];
242 242
         foreach ($this->table->getColumns() as $column) {
243 243
             if (!array_key_exists($column, $data)) {
244
-                $lazy[$column] = function ($entity) use ($column) {
244
+                $lazy[$column] = function($entity) use ($column) {
245 245
                     $query = $this->db->table($this->table->getFullName());
246 246
                     foreach ($this->id($entity) as $k => $v) {
247 247
                         $query->filter($k, $v);
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
     {
265 265
         $relations = [];
266 266
         foreach ($this->table->getRelations() as $name => $relation) {
267
-            $relations[$name] = function (
267
+            $relations[$name] = function(
268 268
                 $entity,
269 269
                 bool $queryOnly = false,
270 270
                 bool $fetchedOnly = false
@@ -279,10 +279,10 @@  discard block
 block discarded – undo
279 279
                         return $this->objects[spl_object_hash($entity)][4][$name] = null;
280 280
                     }
281 281
                     $value = $relation->many ?
282
-                        Collection::from(array_map(function ($v) use ($mapper) {
282
+                        Collection::from(array_map(function($v) use ($mapper) {
283 283
                             return $mapper->entity($v);
284 284
                         }, $data[$name]))
285
-                            ->filter(function ($v) use ($mapper) {
285
+                            ->filter(function($v) use ($mapper) {
286 286
                                 return !$mapper->deleted($v);
287 287
                             }) :
288 288
                         ($mapper->deleted($data[$name]) ? null : $mapper->entity($data[$name]));
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
                 }
295 295
                 $query = $this->db->tableMapped($relation->table->getFullName());
296 296
                 if ($relation->sql) {
297
-                    $query->where($relation->sql, $relation->par?:[]);
297
+                    $query->where($relation->sql, $relation->par ?: []);
298 298
                 }
299 299
                 if ($relation->pivot) {
300 300
                     $nm = null;
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
                     }
316 316
                     $pk = $this->id($entity);
317 317
                     foreach ($pk as $k => $v) {
318
-                        $query->filter($nm . '.' . $k, $v);
318
+                        $query->filter($nm.'.'.$k, $v);
319 319
                     }
320 320
                 } else {
321 321
                     $temp = $this->toArray($entity, array_keys($relation->keymap), [], true);
@@ -327,10 +327,9 @@  discard block
 block discarded – undo
327 327
                     return $query;
328 328
                 }
329 329
                 $value = $relation->many ?
330
-                    $query->iterator() :
331
-                    ($query[0] ?? null);
330
+                    $query->iterator() : ($query[0] ?? null);
332 331
                 if ($value instanceof Collection) {
333
-                    $value->filter(function ($v) use ($mapper) {
332
+                    $value->filter(function($v) use ($mapper) {
334 333
                         return !$mapper->deleted($v);
335 334
                     });
336 335
                 } elseif (isset($value) && $mapper->deleted($value)) {
@@ -350,7 +349,7 @@  discard block
 block discarded – undo
350 349
     {
351 350
         // BEG: ugly hack to get changed columns
352 351
         $hack = [];
353
-        foreach ((array)$entity as $k => $v) {
352
+        foreach ((array) $entity as $k => $v) {
354 353
             $hack[$k[0] === "\0" ? substr($k, strrpos($k, "\0", 1) + 1) : $k] = $v;
355 354
         }
356 355
         $hack = $hack['changed'] ?? [];
@@ -646,7 +645,7 @@  discard block
 block discarded – undo
646 645
             }
647 646
         }
648 647
     }
649
-    public function exists(array|object $entity): bool
648
+    public function exists(array | object $entity): bool
650 649
     {
651 650
         if (is_array($entity)) {
652 651
             $primary = [];
@@ -660,7 +659,7 @@  discard block
 block discarded – undo
660 659
         return isset($this->objects[spl_object_hash($entity)]) &&
661 660
             $this->objects[spl_object_hash($entity)][5] === false;
662 661
     }
663
-    public function deleted(array|object $entity): bool
662
+    public function deleted(array | object $entity): bool
664 663
     {
665 664
         if (is_array($entity)) {
666 665
             $primary = [];
@@ -746,7 +745,7 @@  discard block
 block discarded – undo
746 745
         return array_filter(
747 746
             array_values(
748 747
                 array_map(
749
-                    function ($v) {
748
+                    function($v) {
750 749
                         return $v[5] ? null : ($v[1] ?? null);
751 750
                     },
752 751
                     $this->objects
Please login to merge, or discard this patch.
src/Schema.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     public function getTable(string $table): Table
32 32
     {
33 33
         if (!$this->hasTable($table)) {
34
-            throw new DBException('Invalid table name: ' . $table);
34
+            throw new DBException('Invalid table name: '.$table);
35 35
         }
36 36
         return $this->tables[$table] ??
37 37
             $this->tables[strtoupper($table)] ??
@@ -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.