@@ -31,8 +31,7 @@ |
||
31 | 31 | public static function fromInterface (DB $db, string $interface) { |
32 | 32 | try { |
33 | 33 | $ref = new ReflectionClass($interface); |
34 | - } |
|
35 | - catch (ReflectionException $exception) { |
|
34 | + } catch (ReflectionException $exception) { |
|
36 | 35 | throw new LogicException('Unexpected ReflectionException', 0, $exception); |
37 | 36 | } |
38 | 37 | $doc = $ref->getDocComment(); |
@@ -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 |
@@ -75,8 +75,7 @@ discard block |
||
75 | 75 | foreach ($rClass->getProperties() as $rProp) { |
76 | 76 | if (preg_match('/@col(umn)?[\s$]/', $rProp->getDocComment())) { |
77 | 77 | $columns[] = $rProp->getName(); |
78 | - } |
|
79 | - elseif (preg_match('/@eav\s+(?<table>\S+)/', $rProp->getDocComment(), $attr)) { |
|
78 | + } elseif (preg_match('/@eav\s+(?<table>\S+)/', $rProp->getDocComment(), $attr)) { |
|
80 | 79 | $eav[$rProp->getName()] = EAV::factory($db, $attr['table']); |
81 | 80 | } |
82 | 81 | } |
@@ -254,8 +253,7 @@ discard block |
||
254 | 253 | public function save (EntityInterface $entity): int { |
255 | 254 | if (!$entity->getId()) { |
256 | 255 | $this->saveInsert($entity); |
257 | - } |
|
258 | - else { |
|
256 | + } else { |
|
259 | 257 | $this->saveUpdate($entity); |
260 | 258 | } |
261 | 259 | $this->saveEav($entity); |
@@ -341,8 +339,7 @@ discard block |
||
341 | 339 | if (isset($this->properties[$name])) { |
342 | 340 | settype($value, $this->types[$name]); |
343 | 341 | $this->properties[$name]->setValue($entity, $value); |
344 | - } |
|
345 | - else { |
|
342 | + } else { |
|
346 | 343 | $entity->{$name} = $value; |
347 | 344 | } |
348 | 345 | } |
@@ -137,8 +137,7 @@ discard block |
||
137 | 137 | if ($this->transactions === 0) { |
138 | 138 | $this->logger->__invoke("BEGIN TRANSACTION"); |
139 | 139 | parent::beginTransaction(); |
140 | - } |
|
141 | - else { |
|
140 | + } else { |
|
142 | 141 | $this->exec("SAVEPOINT SAVEPOINT_{$this->transactions}"); |
143 | 142 | } |
144 | 143 | $this->transactions++; |
@@ -157,8 +156,7 @@ discard block |
||
157 | 156 | if ($this->transactions === 1) { |
158 | 157 | $this->logger->__invoke("COMMIT TRANSACTION"); |
159 | 158 | parent::commit(); |
160 | - } |
|
161 | - else { |
|
159 | + } else { |
|
162 | 160 | $savepoint = $this->transactions - 1; |
163 | 161 | $this->exec("RELEASE SAVEPOINT SAVEPOINT_{$savepoint}"); |
164 | 162 | } |
@@ -238,8 +236,7 @@ discard block |
||
238 | 236 | if ($this->isSQLite()) { |
239 | 237 | $info = $this->query("PRAGMA table_info({$this->quote($name)})")->fetchAll(); |
240 | 238 | $cols = array_column($info, 'name'); |
241 | - } |
|
242 | - else { |
|
239 | + } else { |
|
243 | 240 | $cols = $this->query( |
244 | 241 | "SELECT column_name FROM information_schema.tables WHERE table_name = {$this->quote($name)}" |
245 | 242 | )->fetchAll(self::FETCH_COLUMN); |
@@ -457,8 +454,7 @@ discard block |
||
457 | 454 | if ($this->transactions === 1) { |
458 | 455 | $this->logger->__invoke("ROLLBACK TRANSACTION"); |
459 | 456 | parent::rollBack(); |
460 | - } |
|
461 | - else { |
|
457 | + } else { |
|
462 | 458 | $savepoint = $this->transactions - 1; |
463 | 459 | $this->exec("ROLLBACK TO SAVEPOINT SAVEPOINT_{$savepoint}"); |
464 | 460 | } |
@@ -131,8 +131,7 @@ discard block |
||
131 | 131 | if ($table instanceof Select) { |
132 | 132 | $this->_table = $table->toSubquery(); |
133 | 133 | $this->alias = "_anon{$autoAlias}_{$table->alias}"; |
134 | - } |
|
135 | - else { |
|
134 | + } else { |
|
136 | 135 | if (is_string($table)) { |
137 | 136 | $table = $db->getTable($table); |
138 | 137 | assert(isset($table)); |
@@ -264,8 +263,7 @@ discard block |
||
264 | 263 | public function group (string $column) { |
265 | 264 | if (!strlen($this->_group)) { |
266 | 265 | $this->_group = " GROUP BY {$column}"; |
267 | - } |
|
268 | - else { |
|
266 | + } else { |
|
269 | 267 | $this->_group .= ", {$column}"; |
270 | 268 | } |
271 | 269 | return $this; |
@@ -282,8 +280,7 @@ discard block |
||
282 | 280 | $conditions = implode(' AND ', $conditions); |
283 | 281 | if (!strlen($this->_having)) { |
284 | 282 | $this->_having = " HAVING {$conditions}"; |
285 | - } |
|
286 | - else { |
|
283 | + } else { |
|
287 | 284 | $this->_having .= " AND {$conditions}"; |
288 | 285 | } |
289 | 286 | return $this; |
@@ -375,8 +372,7 @@ discard block |
||
375 | 372 | public function limit (int $limit, int $offset = 0) { |
376 | 373 | if ($limit == 0) { |
377 | 374 | $this->_limit = ''; |
378 | - } |
|
379 | - else { |
|
375 | + } else { |
|
380 | 376 | $this->_limit = " LIMIT {$limit}"; |
381 | 377 | if ($offset > 1) { |
382 | 378 | $this->_limit .= " OFFSET {$offset}"; |
@@ -451,8 +447,7 @@ discard block |
||
451 | 447 | $name = $match['name'] ?? null; |
452 | 448 | if (is_int($alias)) { |
453 | 449 | $alias = $name; |
454 | - } |
|
455 | - elseif ($alias !== $name) { |
|
450 | + } elseif ($alias !== $name) { |
|
456 | 451 | $expr .= " AS {$alias}"; |
457 | 452 | } |
458 | 453 | if (isset($alias)) { |
@@ -538,8 +533,7 @@ discard block |
||
538 | 533 | $conditions = implode(' AND ', $conditions); |
539 | 534 | if (!strlen($this->_where)) { |
540 | 535 | $this->_where = " WHERE {$conditions}"; |
541 | - } |
|
542 | - else { |
|
536 | + } else { |
|
543 | 537 | $this->_where .= " AND {$conditions}"; |
544 | 538 | } |
545 | 539 | return $this; |