@@ -57,8 +57,7 @@ |
||
| 57 | 57 | public function offsetSet ($attr, $value): void { |
| 58 | 58 | if (isset($attr)) { |
| 59 | 59 | $this->attributes[$attr] = $value; |
| 60 | - } |
|
| 61 | - else { |
|
| 60 | + } else { |
|
| 62 | 61 | $this->attributes[] = $value; |
| 63 | 62 | } |
| 64 | 63 | } |
@@ -64,8 +64,7 @@ |
||
| 64 | 64 | } |
| 65 | 65 | if ($arg === null or is_bool($arg)) { |
| 66 | 66 | $arg = ['' => 'NULL', 1 => 'TRUE', 0 => 'FALSE'][$arg]; |
| 67 | - } |
|
| 68 | - else { |
|
| 67 | + } else { |
|
| 69 | 68 | $arg = $this->db->quote($arg); |
| 70 | 69 | } |
| 71 | 70 | if ($this->db->isMySQL()) { |
@@ -85,8 +85,10 @@ |
||
| 85 | 85 | * @param string|ValueInterface $else |
| 86 | 86 | * @return $this |
| 87 | 87 | */ |
| 88 | - public function else ($else) { |
|
| 88 | + public function else { |
|
| 89 | + ($else) { |
|
| 89 | 90 | $this->else = isset($else) ? $this->db->quote($else) : null; |
| 91 | + } |
|
| 90 | 92 | return $this; |
| 91 | 93 | } |
| 92 | 94 | |
@@ -219,8 +219,7 @@ discard block |
||
| 219 | 219 | if ($this->transactions === 0) { |
| 220 | 220 | $this->logger->__invoke("BEGIN TRANSACTION"); |
| 221 | 221 | parent::beginTransaction(); |
| 222 | - } |
|
| 223 | - else { |
|
| 222 | + } else { |
|
| 224 | 223 | $this->exec("SAVEPOINT SAVEPOINT_{$this->transactions}"); |
| 225 | 224 | } |
| 226 | 225 | $this->transactions++; |
@@ -239,8 +238,7 @@ discard block |
||
| 239 | 238 | if ($this->transactions === 1) { |
| 240 | 239 | $this->logger->__invoke("COMMIT TRANSACTION"); |
| 241 | 240 | parent::commit(); |
| 242 | - } |
|
| 243 | - else { |
|
| 241 | + } else { |
|
| 244 | 242 | $savepoint = $this->transactions - 1; |
| 245 | 243 | $this->exec("RELEASE SAVEPOINT SAVEPOINT_{$savepoint}"); |
| 246 | 244 | } |
@@ -533,8 +531,7 @@ discard block |
||
| 533 | 531 | if ($this->transactions === 1) { |
| 534 | 532 | $this->logger->__invoke("ROLLBACK TRANSACTION"); |
| 535 | 533 | parent::rollBack(); |
| 536 | - } |
|
| 537 | - else { |
|
| 534 | + } else { |
|
| 538 | 535 | $savepoint = $this->transactions - 1; |
| 539 | 536 | $this->exec("ROLLBACK TO SAVEPOINT SAVEPOINT_{$savepoint}"); |
| 540 | 537 | } |
@@ -132,8 +132,7 @@ discard block |
||
| 132 | 132 | if ($table instanceof Select) { |
| 133 | 133 | $this->_table = $table->toSubquery(); |
| 134 | 134 | $this->alias = "_anon{$autoAlias}_{$table->alias}"; |
| 135 | - } |
|
| 136 | - else { |
|
| 135 | + } else { |
|
| 137 | 136 | if (is_string($table)) { |
| 138 | 137 | $table = $db[$table]; |
| 139 | 138 | assert(isset($table)); |
@@ -265,8 +264,7 @@ discard block |
||
| 265 | 264 | public function group (string $column) { |
| 266 | 265 | if (!strlen($this->_group)) { |
| 267 | 266 | $this->_group = " GROUP BY {$column}"; |
| 268 | - } |
|
| 269 | - else { |
|
| 267 | + } else { |
|
| 270 | 268 | $this->_group .= ", {$column}"; |
| 271 | 269 | } |
| 272 | 270 | return $this; |
@@ -283,8 +281,7 @@ discard block |
||
| 283 | 281 | $conditions = implode(' AND ', $conditions); |
| 284 | 282 | if (!strlen($this->_having)) { |
| 285 | 283 | $this->_having = " HAVING {$conditions}"; |
| 286 | - } |
|
| 287 | - else { |
|
| 284 | + } else { |
|
| 288 | 285 | $this->_having .= " AND {$conditions}"; |
| 289 | 286 | } |
| 290 | 287 | return $this; |
@@ -376,8 +373,7 @@ discard block |
||
| 376 | 373 | public function limit (int $limit, int $offset = 0) { |
| 377 | 374 | if ($limit == 0) { |
| 378 | 375 | $this->_limit = ''; |
| 379 | - } |
|
| 380 | - else { |
|
| 376 | + } else { |
|
| 381 | 377 | $this->_limit = " LIMIT {$limit}"; |
| 382 | 378 | if ($offset > 1) { |
| 383 | 379 | $this->_limit .= " OFFSET {$offset}"; |
@@ -452,8 +448,7 @@ discard block |
||
| 452 | 448 | $name = $match['name'] ?? null; |
| 453 | 449 | if (is_int($alias)) { |
| 454 | 450 | $alias = $name; |
| 455 | - } |
|
| 456 | - elseif ($alias !== $name) { |
|
| 451 | + } elseif ($alias !== $name) { |
|
| 457 | 452 | $expr .= " AS {$alias}"; |
| 458 | 453 | } |
| 459 | 454 | if (isset($alias)) { |
@@ -539,8 +534,7 @@ discard block |
||
| 539 | 534 | $conditions = implode(' AND ', $conditions); |
| 540 | 535 | if (!strlen($this->_where)) { |
| 541 | 536 | $this->_where = " WHERE {$conditions}"; |
| 542 | - } |
|
| 543 | - else { |
|
| 537 | + } else { |
|
| 544 | 538 | $this->_where .= " AND {$conditions}"; |
| 545 | 539 | } |
| 546 | 540 | return $this; |
@@ -114,8 +114,7 @@ |
||
| 114 | 114 | $slots = implode(',', $this->db->slots(array_keys($this->columns))); |
| 115 | 115 | if ($this->db->isSQLite()) { |
| 116 | 116 | $sql = "INSERT OR IGNORE INTO {$this} ({$columns}) VALUES ({$slots})"; |
| 117 | - } |
|
| 118 | - else { |
|
| 117 | + } else { |
|
| 119 | 118 | $sql = "INSERT IGNORE INTO {$this} ({$columns}) VALUES ({$slots})"; |
| 120 | 119 | } |
| 121 | 120 | return $this->db->prepare($sql); |
@@ -301,13 +301,4 @@ |
||
| 301 | 301 | */ |
| 302 | 302 | public function down (\$schema) |
| 303 | 303 | { |
| 304 | - {$down} |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - }; |
|
| 308 | - |
|
| 309 | - MIGRATION |
|
| 310 | - ); |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | -})->_exec(); |
|
| 304 | + {$down} |
|
| 314 | 305 | \ No newline at end of file |
@@ -356,8 +356,7 @@ |
||
| 356 | 356 | if ($this->db->isSQLite()) { |
| 357 | 357 | $info = $this->db->query("PRAGMA table_info({$name})")->fetchAll(); |
| 358 | 358 | $cols = array_column($info, 'name'); |
| 359 | - } |
|
| 360 | - else { |
|
| 359 | + } else { |
|
| 361 | 360 | $cols = $this->db->query("SELECT column_name FROM information_schema.tables WHERE table_name = \"{$name}\"")->fetchAll(DB::FETCH_COLUMN); |
| 362 | 361 | } |
| 363 | 362 | if (!$cols) { |
@@ -126,8 +126,7 @@ discard block |
||
| 126 | 126 | $doc = $rProp->getDocComment(); |
| 127 | 127 | if (preg_match(static::RX_IS_COLUMN, $doc)) { |
| 128 | 128 | $columns[] = $rProp->getName(); |
| 129 | - } |
|
| 130 | - elseif (preg_match(static::RX_EAV, $doc, $eav)) { |
|
| 129 | + } elseif (preg_match(static::RX_EAV, $doc, $eav)) { |
|
| 131 | 130 | preg_match(static::RX_EAV_VAR, $doc, $var); |
| 132 | 131 | $EAV[$rProp->getName()] = EAV::factory($db, $eav['table'], $var['type'] ?? 'string'); |
| 133 | 132 | } |
@@ -160,8 +159,7 @@ discard block |
||
| 160 | 159 | if ($rType = $rProp->getType() and $rType instanceof ReflectionNamedType) { |
| 161 | 160 | if (preg_match(static::RX_IS_SCALAR, $rType->getName())) { |
| 162 | 161 | $type = $rType->getName(); |
| 163 | - } |
|
| 164 | - else { // "array", "object", class name |
|
| 162 | + } else { // "array", "object", class name |
|
| 165 | 163 | $type = self::DEHYDRATE_AS[$rType->getName()]; |
| 166 | 164 | $this->hydration[$prop] = $rType->getName(); |
| 167 | 165 | } |
@@ -181,8 +179,7 @@ discard block |
||
| 181 | 179 | if (isset($defaults[$prop])) { |
| 182 | 180 | $type = gettype($defaults[$prop]); |
| 183 | 181 | $nullable = false; |
| 184 | - } |
|
| 185 | - else { |
|
| 182 | + } else { |
|
| 186 | 183 | $type = 'string'; |
| 187 | 184 | $nullable = true; |
| 188 | 185 | } |
@@ -417,8 +414,7 @@ discard block |
||
| 417 | 414 | public function save (EntityInterface $entity): int { |
| 418 | 415 | if (!$entity->getId()) { |
| 419 | 416 | $this->saveInsert($entity); |
| 420 | - } |
|
| 421 | - else { |
|
| 417 | + } else { |
|
| 422 | 418 | $this->saveUpdate($entity); |
| 423 | 419 | } |
| 424 | 420 | $this->saveEav($entity); |
@@ -541,8 +537,7 @@ discard block |
||
| 541 | 537 | foreach ($values as $name => $value) { |
| 542 | 538 | if (isset($this->properties[$name])) { |
| 543 | 539 | $this->properties[$name]->setValue($entity, $this->setType($name, $value)); |
| 544 | - } |
|
| 545 | - else { |
|
| 540 | + } else { |
|
| 546 | 541 | // attempt to set unknown fields directly on the instance. |
| 547 | 542 | $entity->{$name} = $value; |
| 548 | 543 | } |