@@ -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(); |
@@ -117,8 +117,7 @@ discard block |
||
117 | 117 | if ($table instanceof Select) { |
118 | 118 | $this->table = $table->toSubquery(); |
119 | 119 | $this->alias = uniqid('_') . "_{$table->alias}"; |
120 | - } |
|
121 | - else { |
|
120 | + } else { |
|
122 | 121 | $this->table = (string)$table; |
123 | 122 | $this->alias = uniqid('_') . "__{$table}"; |
124 | 123 | } |
@@ -228,8 +227,7 @@ discard block |
||
228 | 227 | public function group (string $column) { |
229 | 228 | if (!strlen($this->_group)) { |
230 | 229 | $this->_group = " GROUP BY {$column}"; |
231 | - } |
|
232 | - else { |
|
230 | + } else { |
|
233 | 231 | $this->_group .= ", {$column}"; |
234 | 232 | } |
235 | 233 | return $this; |
@@ -244,8 +242,7 @@ discard block |
||
244 | 242 | public function having (string $condition) { |
245 | 243 | if (!strlen($this->_having)) { |
246 | 244 | $this->_having = " HAVING {$condition}"; |
247 | - } |
|
248 | - else { |
|
245 | + } else { |
|
249 | 246 | $this->_having .= " AND {$condition}"; |
250 | 247 | } |
251 | 248 | return $this; |
@@ -264,8 +261,7 @@ discard block |
||
264 | 261 | $select->_limit = ''; |
265 | 262 | if ($all) { |
266 | 263 | $this->_import .= " INTERSECT ALL {$select->toSql()}"; |
267 | - } |
|
268 | - else { |
|
264 | + } else { |
|
269 | 265 | $this->_import .= " INTERSECT {$select->toSql()}"; |
270 | 266 | } |
271 | 267 | return $this; |
@@ -315,8 +311,7 @@ discard block |
||
315 | 311 | public function limit (int $limit, int $offset = 0) { |
316 | 312 | if ($limit == 0) { |
317 | 313 | $this->_limit = ''; |
318 | - } |
|
319 | - else { |
|
314 | + } else { |
|
320 | 315 | $this->_limit = " LIMIT {$limit}"; |
321 | 316 | if ($offset > 1) { |
322 | 317 | $this->_limit .= " OFFSET {$offset}"; |
@@ -389,8 +384,7 @@ discard block |
||
389 | 384 | $name = $match['name'] ?? null; |
390 | 385 | if (is_int($alias)) { |
391 | 386 | $alias = $name; |
392 | - } |
|
393 | - elseif ($alias !== $name) { |
|
387 | + } elseif ($alias !== $name) { |
|
394 | 388 | $expr .= " AS {$alias}"; |
395 | 389 | } |
396 | 390 | if (isset($alias)) { |
@@ -450,8 +444,7 @@ discard block |
||
450 | 444 | $select->_limit = ''; |
451 | 445 | if ($all) { |
452 | 446 | $this->_import .= " UNION ALL {$select->toSql()}"; |
453 | - } |
|
454 | - else { |
|
447 | + } else { |
|
455 | 448 | $this->_import .= " UNION {$select->toSql()}"; |
456 | 449 | } |
457 | 450 | return $this; |
@@ -466,8 +459,7 @@ discard block |
||
466 | 459 | public function where (string $condition) { |
467 | 460 | if (!strlen($this->_where)) { |
468 | 461 | $this->_where = " WHERE {$condition}"; |
469 | - } |
|
470 | - else { |
|
462 | + } else { |
|
471 | 463 | $this->_where .= " AND {$condition}"; |
472 | 464 | } |
473 | 465 | return $this; |
@@ -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 |
@@ -157,8 +157,7 @@ |
||
157 | 157 | if ($this->isSQLite()) { |
158 | 158 | $info = $this->query("PRAGMA table_info({$this->quote($name)})")->fetchAll(); |
159 | 159 | $cols = array_column($info, 'name'); |
160 | - } |
|
161 | - else { |
|
160 | + } else { |
|
162 | 161 | $cols = $this->query( |
163 | 162 | "SELECT column_name FROM information_schema.tables WHERE table_name = {$this->quote($name)}" |
164 | 163 | )->fetchAll(self::FETCH_COLUMN); |
@@ -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 | } |