Skip to content

Commit

Permalink
Rename ColumnSchemaBuilder::class to AbstractColumnSchemaBuilder::cla…
Browse files Browse the repository at this point in the history
…ss. (#184)

* Rename ColumnSchemaBuilder::class to AbstractColumnSchemaBuilder::class.
  • Loading branch information
terabytesoftw committed Jan 12, 2023
1 parent e8c70e1 commit 10cf6d1
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 34 deletions.
5 changes: 2 additions & 3 deletions src/ColumnSchemaBuilder.php
Expand Up @@ -4,10 +4,9 @@

namespace Yiisoft\Db\Sqlite;

use Stringable;
use Yiisoft\Db\Schema\ColumnSchemaBuilder as AbstractColumnSchemaBuilder;
use Yiisoft\Db\Schema\AbstractColumnSchemaBuilder;

final class ColumnSchemaBuilder extends AbstractColumnSchemaBuilder implements Stringable
final class ColumnSchemaBuilder extends AbstractColumnSchemaBuilder
{
/**
* Builds the unsigned string for column. Defaults to unsupported.
Expand Down
4 changes: 2 additions & 2 deletions src/DDLQueryBuilder.php
Expand Up @@ -9,7 +9,7 @@
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\QueryBuilder\AbstractDDLQueryBuilder;
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
use Yiisoft\Db\Schema\ColumnSchemaBuilder;
use Yiisoft\Db\Schema\ColumnSchemaBuilderInterface;
use Yiisoft\Db\Schema\QuoterInterface;
use Yiisoft\Db\Schema\SchemaInterface;

Expand Down Expand Up @@ -91,7 +91,7 @@ public function addUnique(string $name, string $table, array|string $columns): s
/**
* @throws NotSupportedException
*/
public function alterColumn(string $table, string $column, ColumnSchemaBuilder|string $type): string
public function alterColumn(string $table, string $column, ColumnSchemaBuilderInterface|string $type): string
{
throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.');
}
Expand Down
84 changes: 55 additions & 29 deletions src/Schema.php
Expand Up @@ -17,6 +17,7 @@
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Expression\Expression;
use Yiisoft\Db\Schema\AbstractSchema;
use Yiisoft\Db\Schema\ColumnSchemaBuilderInterface;
use Yiisoft\Db\Schema\ColumnSchemaInterface;
use Yiisoft\Db\Schema\TableSchemaInterface;
use Yiisoft\Db\Transaction\TransactionInterface;
Expand Down Expand Up @@ -125,7 +126,9 @@ final class Schema extends AbstractSchema
*
* @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema.
*
* @throws Exception|InvalidConfigException|Throwable
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*
* @return array All table names in the database. The names have NO schema name prefix.
*/
Expand All @@ -143,7 +146,10 @@ protected function findTableNames(string $schema = ''): array
*
* @param string $name table name.
*
* @throws Exception|InvalidArgumentException|InvalidConfigException|Throwable
* @throws Exception
* @throws InvalidArgumentException
* @throws InvalidConfigException
* @throws Throwable
*
* @return TableSchemaInterface|null DBMS-dependent table metadata, `null` if the table does not exist.
*/
Expand All @@ -168,7 +174,10 @@ protected function loadTableSchema(string $name): TableSchemaInterface|null
*
* @param string $tableName table name.
*
* @throws Exception|InvalidArgumentException|InvalidConfigException|Throwable
* @throws Exception
* @throws InvalidArgumentException
* @throws InvalidConfigException
* @throws Throwable
*
* @return Constraint|null primary key for the given table, `null` if the table has no primary key.
*/
Expand All @@ -184,7 +193,9 @@ protected function loadTablePrimaryKey(string $tableName): Constraint|null
*
* @param string $tableName table name.
*
* @throws Exception|InvalidConfigException|Throwable
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*
* @return ForeignKeyConstraint[] foreign keys for the given table.
*/
Expand Down Expand Up @@ -219,7 +230,10 @@ protected function loadTableForeignKeys(string $tableName): array
*
* @param string $tableName table name.
*
* @throws Exception|InvalidArgumentException|InvalidConfigException|Throwable
* @throws Exception
* @throws InvalidArgumentException
* @throws InvalidConfigException
* @throws Throwable
*
* @return array indexes for the given table.
*
Expand All @@ -237,7 +251,10 @@ protected function loadTableIndexes(string $tableName): array
*
* @param string $tableName table name.
*
* @throws Exception|InvalidArgumentException|InvalidConfigException|Throwable
* @throws Exception
* @throws InvalidArgumentException
* @throws InvalidConfigException
* @throws Throwable
*
* @return array unique constraints for the given table.
*
Expand All @@ -255,7 +272,10 @@ protected function loadTableUniques(string $tableName): array
*
* @param string $tableName table name.
*
* @throws Exception|InvalidArgumentException|InvalidConfigException|Throwable
* @throws Exception
* @throws InvalidArgumentException
* @throws InvalidConfigException
* @throws Throwable
*
* @return CheckConstraint[] check constraints for the given table.
*/
Expand Down Expand Up @@ -315,20 +335,10 @@ protected function loadTableDefaultValues(string $tableName): array
throw new NotSupportedException('SQLite does not support default value constraints.');
}

/**
* Create a column schema builder instance giving the type and value precision.
*
* This method may be overridden by child classes to create a DBMS-specific column schema builder.
*
* @param string $type type of the column. See {@see ColumnSchemaBuilder::$type}.
* @param array|int|string|null $length length or precision of the column. See {@see ColumnSchemaBuilder::$length}.
*
* @return ColumnSchemaBuilder column schema builder instance.
*
* @psalm-param string[]|int[]|int|null|string $length
*/
public function createColumnSchemaBuilder(string $type, array|int|string $length = null): ColumnSchemaBuilder
{
public function createColumnSchemaBuilder(
string $type,
array|int|string $length = null
): ColumnSchemaBuilderInterface {
return new ColumnSchemaBuilder($type, $length);
}

Expand All @@ -337,7 +347,9 @@ public function createColumnSchemaBuilder(string $type, array|int|string $length
*
* @param TableSchemaInterface $table the table metadata.
*
* @throws Exception|InvalidConfigException|Throwable
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*
* @return bool whether the table exists in the database.
*/
Expand Down Expand Up @@ -370,7 +382,9 @@ protected function findColumns(TableSchemaInterface $table): bool
*
* @param TableSchemaInterface $table the table metadata.
*
* @throws Exception|InvalidConfigException|Throwable
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*/
protected function findConstraints(TableSchemaInterface $table): void
{
Expand Down Expand Up @@ -404,7 +418,9 @@ protected function findConstraints(TableSchemaInterface $table): void
*
* @param TableSchemaInterface $table the table metadata.
*
* @throws Exception|InvalidConfigException|Throwable
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*
* @return array all unique indexes for the given table.
*/
Expand Down Expand Up @@ -506,7 +522,9 @@ protected function loadColumnSchema(array $info): ColumnSchemaInterface
*
* @param string $tableName table name.
*
* @throws Exception|InvalidConfigException|Throwable
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*/
private function loadTableColumnsInfo(string $tableName): array
{
Expand All @@ -523,7 +541,9 @@ private function loadTableColumnsInfo(string $tableName): array
* @param string $tableName table name.
* @param string $returnType return type: (primaryKey, indexes, uniques).
*
* @throws Exception|InvalidConfigException|Throwable
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*
* @psalm-return (Constraint|IndexConstraint)[]|Constraint|null
*/
Expand Down Expand Up @@ -598,7 +618,9 @@ private function createColumnSchema(): ColumnSchemaInterface
}

/**
* @throws Exception|InvalidConfigException|Throwable
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*/
private function getPragmaForeignKeyList(string $tableName): array
{
Expand All @@ -608,7 +630,9 @@ private function getPragmaForeignKeyList(string $tableName): array
}

/**
* @throws Exception|InvalidConfigException|Throwable
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*/
private function getPragmaIndexInfo(string $name): array
{
Expand All @@ -635,7 +659,9 @@ private function getPragmaIndexList(string $tableName): array
}

/**
* @throws Exception|InvalidConfigException|Throwable
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*/
private function getPragmaTableInfo(string $tableName): array
{
Expand Down

0 comments on commit 10cf6d1

Please sign in to comment.