From 030512e54c4001423f304c36365c1baf41a161f1 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Fri, 18 Oct 2024 09:59:47 +0700 Subject: [PATCH 1/4] Refactor `Dsn` class --- src/Dsn.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Dsn.php b/src/Dsn.php index 7cfb71166..85cfd65aa 100644 --- a/src/Dsn.php +++ b/src/Dsn.php @@ -14,11 +14,11 @@ final class Dsn extends AbstractDsn { /** - * @psalm-param string[] $options + * @psalm-param array $options */ public function __construct( - string $driver, - string $host, + string $driver = 'pgsql', + string $host = 'localhost', string|null $databaseName = 'postgres', string $port = '5432', array $options = [] From ce4f6a7fe3ea60cd7d55ae0e2d532565fcbccead Mon Sep 17 00:00:00 2001 From: Tigrov Date: Fri, 18 Oct 2024 10:06:30 +0700 Subject: [PATCH 2/4] Refactor `Dsn` class --- tests/Support/TestTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Support/TestTrait.php b/tests/Support/TestTrait.php index d58172805..293cfa7de 100644 --- a/tests/Support/TestTrait.php +++ b/tests/Support/TestTrait.php @@ -36,7 +36,7 @@ protected function getConnection(bool $fixture = false): PdoConnectionInterface protected static function getDb(): PdoConnectionInterface { - $dsn = (new Dsn('pgsql', '127.0.0.1', 'yiitest', '5432'))->asString(); + $dsn = (new Dsn(databaseName: 'yiitest'))->asString(); return new Connection(new Driver($dsn, 'root', 'root'), DbHelper::getSchemaCache()); } @@ -44,7 +44,7 @@ protected static function getDb(): PdoConnectionInterface protected function getDsn(): string { if ($this->dsn === '') { - $this->dsn = (new Dsn('pgsql', '127.0.0.1', 'yiitest', '5432'))->asString(); + $this->dsn = (new Dsn(databaseName: 'yiitest'))->asString(); } return $this->dsn; From cb19037053d03a80c481ed4124d9b37fdd4d2e1c Mon Sep 17 00:00:00 2001 From: Tigrov Date: Fri, 18 Oct 2024 10:16:06 +0700 Subject: [PATCH 3/4] Change `localhost` to `127.0.0.1` --- src/Dsn.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dsn.php b/src/Dsn.php index 85cfd65aa..672ba8eac 100644 --- a/src/Dsn.php +++ b/src/Dsn.php @@ -18,7 +18,7 @@ final class Dsn extends AbstractDsn */ public function __construct( string $driver = 'pgsql', - string $host = 'localhost', + string $host = '127.0.0.1', string|null $databaseName = 'postgres', string $port = '5432', array $options = [] From c07385f3a8f550907e41a913d5bff1e4a6024692 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Fri, 18 Oct 2024 10:22:33 +0700 Subject: [PATCH 4/4] Add line to CHANGELOG.md [skip ci] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eac161d8..cf9826f10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - New #360: Realize `ColumnBuilder` class (@Tigrov) - Enh #362: Update according changes in `ColumnSchemaInterface` (@Tigrov) - New #364: Add `ColumnDefinitionBuilder` class (@Tigrov) +- Enh #365: Refactor `Dsn` class (@Tigrov) ## 1.3.0 March 21, 2024