diff --git a/composer.json b/composer.json index 33fe113..1b72f2d 100644 --- a/composer.json +++ b/composer.json @@ -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" diff --git a/src/PgSQLConnection.php b/src/PgSQLConnection.php index 834d800..1dc4e17 100644 --- a/src/PgSQLConnection.php +++ b/src/PgSQLConnection.php @@ -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, @@ -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)