@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | $result = (new Query($db))->from('customer') |
551 | 551 | ->select(['name', 'id']) |
552 | 552 | ->orderBy(['id' => SORT_DESC]) |
553 | - ->indexBy(function ($row) { |
|
553 | + ->indexBy(function($row) { |
|
554 | 554 | return $row['id'] * 2; |
555 | 555 | }) |
556 | 556 | ->column(); |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | ); |
815 | 815 | |
816 | 816 | /* Connection cache */ |
817 | - $db->cache(function (ConnectionInterface $db) use ($query, $update) { |
|
817 | + $db->cache(function(ConnectionInterface $db) use ($query, $update) { |
|
818 | 818 | $this->assertEquals( |
819 | 819 | 'user2', |
820 | 820 | $query->where(['id' => 2])->scalar(), |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | 'Query does NOT reflect DB changes when wrapped in connection caching' |
830 | 830 | ); |
831 | 831 | |
832 | - $db->noCache(function () use ($query) { |
|
832 | + $db->noCache(function() use ($query) { |
|
833 | 833 | $this->assertEquals( |
834 | 834 | 'user22', |
835 | 835 | $query->where(['id' => 2])->scalar(), |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | |
847 | 847 | $this->queryCache->setEnable(false); |
848 | 848 | |
849 | - $db->cache(function () use ($query, $update) { |
|
849 | + $db->cache(function() use ($query, $update) { |
|
850 | 850 | $this->assertEquals( |
851 | 851 | 'user22', |
852 | 852 | $query->where(['id' => 2])->scalar(), |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | 'When Query has disabled cache, we get actual data' |
878 | 878 | ); |
879 | 879 | |
880 | - $db->cache(function () use ($query) { |
|
880 | + $db->cache(function() use ($query) { |
|
881 | 881 | $this->assertEquals('user1', $query->noCache()->where(['id' => 1])->scalar()); |
882 | 882 | $this->assertEquals('user11', $query->cache()->where(['id' => 1])->scalar()); |
883 | 883 | }, 10); |
@@ -30,7 +30,7 @@ |
||
30 | 30 | */ |
31 | 31 | public function toString(): string |
32 | 32 | { |
33 | - $allowedValues = array_map(static function ($value) { |
|
33 | + $allowedValues = array_map(static function($value) { |
|
34 | 34 | return VarDumper::create($value)->asString(); |
35 | 35 | }, $this->allowedValues); |
36 | 36 |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | */ |
490 | 490 | protected function loadTableTypeMetadata(string $type, string $name): Constraint|array|TableSchema|null |
491 | 491 | { |
492 | - return match ($type) { |
|
492 | + return match($type) { |
|
493 | 493 | self::SCHEMA => $this->loadTableSchema($name), |
494 | 494 | self::PRIMARY_KEY => $this->loadTablePrimaryKey($name), |
495 | 495 | self::UNIQUES => $this->loadTableUniques($name), |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | string $name, |
516 | 516 | bool $refresh = false |
517 | 517 | ): Constraint|array|null|TableSchema { |
518 | - return match ($type) { |
|
518 | + return match($type) { |
|
519 | 519 | self::SCHEMA => $this->getTableSchema($name, $refresh), |
520 | 520 | self::PRIMARY_KEY => $this->getTablePrimaryKey($name, $refresh), |
521 | 521 | self::UNIQUES => $this->getTableUniques($name, $refresh), |
@@ -20,7 +20,7 @@ |
||
20 | 20 | $message = $this->e->getMessage() . PHP_EOL . 'The SQL being executed was: ' . $this->rawSql; |
21 | 21 | $errorInfo = $this->e instanceof PDOException ? $this->e->errorInfo : null; |
22 | 22 | |
23 | - return match ( |
|
23 | + return match( |
|
24 | 24 | str_contains($message, self::MSG_INTEGRITY_EXCEPTION_1) || |
25 | 25 | str_contains($message, self::MGS_INTEGRITY_EXCEPTION_2) |
26 | 26 | ) { |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | ); |
129 | 129 | } |
130 | 130 | |
131 | - $this->db->getPDO()?->beginTransaction(); |
|
131 | + $this->db->getPDO() ? ->beginTransaction(); |
|
132 | 132 | $this->level = 1; |
133 | 133 | |
134 | 134 | return; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $this->logger->log(LogLevel::DEBUG, 'Commit transaction ' . __METHOD__); |
174 | 174 | } |
175 | 175 | |
176 | - $this->db->getPDO()?->commit(); |
|
176 | + $this->db->getPDO() ? ->commit(); |
|
177 | 177 | |
178 | 178 | return; |
179 | 179 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $this->logger->log(LogLevel::INFO, 'Roll back transaction ' . __METHOD__); |
216 | 216 | } |
217 | 217 | |
218 | - $this->db->getPDO()?->rollBack(); |
|
218 | + $this->db->getPDO() ? ->rollBack(); |
|
219 | 219 | |
220 | 220 | return; |
221 | 221 | } |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | */ |
842 | 842 | protected function hasOffset(mixed $offset): bool |
843 | 843 | { |
844 | - return ($offset instanceof ExpressionInterface) || (ctype_digit((string)$offset) && (string)$offset !== '0'); |
|
844 | + return ($offset instanceof ExpressionInterface) || (ctype_digit((string) $offset) && (string) $offset !== '0'); |
|
845 | 845 | } |
846 | 846 | |
847 | 847 | /** |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | /** Remove duplicates */ |
1026 | 1026 | $constraints = array_combine( |
1027 | 1027 | array_map( |
1028 | - static function (Constraint $constraint) { |
|
1028 | + static function(Constraint $constraint) { |
|
1029 | 1029 | $columns = $constraint->getColumnNames() ?? []; |
1030 | 1030 | $columns = is_array($columns) ? $columns : [$columns]; |
1031 | 1031 | sort($columns, SORT_STRING); |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | $constraints = array_values( |
1044 | 1044 | array_filter( |
1045 | 1045 | $constraints, |
1046 | - static function (Constraint $constraint) use ($quoter, $columns, &$columnNames) { |
|
1046 | + static function(Constraint $constraint) use ($quoter, $columns, &$columnNames) { |
|
1047 | 1047 | $getColumnNames = $constraint->getColumnNames() ?? []; |
1048 | 1048 | $constraintColumnNames = array_map( |
1049 | 1049 | [$quoter, 'quoteColumnName'], |
@@ -159,7 +159,7 @@ |
||
159 | 159 | $count = 0; |
160 | 160 | |
161 | 161 | try { |
162 | - while ($count++ < $this->batchSize && ($row = $this->dataReader?->read())) { |
|
162 | + while ($count++ < $this->batchSize && ($row = $this->dataReader ? ->read())) { |
|
163 | 163 | $rows[] = $row; |
164 | 164 | } |
165 | 165 | } catch (PDOException $e) { |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | protected function bindPendingParams(): void |
34 | 34 | { |
35 | 35 | foreach ($this->params as $name => $value) { |
36 | - $this->pdoStatement?->bindValue($name, $value->getValue(), $value->getType()); |
|
36 | + $this->pdoStatement ? ->bindValue($name, $value->getValue(), $value->getType()); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | if ($length === null) { |
54 | - $this->pdoStatement?->bindParam($name, $value, $dataType); |
|
54 | + $this->pdoStatement ? ->bindParam($name, $value, $dataType); |
|
55 | 55 | } elseif ($driverOptions === null) { |
56 | - $this->pdoStatement?->bindParam($name, $value, $dataType, $length); |
|
56 | + $this->pdoStatement ? ->bindParam($name, $value, $dataType, $length); |
|
57 | 57 | } else { |
58 | - $this->pdoStatement?->bindParam($name, $value, $dataType, $length, $driverOptions); |
|
58 | + $this->pdoStatement ? ->bindParam($name, $value, $dataType, $length, $driverOptions); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | return $this; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | public function batchInsert(string $table, array $columns, iterable $rows): self |
216 | 216 | { |
217 | 217 | $table = $this->queryBuilder()->quoter()->quoteSql($table); |
218 | - $columns = array_map(fn ($column) => $this->queryBuilder()->quoter()->quoteSql($column), $columns); |
|
218 | + $columns = array_map(fn($column) => $this->queryBuilder()->quoter()->quoteSql($column), $columns); |
|
219 | 219 | $params = []; |
220 | 220 | $sql = $this->queryBuilder()->batchInsert($table, $columns, $rows, $params); |
221 | 221 | |
@@ -400,18 +400,18 @@ discard block |
||
400 | 400 | $this->prepare(false); |
401 | 401 | |
402 | 402 | try { |
403 | - $this->profiler?->begin((string)$rawSql, [__METHOD__]); |
|
403 | + $this->profiler ? ->begin((string) $rawSql, [__METHOD__]); |
|
404 | 404 | |
405 | 405 | $this->internalExecute($rawSql); |
406 | - $n = $this->pdoStatement?->rowCount(); |
|
406 | + $n = $this->pdoStatement ? ->rowCount(); |
|
407 | 407 | |
408 | - $this->profiler?->end((string)$rawSql, [__METHOD__]); |
|
408 | + $this->profiler ? ->end((string) $rawSql, [__METHOD__]); |
|
409 | 409 | |
410 | 410 | $this->refreshTableSchema(); |
411 | 411 | |
412 | 412 | return $n ?? 0; |
413 | 413 | } catch (Exception $e) { |
414 | - $this->profiler?->end((string)$rawSql, [__METHOD__]); |
|
414 | + $this->profiler ? ->end((string) $rawSql, [__METHOD__]); |
|
415 | 415 | throw $e; |
416 | 416 | } |
417 | 417 | } |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | |
432 | 432 | public function getParams(): array |
433 | 433 | { |
434 | - return array_map(static fn (mixed $value): mixed => $value->getValue(), $this->params); |
|
434 | + return array_map(static fn(mixed $value): mixed => $value->getValue(), $this->params); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /** |
@@ -663,11 +663,11 @@ discard block |
||
663 | 663 | $cacheKey = $this->getCacheKey($method, $fetchMode, $rawSql); |
664 | 664 | $result = $cache->getOrSet( |
665 | 665 | $cacheKey, |
666 | - static fn () => null, |
|
666 | + static fn() => null, |
|
667 | 667 | ); |
668 | 668 | |
669 | 669 | if (is_array($result) && isset($result[0])) { |
670 | - $this->logger?->log(LogLevel::DEBUG, 'Query result served from cache', [__CLASS__ . '::query']); |
|
670 | + $this->logger ? ->log(LogLevel::DEBUG, 'Query result served from cache', [__CLASS__ . '::query']); |
|
671 | 671 | |
672 | 672 | return $result[0]; |
673 | 673 | } |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | $this->prepare(true); |
678 | 678 | |
679 | 679 | try { |
680 | - $this->profiler?->begin((string)$rawSql, [__CLASS__ . '::query']); |
|
680 | + $this->profiler ? ->begin((string) $rawSql, [__CLASS__ . '::query']); |
|
681 | 681 | |
682 | 682 | $this->internalExecute($rawSql); |
683 | 683 | |
@@ -690,24 +690,24 @@ discard block |
||
690 | 690 | |
691 | 691 | $result = call_user_func_array([$this->pdoStatement, $method], (array) $fetchMode); |
692 | 692 | |
693 | - $this->pdoStatement?->closeCursor(); |
|
693 | + $this->pdoStatement ? ->closeCursor(); |
|
694 | 694 | } |
695 | 695 | |
696 | - $this->profiler?->end((string)$rawSql, [__CLASS__ . '::query']); |
|
696 | + $this->profiler ? ->end((string) $rawSql, [__CLASS__ . '::query']); |
|
697 | 697 | } catch (Exception $e) { |
698 | - $this->profiler?->end((string)$rawSql, [__CLASS__ . '::query']); |
|
698 | + $this->profiler ? ->end((string) $rawSql, [__CLASS__ . '::query']); |
|
699 | 699 | throw $e; |
700 | 700 | } |
701 | 701 | |
702 | 702 | if (isset($cache, $cacheKey, $info)) { |
703 | 703 | $cache->getOrSet( |
704 | 704 | $cacheKey, |
705 | - static fn (): array => [$result], |
|
705 | + static fn(): array => [$result], |
|
706 | 706 | $info[1], |
707 | 707 | $info[2] |
708 | 708 | ); |
709 | 709 | |
710 | - $this->logger?->log(LogLevel::DEBUG, 'Saved query result in cache', [__CLASS__ . '::query']); |
|
710 | + $this->logger ? ->log(LogLevel::DEBUG, 'Saved query result in cache', [__CLASS__ . '::query']); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | return $result; |