From 0bbdb5bbe7296f1d2319e1e8b5f3d5d66fe19d29 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 21 Dec 2023 19:27:06 +0300 Subject: [PATCH] Fix typos and wording (#249) --- README.md | 10 +- docs/en/testing.md | 7 +- docs/en/usage-standalone.md | 33 +++-- docs/en/usage-with-yii-console.md | 2 +- src/AbstractMigrationBuilder.php | 12 +- src/MigrationBuilder.php | 79 +++++------ src/Service/Generate/CreateService.php | 2 +- src/Service/Generate/FieldsParser.php | 2 +- src/Service/Generate/ForeignKeyFactory.php | 2 +- src/Service/MigrationService.php | 4 +- .../Service/AbstractMigrationServiceTest.php | 5 +- tests/Support/AssertTrait.php | 2 +- tests/Support/Factory/MssqlFactory.php | 1 - tests/Support/Factory/MysqlFactory.php | 1 - tests/Support/Factory/OracleFactory.php | 1 - tests/Support/Factory/PostgreSqlFactory.php | 2 - tests/Support/Factory/SqLiteFactory.php | 2 - tests/Support/Helper/ContainerHelper.php | 133 +++++++----------- tests/Support/Provider/ColumnTypes.php | 4 +- 19 files changed, 132 insertions(+), 172 deletions(-) diff --git a/README.md b/README.md index aba8a07d..45a22829 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,10 @@ Yii DB Migration allows you to manage database schema using migrations. Supports the following databases out of the box: - [MSSQL](https://www.microsoft.com/en-us/sql-server/sql-server-2019) of versions **2017, 2019, 2022**. -- [MySQL](https://www.mysql.com/) of versions **5.7 - 8.0**. -- [MariaDB](https://mariadb.org/) of versions **10.4 - 10.9**. -- [Oracle](https://www.oracle.com/database/) of versions **12c - 21c**. -- [PostgreSQL](https://www.postgresql.org/) of versions **9.6 - 15**. +- [MySQL](https://www.mysql.com/) of versions **5.7ā€“8.0**. +- [MariaDB](https://mariadb.org/) of versions **10.4ā€“10.9**. +- [Oracle](https://www.oracle.com/database/) of versions **12cā€“21c**. +- [PostgreSQL](https://www.postgresql.org/) of versions **9.6ā€“15**. - [SQLite](https://www.sqlite.org/index.html) of version **3.3 and above**. ## Requirements @@ -65,7 +65,7 @@ migrate:redo Redoes the last few migrations. migrate:up Applies new migrations. ``` -The create command allows to define fields for the table being created. +The create command allows defining fields for the table being created. ## Support diff --git a/docs/en/testing.md b/docs/en/testing.md index c1f922d6..425ac30e 100644 --- a/docs/en/testing.md +++ b/docs/en/testing.md @@ -16,8 +16,9 @@ All our packages have GitHub actions by default, so you can test your [contribut ## Docker images -For greater ease it is recommended to use Docker containers for each DBMS, for this you can use -the [docker-compose.yml](https://docs.docker.com/compose/compose-file/) file that in the root directory of each package. +For greater ease, it's recommended to use Docker containers for each DBMS. +For this, you can use the [docker-compose.yml](https://docs.docker.com/compose/compose-file/) file +in the root directory of each package. - [MSSQL 2022](https://github.com/yiisoft/db-mssql/blob/master/docker-compose.yml) - [MySQL 8](https://github.com/yiisoft/db-mysql/blob/master/docker-compose.yml) @@ -25,7 +26,7 @@ the [docker-compose.yml](https://docs.docker.com/compose/compose-file/) file tha - [Oracle 21](https://github.com/yiisoft/db-oracle/blob/master/docker-compose.yml) - [PostgreSQL 15](https://github.com/yiisoft/db-pgsql/blob/master/docker-compose.yml) -For running the Docker containers you can use the following command: +For running the Docker containers, you can use the following command: ```shell docker compose up -d diff --git a/docs/en/usage-standalone.md b/docs/en/usage-standalone.md index 41711758..0014b74f 100644 --- a/docs/en/usage-standalone.md +++ b/docs/en/usage-standalone.md @@ -2,24 +2,23 @@ 1. Copy configuration file `./vendor/yiisoft/db-migration/bin/yii-db-migration.php` to root folder of your project: -```shell -cp ./vendor/yiisoft/db-migration/bin/yii-db-migration.php ./yii-db-migration.php -``` + ```shell + cp ./vendor/yiisoft/db-migration/bin/yii-db-migration.php ./yii-db-migration.php + ``` 2. Define DB connection in configuration file (see -[Yii DB documentation](https://github.com/yiisoft/db/blob/master/docs/en/README.md#create-connection)). For example, MySQL connection: - -```php -'db' => new \Yiisoft\Db\Mysql\Connection( - new \Yiisoft\Db\Mysql\Driver('mysql:host=mysql;dbname=mydb', 'user', 'q1w2e3r4'), - new \Yiisoft\Db\Cache\SchemaCache(new \Yiisoft\Cache\ArrayCache()), -), -``` - -3. Optionally, modify other options in configuration file. Each option has a comment with description. - + [Yii DB documentation](https://github.com/yiisoft/db/blob/master/docs/en/README.md#create-connection)). + For example, MySQL connection: + ```php + 'db' => new \Yiisoft\Db\Mysql\Connection( + new \Yiisoft\Db\Mysql\Driver('mysql:host=mysql;dbname=mydb', 'user', 'q1w2e3r4'), + new \Yiisoft\Db\Cache\SchemaCache(new \Yiisoft\Cache\ArrayCache()), + ), + ``` + +3. Optionally, modify other options in the configuration file. Each option has a comment with description. 4. Run the console command without arguments to see the list of available migration commands: -```shell -./vendor/bin/yii-db-migration -``` + ```shell + ./vendor/bin/yii-db-migration + ``` diff --git a/docs/en/usage-with-yii-console.md b/docs/en/usage-with-yii-console.md index 97f4e2c2..067edbce 100644 --- a/docs/en/usage-with-yii-console.md +++ b/docs/en/usage-with-yii-console.md @@ -1,6 +1,6 @@ # Usage with Yii Console -In this example we use [yiisoft/app](https://github.com/yiisoft/app). +In this example, we use [yiisoft/app](https://github.com/yiisoft/app). First, configure DI container. Create `config/common/db.php` with the following content: diff --git a/src/AbstractMigrationBuilder.php b/src/AbstractMigrationBuilder.php index b5f760b8..09d1511f 100644 --- a/src/AbstractMigrationBuilder.php +++ b/src/AbstractMigrationBuilder.php @@ -92,7 +92,7 @@ public function boolean(): ColumnInterface /** * Creates a char column. * - * @param int|null $length the column size definition i.e. the maximum string length. + * @param int|null $length the column size definition, i.e., the maximum string length. * * This parameter will be ignored if not supported by the DBMS. * @@ -132,11 +132,11 @@ public function dateTime(int $precision = null): ColumnInterface * Creates a decimal column. * * @param int|null $precision The column value precision, which is usually the total number of digits. - * First parameter passed to the column type, e.g. DECIMAL(precision, scale). + * First parameter passed to the column type, e.g., DECIMAL(precision, scale). * * This parameter will be ignored if not supported by the DBMS. * @param int|null $scale The column value scale, which is usually the number of digits after the decimal point. - * Second parameter passed to the column type, e.g. DECIMAL(precision, scale). + * Second parameter passed to the column type, e.g., DECIMAL(precision, scale). * * This parameter will be ignored if not supported by the DBMS. * @@ -215,11 +215,11 @@ public function json(): ColumnInterface * Creates a money column. * * @param int|null $precision The column value precision, which is usually the total number of digits. First - * parameter passed to the column type, e.g. DECIMAL(precision, scale). + * parameter passed to the column type, e.g., DECIMAL(precision, scale). * * This parameter will be ignored if not supported by the DBMS. * @param int|null $scale The column value scale, which is usually the number of digits after the decimal point. - * Second parameter passed to the column type, e.g. DECIMAL(precision, scale). + * Second parameter passed to the column type, e.g., DECIMAL(precision, scale). * * This parameter will be ignored if not supported by the DBMS. * @@ -271,7 +271,7 @@ public function smallInteger(int $length = null): ColumnInterface /** * Creates a string column. * - * @param int|null $length The column size definition i.e. the maximum string length. + * @param int|null $length The column size definition, i.e., the maximum string length. * * This parameter will be ignored if not supported by the DBMS. * diff --git a/src/MigrationBuilder.php b/src/MigrationBuilder.php index 91c9091a..7f453738 100644 --- a/src/MigrationBuilder.php +++ b/src/MigrationBuilder.php @@ -67,7 +67,7 @@ public function execute(string $sql, array $params = []): void /** * Creates and executes an INSERT SQL statement. * - * The method will properly escape the column names, and bind the values to be inserted. + * The method will properly escape the column names and bind the values to be inserted. * * @param string $table The table that new rows will be inserted into. * @param array $columns The column data (name => value) to be inserted into the table. @@ -86,7 +86,7 @@ public function insert(string $table, array $columns): void /** * Creates and executes a batch INSERT SQL statement. * - * The method will properly escape the column names, and bind the values to be inserted. + * The method will properly escape the column names and bind the values to be inserted. * * @param string $table The table that new rows will be inserted into. * @param array $columns The column names. @@ -109,7 +109,7 @@ public function batchInsert(string $table, array $columns, iterable $rows): void * Creates and executes a command to insert rows into a database table if they do not already exist (matching unique * constraints), or update them if they do. * - * The method will properly escape the column names, and bind the values to be inserted. + * The method will properly escape the column names and bind the values to be inserted. * * @param string $table The table that new rows will be inserted into/updated in. * @param array|QueryInterface $insertColumns The column data (name => value) to insert into the table or an @@ -219,7 +219,7 @@ public function createTable(string $table, array $columns, string|null $options } /** - * Builds and executes a SQL statement for renaming a DB table. + * Builds and executes an SQL statement for renaming a DB table. * * @param string $table The table to be renamed. The name will be properly quoted by the method. * @param string $newName The new table name. The name will be properly quoted by the method. @@ -232,7 +232,7 @@ public function renameTable(string $table, string $newName): void } /** - * Builds and executes a SQL statement for dropping a DB table. + * Builds and executes an SQL statement for dropping a DB table. * * @param string $table The table to be dropped. The name will be properly quoted by the method. * @@ -248,7 +248,7 @@ public function dropTable(string $table): void } /** - * Builds and executes a SQL statement for truncating a DB table. + * Builds and executes an SQL statement for truncating a DB table. * * @param string $table The table to be truncated. The name will be properly quoted by the method. */ @@ -260,14 +260,14 @@ public function truncateTable(string $table): void } /** - * Builds and executes a SQL statement for adding a new DB column. + * Builds and executes an SQL statement for adding a new DB column. * * @param string $table The table that the new column will be added to. * The table name will be properly quoted by the method. * @param string $column The name of the new column. The name will be properly quoted by the method. * @param ColumnInterface|string $type The column type. The {@see QueryBuilder::getColumnType()} method - * will be invoked to convert abstract column type (if any) into the physical one. Anything that is not - * recognized as abstract type will be kept in the generated SQL. For example, 'string' will be turned + * will be invoked to convert an abstract column type (if any) into the physical one. Anything not + * recognized as an abstract type will be kept in the generated SQL. For example, 'string' will be turned * into 'varchar(255)', while 'string not null' will become 'varchar(255) not null'. */ public function addColumn(string $table, string $column, ColumnInterface|string $type): void @@ -287,7 +287,7 @@ public function addColumn(string $table, string $column, ColumnInterface|string } /** - * Builds and executes a SQL statement for dropping a DB column. + * Builds and executes an SQL statement for dropping a DB column. * * @param string $table The table whose column is to be dropped. The name will be properly quoted by the method. * @param string $column The name of the column to be dropped. The name will be properly quoted by the method. @@ -300,7 +300,7 @@ public function dropColumn(string $table, string $column): void } /** - * Builds and executes a SQL statement for renaming a column. + * Builds and executes an SQL statement for renaming a column. * * @param string $table The table whose column is to be renamed. The name will be properly quoted by the method. * @param string $name The old name of the column. The name will be properly quoted by the method. @@ -318,14 +318,13 @@ public function renameColumn(string $table, string $name, string $newName): void } /** - * Builds and executes a SQL statement for changing the definition of a column. + * Builds and executes an SQL statement for changing the definition of a column. * - * @param string $table The table whose column is to be changed. The table name will be properly quoted by the - * method. + * @param string $table The table whose column is to be changed. The method will properly quote the table name. * @param string $column The name of the column to be changed. The name will be properly quoted by the method. * @param ColumnInterface|string $type The new column type. - * The {@see \Yiisoft\Db\Query\QueryBuilder::getColumnType()} method will be invoked to convert abstract column - * type (if any) into the physical one. Anything that is not recognized as abstract type will be kept in the + * The {@see \Yiisoft\Db\Query\QueryBuilder::getColumnType()} method will be invoked to convert an abstract column + * type (if any) into the physical one. Anything not recognized as an abstract type will be kept in the * generated SQL. For example, 'string' will be turned into 'varchar(255)', while 'string not null' will become * 'varchar(255) not null'. * @@ -355,7 +354,7 @@ public function alterColumn(string $table, string $column, ColumnInterface|strin } /** - * Builds and executes a SQL statement for creating a primary key. + * Builds and executes an SQL statement for creating a primary key. * * The method will properly quote the table and column names. * @@ -379,7 +378,7 @@ public function addPrimaryKey(string $table, string $name, array|string $columns } /** - * Builds and executes a SQL statement for dropping a primary key. + * Builds and executes an SQL statement for dropping a primary key. * * @param string $table The table that the primary key constraint will be removed from. * @param string $name The name of the primary key constraint to be removed. @@ -396,7 +395,7 @@ public function dropPrimaryKey(string $table, string $name): void } /** - * Builds a SQL statement for adding a foreign key constraint to an existing table. + * Builds an SQL statement for adding a foreign key constraint to an existing table. * * The method will properly quote the table and column names. * @@ -407,10 +406,10 @@ public function dropPrimaryKey(string $table, string $name): void * @param string $refTable The table that the foreign key references to. * @param array|string $refColumns The name of the column that the foreign key references to. If there are multiple * columns, separate them with commas or use an array. - * @param string|null $delete The ON DELETE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, - * SET DEFAULT, SET NULL. - * @param string|null $update The ON UPDATE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, - * SET DEFAULT, SET NULL. + * @param string|null $delete The `ON DELETE` option. Most DBMS support these options: `RESTRICT`, `CASCADE`, + * `NO ACTION`, `SET DEFAULT`, `SET NULL`. + * @param string|null $update The `ON UPDATE` option. Most DBMS support these options: `RESTRICT`, `CASCADE`, + * `NO ACTION`, `SET DEFAULT`, `SET NULL`. * * @throws Exception * @throws InvalidConfigException @@ -450,11 +449,10 @@ public function addForeignKey( } /** - * Builds a SQL statement for dropping a foreign key constraint. + * Builds an SQL statement for dropping a foreign key constraint. * * @param string $table The table whose foreign is to be dropped. The name will be properly quoted by the method. - * @param string $name The name of the foreign key constraint to be dropped. The name will be properly quoted by the - * method. + * @param string $name The name of the foreign key constraint to be dropped. The method will properly quote the name. * * @throws Exception * @throws InvalidConfigException @@ -468,7 +466,7 @@ public function dropForeignKey(string $table, string $name): void } /** - * Builds and executes a SQL statement for creating a new index. + * Builds and executes an SQL statement for creating a new index. * * @param string $table The table that the new index will be created for. The table name will be properly quoted by * the method. @@ -476,8 +474,8 @@ public function dropForeignKey(string $table, string $name): void * @param array|string $columns The column(s) that should be included in the index. If there are multiple columns, * please separate them by commas or use an array. Each column name will be properly quoted by the method. Quoting * will be skipped for column names that include a left parenthesis "(". - * @param string|null $indexType Type of index supported DBMS - for example: UNIQUE, FULLTEXT, SPATIAL, BITMAP or - * `null` as default. + * @param string|null $indexType Type of index supported DBMS - for example, `UNIQUE`, `FULLTEXT`, `SPATIAL`, + * `BITMAP` or `null` as default. * @param string|null $indexMethod For setting index organization method (with 'USING', not all DBMS). * * @throws Exception @@ -504,7 +502,7 @@ public function createIndex( } /** - * Builds and executes a SQL statement for creating a view. + * Builds and executes an SQL statement for creating a view. * * @param string $viewName The name of the view to create. * @param QueryInterface|string $subQuery The select statement which defines the view. This can be either a string @@ -524,7 +522,7 @@ public function createView(string $viewName, QueryInterface|string $subQuery): v } /** - * Builds and executes a SQL statement for dropping an index. + * Builds and executes an SQL statement for dropping an index. * * @param string $table The table whose index is to be dropped. The name will be properly quoted by the method. * @param string $name The name of the index to be dropped. The name will be properly quoted by the method. @@ -547,7 +545,7 @@ public function dropIndex(string $table, string $name): void } /** - * Builds and executes a SQL statement for dropping a DB view. + * Builds and executes an SQL statement for dropping a DB view. * * @param string $viewName The name of the view to be dropped. * @@ -567,10 +565,8 @@ public function dropView(string $viewName): void /** * Builds and execute a SQL statement for adding comment to column. * - * @param string $table The table whose column is to be commented. The table name will be properly quoted by the - * method. - * @param string $column The name of the column to be commented. The column name will be properly quoted by the - * method. + * @param string $table The table whose column is to be commented. The method will properly quote the table name. + * @param string $column The name of the column to be commented. The method will properly quote the column name. * @param string $comment The text of the comment to be added. The comment will be properly quoted by the method. * * @throws Exception @@ -585,7 +581,7 @@ public function addCommentOnColumn(string $table, string $column, string $commen } /** - * Builds a SQL statement for adding comment to table. + * Builds an SQL statement for adding comment to table. * * @param string $table The table to be commented. The table name will be properly quoted by the method. * @param string $comment The text of the comment to be added. The comment will be properly quoted by the method. @@ -604,10 +600,8 @@ public function addCommentOnTable(string $table, string $comment): void /** * Builds and execute a SQL statement for dropping comment from column. * - * @param string $table The table whose column is to be commented. The table name will be properly quoted by the - * method. - * @param string $column The name of the column to be commented. The column name will be properly quoted by the - * method. + * @param string $table The table whose column is to be commented. The method will properly quote the table name. + * @param string $column The name of the column to be commented. The method will properly quote the column name. * * @throws Exception * @throws InvalidConfigException @@ -623,8 +617,7 @@ public function dropCommentFromColumn(string $table, string $column): void /** * Builds a SQL statement for dropping comment from table. * - * @param string $table The table whose column is to be commented. The table name will be properly quoted by the - * method. + * @param string $table The table whose column is to be commented. The method will properly quote the table name. * * @throws Exception * @throws InvalidConfigException diff --git a/src/Service/Generate/CreateService.php b/src/Service/Generate/CreateService.php index a5fed346..cfdff809 100644 --- a/src/Service/Generate/CreateService.php +++ b/src/Service/Generate/CreateService.php @@ -23,7 +23,7 @@ final class CreateService /** * @param bool $useTablePrefix Indicates whether the table names generated should consider the `tablePrefix` setting - * of the DB connection. For example, if the table name is `post` the generator will return `{{%post}}`. + * of the DB connection. For example, if the table name is `post`, the generator will return `{{%post}}`. */ public function __construct( private ConnectionInterface $db, diff --git a/src/Service/Generate/FieldsParser.php b/src/Service/Generate/FieldsParser.php index 860192df..0316ca2e 100644 --- a/src/Service/Generate/FieldsParser.php +++ b/src/Service/Generate/FieldsParser.php @@ -98,7 +98,7 @@ private function splitFieldIntoChunks(string $field): array } /** - * Adds default primary key to columns list if there's no primary key specified. + * Adds a default primary key to columns list if there's no primary key specified. * * @param Column[] $columns */ diff --git a/src/Service/Generate/ForeignKeyFactory.php b/src/Service/Generate/ForeignKeyFactory.php index 2384af2d..7cbb44ce 100644 --- a/src/Service/Generate/ForeignKeyFactory.php +++ b/src/Service/Generate/ForeignKeyFactory.php @@ -28,7 +28,7 @@ public function create( string|null $relatedColumn ): ForeignKey { /** - * We're trying to get it from table schema. + * We're trying to get it from the table schema. * * {@see https://github.com/yiisoft/yii2/issues/12748} */ diff --git a/src/Service/MigrationService.php b/src/Service/MigrationService.php index 26f8779b..84e4a7b8 100644 --- a/src/Service/MigrationService.php +++ b/src/Service/MigrationService.php @@ -183,10 +183,10 @@ public function setSourceNamespaces(array $value): void /** * The directory containing the migration update classes. * - * Migration classes located at this path should be declared without a namespace. + * Migration classes located on this path should be declared without a namespace. * Use {@see $newMigrationNamespace} property in case you are using namespaced migrations. * - * If you have set up {@see $newMigrationNamespace}, you may set this field to `null` in order to disable usage of migrations + * If you have set up {@see $newMigrationNamespace}, you may set this field to `null` to disable usage of migrations * that are not namespaced. * * In general, to load migrations from different locations, {@see $newMigrationNamespace} is the preferable solution as the diff --git a/tests/Common/Service/AbstractMigrationServiceTest.php b/tests/Common/Service/AbstractMigrationServiceTest.php index f2cc9154..6e0460a8 100644 --- a/tests/Common/Service/AbstractMigrationServiceTest.php +++ b/tests/Common/Service/AbstractMigrationServiceTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; +use ReflectionMethod; use Yiisoft\Db\Migration\Migrator; use Yiisoft\Db\Migration\Service\MigrationService; use Yiisoft\Db\Migration\Tests\Support\Helper\MigrationHelper; @@ -60,7 +61,7 @@ public function testGetNamespacesFromPathForNoHavingNamespacePath(): void { $migrationService = $this->container->get(MigrationService::class); - $getNamespaceFromPath = new \ReflectionMethod($migrationService, 'getNamespacesFromPath'); + $getNamespaceFromPath = new ReflectionMethod($migrationService, 'getNamespacesFromPath'); $getNamespaceFromPath->setAccessible(true); // No having namespace path @@ -77,7 +78,7 @@ public function testGetNamespacesFromPathForLongestPath(): void { $migrationService = $this->container->get(MigrationService::class); - $getNamespaceFromPath = new \ReflectionMethod($migrationService, 'getNamespacesFromPath'); + $getNamespaceFromPath = new ReflectionMethod($migrationService, 'getNamespacesFromPath'); $getNamespaceFromPath->setAccessible(true); /** diff --git a/tests/Support/AssertTrait.php b/tests/Support/AssertTrait.php index 1ca67e34..7b98c418 100644 --- a/tests/Support/AssertTrait.php +++ b/tests/Support/AssertTrait.php @@ -14,7 +14,7 @@ trait AssertTrait { /** - * Asserting two strings equality ignoring line endings. + * Asserting two strings are equal ignoring line endings. * * @param string $expected Expected string. * @param string $actual Actual string. diff --git a/tests/Support/Factory/MssqlFactory.php b/tests/Support/Factory/MssqlFactory.php index 7f8afc67..744af6c9 100644 --- a/tests/Support/Factory/MssqlFactory.php +++ b/tests/Support/Factory/MssqlFactory.php @@ -17,7 +17,6 @@ use Yiisoft\Db\Migration\Tests\Support\Helper\ContainerHelper; use function array_intersect; -use function dirname; final class MssqlFactory { diff --git a/tests/Support/Factory/MysqlFactory.php b/tests/Support/Factory/MysqlFactory.php index 73711281..f59d1913 100644 --- a/tests/Support/Factory/MysqlFactory.php +++ b/tests/Support/Factory/MysqlFactory.php @@ -17,7 +17,6 @@ use Yiisoft\Db\Migration\Tests\Support\Helper\ContainerHelper; use function array_intersect; -use function dirname; final class MysqlFactory { diff --git a/tests/Support/Factory/OracleFactory.php b/tests/Support/Factory/OracleFactory.php index 12394d32..5daed53d 100644 --- a/tests/Support/Factory/OracleFactory.php +++ b/tests/Support/Factory/OracleFactory.php @@ -17,7 +17,6 @@ use Yiisoft\Db\Migration\Tests\Support\Helper\ContainerHelper; use function array_intersect; -use function dirname; final class OracleFactory { diff --git a/tests/Support/Factory/PostgreSqlFactory.php b/tests/Support/Factory/PostgreSqlFactory.php index b6f7fadb..abc77848 100644 --- a/tests/Support/Factory/PostgreSqlFactory.php +++ b/tests/Support/Factory/PostgreSqlFactory.php @@ -16,8 +16,6 @@ use Yiisoft\Db\Migration\Tests\Support\Helper\ContainerConfig; use Yiisoft\Db\Migration\Tests\Support\Helper\ContainerHelper; -use function dirname; - final class PostgreSqlFactory { public static function createContainer(?ContainerConfig $config = null): ContainerInterface diff --git a/tests/Support/Factory/SqLiteFactory.php b/tests/Support/Factory/SqLiteFactory.php index 09beb2ea..c7a3b0c6 100644 --- a/tests/Support/Factory/SqLiteFactory.php +++ b/tests/Support/Factory/SqLiteFactory.php @@ -16,8 +16,6 @@ use Yiisoft\Db\Migration\Tests\Support\Helper\ContainerConfig; use Yiisoft\Db\Migration\Tests\Support\Helper\ContainerHelper; -use function dirname; - final class SqLiteFactory { public static function createContainer(?ContainerConfig $config = null): ContainerInterface diff --git a/tests/Support/Helper/ContainerHelper.php b/tests/Support/Helper/ContainerHelper.php index 47b2a075..f2968551 100644 --- a/tests/Support/Helper/ContainerHelper.php +++ b/tests/Support/Helper/ContainerHelper.php @@ -28,85 +28,58 @@ final class ContainerHelper */ public static function get(ContainerInterface $container, string $id, ContainerConfig $config): object { - switch ($id) { - case Injector::class: - return new Injector($container); - - case UpdateRunner::class: - return new UpdateRunner( - $container->get(Migrator::class), - ); - - case DownRunner::class: - return new DownRunner( - $container->get(Migrator::class), - ); - - case Migrator::class: - return new Migrator( - $container->get(ConnectionInterface::class), - $container->get(ConsoleMigrationInformer::class), - ); - - case MigrationService::class: - return new MigrationService( - $container->get(ConnectionInterface::class), - $container->get(Injector::class), - $container->get(Migrator::class), - ); - - case CreateService::class: - return new CreateService( - $container->get(ConnectionInterface::class), - $config->useTablePrefix, - ); - - case ConsoleMigrationInformer::class: - return new ConsoleMigrationInformer(); - - case CreateCommand::class: - return new CreateCommand( - $container->get(CreateService::class), - $container->get(MigrationService::class), - $container->get(Migrator::class), - ); - - case UpdateCommand::class: - return new UpdateCommand( - $container->get(UpdateRunner::class), - $container->get(MigrationService::class), - $container->get(Migrator::class), - ); - - case DownCommand::class: - return new DownCommand( - $container->get(DownRunner::class), - $container->get(MigrationService::class), - $container->get(Migrator::class), - ); - - case NewCommand::class: - return new NewCommand( - $container->get(MigrationService::class), - $container->get(Migrator::class), - ); - - case HistoryCommand::class: - return new HistoryCommand( - $container->get(MigrationService::class), - $container->get(Migrator::class), - ); - - case RedoCommand::class: - return new RedoCommand( - $container->get(MigrationService::class), - $container->get(Migrator::class), - $container->get(DownRunner::class), - $container->get(UpdateRunner::class), - ); - - default: - throw new NotFoundException($id); - } + return match ($id) { + Injector::class => new Injector($container), + UpdateRunner::class => new UpdateRunner( + $container->get(Migrator::class), + ), + DownRunner::class => new DownRunner( + $container->get(Migrator::class), + ), + Migrator::class => new Migrator( + $container->get(ConnectionInterface::class), + $container->get(ConsoleMigrationInformer::class), + ), + MigrationService::class => new MigrationService( + $container->get(ConnectionInterface::class), + $container->get(Injector::class), + $container->get(Migrator::class), + ), + CreateService::class => new CreateService( + $container->get(ConnectionInterface::class), + $config->useTablePrefix, + ), + ConsoleMigrationInformer::class => new ConsoleMigrationInformer(), + CreateCommand::class => new CreateCommand( + $container->get(CreateService::class), + $container->get(MigrationService::class), + $container->get(Migrator::class), + ), + UpdateCommand::class => new UpdateCommand( + $container->get(UpdateRunner::class), + $container->get(MigrationService::class), + $container->get(Migrator::class), + ), + DownCommand::class => new DownCommand( + $container->get(DownRunner::class), + $container->get(MigrationService::class), + $container->get(Migrator::class), + ), + NewCommand::class => new NewCommand( + $container->get(MigrationService::class), + $container->get(Migrator::class), + ), + HistoryCommand::class => new HistoryCommand( + $container->get(MigrationService::class), + $container->get(Migrator::class), + ), + RedoCommand::class => new RedoCommand( + $container->get(MigrationService::class), + $container->get(Migrator::class), + $container->get(DownRunner::class), + $container->get(UpdateRunner::class), + ), + default => throw new NotFoundException($id), + }; } } diff --git a/tests/Support/Provider/ColumnTypes.php b/tests/Support/Provider/ColumnTypes.php index 4c7ade2f..e8a07750 100644 --- a/tests/Support/Provider/ColumnTypes.php +++ b/tests/Support/Provider/ColumnTypes.php @@ -19,8 +19,8 @@ public function __construct(private PdoConnectionInterface $db) } /** - * This is not used as a dataprovider for testGetColumnType to speed up the test when used as dataprovider every - * single line will cause a reconnect with the database which is not needed here. + * This is not used as a data provider for `testGetColumnType` to speed up the test when used as data provider every + * single line will cause a reconnecting with the database which is not needed here. */ public function getColumnTypes(): array {