@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function down(string $to = null): ?string |
| 51 | 51 | { |
| 52 | - return $this->db->transact(function () use ($to) { |
|
| 52 | + return $this->db->transact(function() use ($to) { |
|
| 53 | 53 | $current = $this->getCurrent(); |
| 54 | 54 | // walk newest to oldest |
| 55 | 55 | foreach (array_reverse($this->glob(), true) as $sequence => $file) { |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | public function up(string $to = null): ?string |
| 137 | 137 | { |
| 138 | - return $this->db->transact(function () use ($to) { |
|
| 138 | + return $this->db->transact(function() use ($to) { |
|
| 139 | 139 | $current = $this->getCurrent(); |
| 140 | 140 | // walk oldest to newest |
| 141 | 141 | foreach ($this->glob() as $sequence => $file) { |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function exists(int $id, string $attribute): bool |
| 41 | 41 | { |
| 42 | - $statement = $this->cache(__FUNCTION__, function () { |
|
| 42 | + $statement = $this->cache(__FUNCTION__, function() { |
|
| 43 | 43 | return $this->select(['COUNT(*) > 0'])->where('entity = ? AND attribute = ?')->prepare(); |
| 44 | 44 | }); |
| 45 | 45 | $exists = (bool)$statement([$id, $attribute])->fetchColumn(); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function load(int $id): array |
| 91 | 91 | { |
| 92 | - $statement = $this->cache(__FUNCTION__, function () { |
|
| 92 | + $statement = $this->cache(__FUNCTION__, function() { |
|
| 93 | 93 | $select = $this->select(['attribute', 'value']); |
| 94 | 94 | $select->where('entity = ?'); |
| 95 | 95 | $select->order('attribute'); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // upsert each |
| 154 | - $statement = $this->cache(__FUNCTION__, function () { |
|
| 154 | + $statement = $this->cache(__FUNCTION__, function() { |
|
| 155 | 155 | if ($this->db->isSQLite()) { |
| 156 | 156 | return $this->db->prepare( |
| 157 | 157 | "INSERT INTO {$this} (entity,attribute,value) VALUES (?,?,?)" |
@@ -136,7 +136,7 @@ |
||
| 136 | 136 | public function select() |
| 137 | 137 | { |
| 138 | 138 | return Select::factory($this->db, $this->qualifier, [$this->name]) |
| 139 | - ->setFetcher(function (Statement $statement) { |
|
| 139 | + ->setFetcher(function(Statement $statement) { |
|
| 140 | 140 | while (false !== $value = $statement->fetchColumn()) { |
| 141 | 141 | yield $value; |
| 142 | 142 | } |
@@ -144,16 +144,16 @@ discard block |
||
| 144 | 144 | // bool |
| 145 | 145 | 'BOOLEAN' => 'bool', |
| 146 | 146 | // int |
| 147 | - 'BIGINT' => 'int', // mysql |
|
| 147 | + 'BIGINT' => 'int', // mysql |
|
| 148 | 148 | 'INTEGER' => 'int', // sqlite (must be this type to allow AUTOINCREMENT) |
| 149 | 149 | // float |
| 150 | 150 | 'DOUBLE PRECISION' => 'float', |
| 151 | 151 | // string <= 255 |
| 152 | 152 | 'VARCHAR(255)' => 'string', |
| 153 | 153 | // string <= 64k |
| 154 | - 'TEXT' => 'String', // @var String |
|
| 154 | + 'TEXT' => 'String', // @var String |
|
| 155 | 155 | // string > 64k |
| 156 | - 'BLOB' => 'STRING', // @var STRING (sqlite) |
|
| 156 | + 'BLOB' => 'STRING', // @var STRING (sqlite) |
|
| 157 | 157 | 'LONGBLOB' => 'STRING', // @var STRING (mysql) |
| 158 | 158 | // DateTime |
| 159 | 159 | 'DATETIME' => 'DateTime', |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | */ |
| 457 | 457 | protected function sortColumns(array $types): array |
| 458 | 458 | { |
| 459 | - uksort($types, function (string $a, string $b) use ($types) { |
|
| 459 | + uksort($types, function(string $a, string $b) use ($types) { |
|
| 460 | 460 | // descending type constant, ascending name |
| 461 | 461 | return $types[$b] <=> $types[$a] ?: $a <=> $b; |
| 462 | 462 | }); |
@@ -119,7 +119,7 @@ |
||
| 119 | 119 | */ |
| 120 | 120 | public function link(array $ids): int |
| 121 | 121 | { |
| 122 | - $statement = $this->cache(__FUNCTION__, function () { |
|
| 122 | + $statement = $this->cache(__FUNCTION__, function() { |
|
| 123 | 123 | $columns = implode(',', array_keys($this->columns)); |
| 124 | 124 | $slots = implode(',', $this->db->slots(array_keys($this->columns))); |
| 125 | 125 | if ($this->db->isSQLite()) { |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | $this->table = $table; |
| 146 | 146 | $this->setColumns($expressions); |
| 147 | - $this->fetcher = function (Statement $statement) { |
|
| 147 | + $this->fetcher = function(Statement $statement) { |
|
| 148 | 148 | yield from $statement; |
| 149 | 149 | }; |
| 150 | 150 | } |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | if ($this->db->isMySQL()) { |
| 315 | 315 | // to be standards compliant, this hack must fail if they don't have the same cols. |
| 316 | 316 | assert(count($this->refs) === count($select->refs) and !array_diff_key($this->refs, $select->refs)); |
| 317 | - $this->join($select, ...array_map(function (string $alias, Column $ref) { |
|
| 317 | + $this->join($select, ...array_map(function(string $alias, Column $ref) { |
|
| 318 | 318 | return $ref->is($this->refs[$alias]); |
| 319 | 319 | }, array_keys($select->refs), $select->refs)); |
| 320 | 320 | return $this; |
@@ -347,13 +347,4 @@ |
||
| 347 | 347 | */ |
| 348 | 348 | public function down(\$schema) |
| 349 | 349 | { |
| 350 | - {$down} |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - }; |
|
| 354 | - |
|
| 355 | - MIGRATION |
|
| 356 | - ); |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | -})->_exec(); |
|
| 350 | + {$down} |
|
| 360 | 351 | \ No newline at end of file |
@@ -347,13 +347,4 @@ |
||
| 347 | 347 | */ |
| 348 | 348 | public function down(\$schema) |
| 349 | 349 | { |
| 350 | - {$down} |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - }; |
|
| 354 | - |
|
| 355 | - MIGRATION |
|
| 356 | - ); |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | -})->_exec(); |
|
| 350 | + {$down} |
|
| 360 | 351 | \ No newline at end of file |
@@ -347,13 +347,4 @@ |
||
| 347 | 347 | */ |
| 348 | 348 | public function down(\$schema) |
| 349 | 349 | { |
| 350 | - {$down} |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - }; |
|
| 354 | - |
|
| 355 | - MIGRATION |
|
| 356 | - ); |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | -})->_exec(); |
|
| 350 | + {$down} |
|
| 360 | 351 | \ No newline at end of file |
@@ -347,13 +347,4 @@ |
||
| 347 | 347 | */ |
| 348 | 348 | public function down(\$schema) |
| 349 | 349 | { |
| 350 | - {$down} |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - }; |
|
| 354 | - |
|
| 355 | - MIGRATION |
|
| 356 | - ); |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | -})->_exec(); |
|
| 350 | + {$down} |
|
| 360 | 351 | \ No newline at end of file |
@@ -347,13 +347,4 @@ |
||
| 347 | 347 | */ |
| 348 | 348 | public function down(\$schema) |
| 349 | 349 | { |
| 350 | - {$down} |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - }; |
|
| 354 | - |
|
| 355 | - MIGRATION |
|
| 356 | - ); |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | -})->_exec(); |
|
| 350 | + {$down} |
|
| 360 | 351 | \ No newline at end of file |
@@ -36,19 +36,19 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | const SCALARS = [ |
| 38 | 38 | 'bool' => 'bool', |
| 39 | - 'boolean' => 'bool', // gettype() |
|
| 40 | - 'double' => 'float', // gettype() |
|
| 41 | - 'false' => 'bool', // @var |
|
| 39 | + 'boolean' => 'bool', // gettype() |
|
| 40 | + 'double' => 'float', // gettype() |
|
| 41 | + 'false' => 'bool', // @var |
|
| 42 | 42 | 'float' => 'float', |
| 43 | 43 | 'int' => 'int', |
| 44 | - 'integer' => 'int', // gettype() |
|
| 45 | - 'NULL' => 'string', // gettype() |
|
| 46 | - 'number' => 'string', // @var |
|
| 47 | - 'scalar' => 'string', // @var |
|
| 44 | + 'integer' => 'int', // gettype() |
|
| 45 | + 'NULL' => 'string', // gettype() |
|
| 46 | + 'number' => 'string', // @var |
|
| 47 | + 'scalar' => 'string', // @var |
|
| 48 | 48 | 'string' => 'string', |
| 49 | - 'String' => 'String', // @var |
|
| 50 | - 'STRING' => 'STRING', // @var |
|
| 51 | - 'true' => 'bool', // @var |
|
| 49 | + 'String' => 'String', // @var |
|
| 50 | + 'STRING' => 'STRING', // @var |
|
| 51 | + 'true' => 'bool', // @var |
|
| 52 | 52 | ]; |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | */ |
| 351 | 351 | public function load($id) |
| 352 | 352 | { |
| 353 | - $statement = $this->cache(__FUNCTION__, function () { |
|
| 353 | + $statement = $this->cache(__FUNCTION__, function() { |
|
| 354 | 354 | return $this->select()->where('id = ?')->prepare(); |
| 355 | 355 | }); |
| 356 | 356 | if ($id instanceof EntityInterface) { |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | */ |
| 378 | 378 | public function loadAll() |
| 379 | 379 | { |
| 380 | - return $this->select()->setFetcher(function (Statement $statement) { |
|
| 380 | + return $this->select()->setFetcher(function(Statement $statement) { |
|
| 381 | 381 | yield from $this->fetchEach($statement); |
| 382 | 382 | }); |
| 383 | 383 | } |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | */ |
| 437 | 437 | protected function saveInsert(EntityInterface $entity): void |
| 438 | 438 | { |
| 439 | - $statement = $this->cache(__FUNCTION__, function () { |
|
| 439 | + $statement = $this->cache(__FUNCTION__, function() { |
|
| 440 | 440 | $slots = $this->db->slots(array_keys($this->columns)); |
| 441 | 441 | unset($slots['id']); |
| 442 | 442 | $columns = implode(',', array_keys($slots)); |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | */ |
| 457 | 457 | protected function saveUpdate(EntityInterface $entity): void |
| 458 | 458 | { |
| 459 | - $statement = $this->cache(__FUNCTION__, function () { |
|
| 459 | + $statement = $this->cache(__FUNCTION__, function() { |
|
| 460 | 460 | $slots = $this->db->slots(array_keys($this->columns)); |
| 461 | 461 | foreach ($slots as $column => $slot) { |
| 462 | 462 | $slots[$column] = "{$column} = {$slot}"; |