Completed
Push — master ( 367f78...d6b668 )
by Ivan
13:18
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'] ?? [];
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
                     array_key_exists($column, $hack) ||
111 111
                         $fetch
112 112
                 ) {
113
-                    $temp[(string)$column] = $entity->{$column};
113
+                    $temp[(string) $column] = $entity->{$column};
114 114
                 }
115 115
             } catch (\Throwable $ignore) {
116 116
             }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         foreach ($relations as $relation) {
121 121
             try {
122 122
                 if (array_key_exists($relation, $fetched) || array_key_exists($relation, $hack) || $fetch) {
123
-                    $temp[(string)$relation] = $entity->{$relation};
123
+                    $temp[(string) $relation] = $entity->{$relation};
124 124
                 }
125 125
             } catch (\Throwable $ignore) {
126 126
             }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
                         $v = [];
142 142
                     }
143 143
                     if ($v instanceof Entity) {
144
-                        $v = [ $v ];
144
+                        $v = [$v];
145 145
                     }
146 146
                     if (is_array($v)) {
147 147
                         foreach ($v as $kk => $vv) {
@@ -215,10 +215,10 @@  discard block
 block discarded – undo
215 215
         $temp = [];
216 216
         foreach ($this->table->getColumns() as $column) {
217 217
             if (array_key_exists($column, $data)) {
218
-                $temp[(string)$column] = $data[$column];
218
+                $temp[(string) $column] = $data[$column];
219 219
             } else {
220 220
                 if ($empty) {
221
-                    $temp[(string)$column] = null;
221
+                    $temp[(string) $column] = null;
222 222
                 }
223 223
             }
224 224
         }
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
         $lazy = [];
247 247
         foreach ($this->table->getColumns() as $column) {
248 248
             if (!array_key_exists($column, $data)) {
249
-                $lazy[$column] = function ($entity) use ($column) {
249
+                $lazy[$column] = function($entity) use ($column) {
250 250
                     $query = $this->db->table($this->table->getFullName());
251 251
                     foreach ($this->id($entity) as $k => $v) {
252 252
                         $query->filter($k, $v);
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
     {
270 270
         $relations = [];
271 271
         foreach ($this->table->getRelations() as $name => $relation) {
272
-            $relations[$name] = function (
272
+            $relations[$name] = function(
273 273
                 $entity,
274 274
                 bool $queryOnly = false,
275 275
                 bool $fetchedOnly = false
@@ -284,10 +284,10 @@  discard block
 block discarded – undo
284 284
                         return $this->objects[spl_object_hash($entity)][4][$name] = null;
285 285
                     }
286 286
                     $value = $relation->many ?
287
-                        Collection::from(array_map(function ($v) use ($mapper) {
287
+                        Collection::from(array_map(function($v) use ($mapper) {
288 288
                             return $mapper->entity($v);
289 289
                         }, $data[$name]))
290
-                            ->filter(function ($v) use ($mapper) {
290
+                            ->filter(function($v) use ($mapper) {
291 291
                                 return !$mapper->deleted($v);
292 292
                             }) :
293 293
                         ($mapper->deleted($data[$name]) ? null : $mapper->entity($data[$name]));
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
                 }
300 300
                 $query = $this->db->tableMapped($relation->table->getFullName());
301 301
                 if ($relation->sql) {
302
-                    $query->where($relation->sql, $relation->par?:[]);
302
+                    $query->where($relation->sql, $relation->par ?: []);
303 303
                 }
304 304
                 if ($relation->pivot) {
305 305
                     $nm = null;
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
                     }
321 321
                     $pk = $this->id($entity);
322 322
                     foreach ($pk as $k => $v) {
323
-                        $query->filter($nm . '.' . $k, $v);
323
+                        $query->filter($nm.'.'.$k, $v);
324 324
                     }
325 325
                 } else {
326 326
                     $temp = $this->toArray($entity, array_keys($relation->keymap), [], true);
@@ -332,10 +332,9 @@  discard block
 block discarded – undo
332 332
                     return $query;
333 333
                 }
334 334
                 $value = $relation->many ?
335
-                    $query->iterator() :
336
-                    ($query[0] ?? null);
335
+                    $query->iterator() : ($query[0] ?? null);
337 336
                 if ($value instanceof Collection) {
338
-                    $value->filter(function ($v) use ($mapper) {
337
+                    $value->filter(function($v) use ($mapper) {
339 338
                         return !$mapper->deleted($v);
340 339
                     });
341 340
                 } elseif (isset($value) && $mapper->deleted($value)) {
@@ -355,7 +354,7 @@  discard block
 block discarded – undo
355 354
     {
356 355
         // BEG: ugly hack to get changed columns
357 356
         $hack = [];
358
-        foreach ((array)$entity as $k => $v) {
357
+        foreach ((array) $entity as $k => $v) {
359 358
             $hack[$k[0] === "\0" ? substr($k, strrpos($k, "\0", 1) + 1) : $k] = $v;
360 359
         }
361 360
         $orig = $hack['data'] ?? [];
@@ -661,7 +660,7 @@  discard block
 block discarded – undo
661 660
             }
662 661
         }
663 662
     }
664
-    public function exists(array|object $entity): bool
663
+    public function exists(array | object $entity): bool
665 664
     {
666 665
         if (is_array($entity)) {
667 666
             $primary = [];
@@ -675,7 +674,7 @@  discard block
 block discarded – undo
675 674
         return isset($this->objects[spl_object_hash($entity)]) &&
676 675
             $this->objects[spl_object_hash($entity)][5] === false;
677 676
     }
678
-    public function deleted(array|object $entity): bool
677
+    public function deleted(array | object $entity): bool
679 678
     {
680 679
         if (is_array($entity)) {
681 680
             $primary = [];
@@ -761,7 +760,7 @@  discard block
 block discarded – undo
761 760
         return array_filter(
762 761
             array_values(
763 762
                 array_map(
764
-                    function ($v) {
763
+                    function($v) {
765 764
                         return $v[5] ? null : ($v[1] ?? null);
766 765
                     },
767 766
                     $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.