From 87e9665845d07c80312b48940f55c512ffd42e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AC=A6=E6=B5=B7=E5=8D=87?= Date: Sat, 27 Aug 2022 18:23:52 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=8Bhyperf3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 12 ++++++------ src/PgSQLConnection.php | 28 +++++++++------------------- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/composer.json b/composer.json index 33fe113..fd77d5c 100644 --- a/composer.json +++ b/composer.json @@ -18,16 +18,16 @@ } }, "require": { - "php": ">=7.3", - "hyperf/db": "^2.1" + "php": "^7.3|^8.0", + "hyperf/db": "^2.1|^3.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.0", - "hyperf/di": "^2.1", - "hyperf/testing": "^2.1", - "hyperf/utils": "^2.1", + "hyperf/di": "^2.1|^3.0", + "hyperf/testing": "^2.1|^3.0", + "hyperf/utils": "^2.1|^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) From 65e8f7ae5db3ca80bc053c4491ae5dbdc0cdf531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AC=A6=E6=B5=B7=E5=8D=87?= Date: Sat, 27 Aug 2022 19:00:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=8Bhyperf3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index fd77d5c..1b72f2d 100644 --- a/composer.json +++ b/composer.json @@ -18,14 +18,14 @@ } }, "require": { - "php": "^7.3|^8.0", - "hyperf/db": "^2.1|^3.0" + "php": ">=8.0", + "hyperf/db": "^3.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.0", - "hyperf/di": "^2.1|^3.0", - "hyperf/testing": "^2.1|^3.0", - "hyperf/utils": "^2.1|^3.0", + "hyperf/di": "^3.0", + "hyperf/testing": "^3.0", + "hyperf/utils": "^3.0", "mockery/mockery": "^1.0", "phpstan/phpstan": "^0.12|^1.8", "phpunit/phpunit": ">=7.0",