diff --git a/CHANGELOG.md b/CHANGELOG.md index 13e2edc9..d1e20be6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,8 @@ - Enh #354: Separate column type constants (@Tigrov) - New #355: Realize `ColumnBuilder` class (@Tigrov) - Enh #357: Update according changes in `ColumnSchemaInterface` (@Tigrov) -- New #358: Add `ColumnDefinitionBuilder` class (@Tigrov) +- New #358: Add `ColumnDefinitionBuilder` class (@Tigrov) +- Enh #359: Refactor `Dsn` class (@Tigrov) ## 1.2.0 March 21, 2024 diff --git a/src/Dsn.php b/src/Dsn.php index 77b92b02..263f3fff 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 = 'mysql', + string $host = '127.0.0.1', string|null $databaseName = null, string $port = '3306', array $options = [] diff --git a/tests/Support/TestTrait.php b/tests/Support/TestTrait.php index 483b57f0..6bb30459 100644 --- a/tests/Support/TestTrait.php +++ b/tests/Support/TestTrait.php @@ -27,7 +27,7 @@ protected function getConnection(bool $fixture = false): PdoConnectionInterface protected static function getDb(): PdoConnectionInterface { - $dsn = (new Dsn('mysql', '127.0.0.1', 'yiitest', '3306', ['charset' => 'utf8mb4']))->asString(); + $dsn = (new Dsn(databaseName: 'yiitest', options: ['charset' => 'utf8mb4']))->asString(); return new Connection(new Driver($dsn, 'root', ''), DbHelper::getSchemaCache()); } @@ -35,7 +35,7 @@ protected static function getDb(): PdoConnectionInterface protected function getDsn(): string { if ($this->dsn === '') { - $this->dsn = (new Dsn('mysql', '127.0.0.1', 'yiitest', '3306', ['charset' => 'utf8mb4']))->asString(); + $this->dsn = (new Dsn(databaseName: 'yiitest', options: ['charset' => 'utf8mb4']))->asString(); } return $this->dsn;