@@ -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; |