Skip to content
This repository was archived by the owner on Mar 9, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
}
},
"require": {
"php": ">=7.3",
"hyperf/db": "^2.1"
"php": ">=8.0",
"hyperf/db": "^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"hyperf/di": "^2.1",
"hyperf/testing": "^2.1",
"hyperf/utils": "^2.1",
"hyperf/di": "^3.0",
"hyperf/testing": "^3.0",
"hyperf/utils": "^3.0",
"mockery/mockery": "^1.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan": "^0.12|^1.8",
"phpunit/phpunit": ">=7.0",
"swoole/ide-helper": "dev-master",
"symfony/var-dumper": "^5.1"
Expand Down
28 changes: 9 additions & 19 deletions src/PgSQLConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@

class PgSQLConnection extends AbstractConnection
{
/**
* @var PostgreSQL
*/
protected $connection;

/**
* @var array
*/
protected $config = [
protected ?PostgreSQL $connection;

protected array $config = [
'driver' => PgSQLPool::class,
'host' => '127.0.0.1',
'port' => 5432,
Expand Down Expand Up @@ -139,16 +133,12 @@ public function fetch(string $query, array $bindings = [])

public function call(string $method, array $argument = [])
{
switch ($method) {
case 'beginTransaction':
return $this->connection->query('BEGIN');
case 'rollBack':
return $this->connection->query('ROLLBACK');
case 'commit':
return $this->connection->query('COMMIT');
}

return $this->connection->{$method}(...$argument);
return match ($method) {
'beginTransaction' => $this->connection->query('BEGIN'),
'rollBack' => $this->connection->query('ROLLBACK'),
'commit' => $this->connection->query('COMMIT'),
default => $this->connection->{$method}(...$argument),
};
}

public function run(Closure $closure)
Expand Down