Skip to content

Commit

Permalink
Fix a bunch of psalm errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Dec 26, 2023
1 parent 005a024 commit 4559efe
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/Db/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

use Exception;
use InvalidArgumentException;
use Migrations\Db\Literal;
use Migrations\Db\Table;
use Migrations\Db\Table\Column;
use Migrations\Util\Literal;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down
8 changes: 4 additions & 4 deletions src/Db/Adapter/AdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function setOutput(OutputInterface $output);
public function getOutput(): OutputInterface;

/**
* Returns a new Phinx\Db\Table\Column using the existent data domain.
* Returns a new Migrations\Db\Table\Column using the existent data domain.
*
* @param string $columnName The desired column name
* @param string $type The type for the column. Can be a data domain type.
Expand Down Expand Up @@ -360,8 +360,8 @@ public function hasTable(string $tableName): bool;
* Creates the specified database table.
*
* @param \Migrations\Db\Table\Table $table Table
* @param \Phinx\Db\Table\Column[] $columns List of columns in the table
* @param \Phinx\Db\Table\Index[] $indexes List of indexes for the table
* @param \Migrations\Db\Table\Column[] $columns List of columns in the table
* @param \Migrations\Db\Table\Index[] $indexes List of indexes for the table
* @return void
*/
public function createTable(Table $table, array $columns = [], array $indexes = []): void;
Expand All @@ -378,7 +378,7 @@ public function truncateTable(string $tableName): void;
* Returns table columns
*
* @param string $tableName Table name
* @return \Phinx\Db\Table\Column[]
* @return \Migrations\Db\Table\Column[]
*/
public function getColumns(string $tableName): array;

Expand Down
2 changes: 1 addition & 1 deletion src/Db/Adapter/MysqlAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ protected function getColumnSqlDefinition(Column $column): string
}

$values = $column->getValues();
if ($values && is_array($values)) {
if ($values) {
$def .= '(' . implode(', ', array_map(function ($value) {

Check warning on line 1353 in src/Db/Adapter/MysqlAdapter.php

View check run for this annotation

Codecov / codecov/patch

src/Db/Adapter/MysqlAdapter.php#L1351-L1353

Added lines #L1351 - L1353 were not covered by tests
// we special case NULL as it's not actually allowed an enum value,
// and we want MySQL to issue an error on the create statement, but
Expand Down
32 changes: 16 additions & 16 deletions src/Db/Adapter/PdoAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ public function createSchema(string $schemaName = 'public'): void
* @throws \BadMethodCallException
* @return void
*/
public function dropSchema(string $name): void
public function dropSchema(string $schemaName): void

Check warning on line 564 in src/Db/Adapter/PdoAdapter.php

View check run for this annotation

Codecov / codecov/patch

src/Db/Adapter/PdoAdapter.php#L564

Added line #L564 was not covered by tests
{
throw new BadMethodCallException('Dropping a schema is not supported');

Check warning on line 566 in src/Db/Adapter/PdoAdapter.php

View check run for this annotation

Codecov / codecov/patch

src/Db/Adapter/PdoAdapter.php#L566

Added line #L566 was not covered by tests
}
Expand Down Expand Up @@ -647,7 +647,7 @@ protected function getDefaultValueDefinition(mixed $default, ?string $columnType
* Executes all the ALTER TABLE instructions passed for the given table
*
* @param string $tableName The table name to use in the ALTER statement
* @param \Migrations\Db\Util\AlterInstructions $instructions The object containing the alter sequence
* @param \Migrations\Db\AlterInstructions $instructions The object containing the alter sequence
* @return void
*/
protected function executeAlterSteps(string $tableName, AlterInstructions $instructions): void

Check warning on line 653 in src/Db/Adapter/PdoAdapter.php

View check run for this annotation

Codecov / codecov/patch

src/Db/Adapter/PdoAdapter.php#L653

Added line #L653 was not covered by tests
Expand All @@ -670,7 +670,7 @@ public function addColumn(Table $table, Column $column): void
*
* @param \Migrations\Db\Table\Table $table Table
* @param \Migrations\Db\Table\Column $column Column
* @return \Migrations\Db\Util\AlterInstructions
* @return \Migrations\Db\AlterInstructions
*/
abstract protected function getAddColumnInstructions(Table $table, Column $column): AlterInstructions;

Expand All @@ -689,7 +689,7 @@ public function renameColumn(string $tableName, string $columnName, string $newC
* @param string $tableName Table name
* @param string $columnName Column Name
* @param string $newColumnName New Column Name
* @return \Migrations\Db\Util\AlterInstructions
* @return \Migrations\Db\AlterInstructions
*/
abstract protected function getRenameColumnInstructions(string $tableName, string $columnName, string $newColumnName): AlterInstructions;

Expand All @@ -708,7 +708,7 @@ public function changeColumn(string $tableName, string $columnName, Column $newC
* @param string $tableName Table name
* @param string $columnName Column Name
* @param \Migrations\Db\Table\Column $newColumn New Column
* @return \Migrations\Db\Util\AlterInstructions
* @return \Migrations\Db\AlterInstructions
*/
abstract protected function getChangeColumnInstructions(string $tableName, string $columnName, Column $newColumn): AlterInstructions;

Expand All @@ -726,7 +726,7 @@ public function dropColumn(string $tableName, string $columnName): void
*
* @param string $tableName Table name
* @param string $columnName Column Name
* @return \Migrations\Db\Util\AlterInstructions
* @return \Migrations\Db\AlterInstructions
*/
abstract protected function getDropColumnInstructions(string $tableName, string $columnName): AlterInstructions;

Expand All @@ -744,7 +744,7 @@ public function addIndex(Table $table, Index $index): void
*
* @param \Migrations\Db\Table\Table $table Table
* @param \Migrations\Db\Table\Index $index Index
* @return \Migrations\Db\Util\AlterInstructions
* @return \Migrations\Db\AlterInstructions
*/
abstract protected function getAddIndexInstructions(Table $table, Index $index): AlterInstructions;

Expand All @@ -762,7 +762,7 @@ public function dropIndex(string $tableName, $columns): void
*
* @param string $tableName The name of of the table where the index is
* @param string|string[] $columns Column(s)
* @return \Migrations\Db\Util\AlterInstructions
* @return \Migrations\Db\AlterInstructions
*/
abstract protected function getDropIndexByColumnsInstructions(string $tableName, string|array $columns): AlterInstructions;

Expand All @@ -780,7 +780,7 @@ public function dropIndexByName(string $tableName, string $indexName): void
*
* @param string $tableName The table name whe the index is
* @param string $indexName The name of the index
* @return \Migrations\Db\Util\AlterInstructions
* @return \Migrations\Db\AlterInstructions
*/
abstract protected function getDropIndexByNameInstructions(string $tableName, string $indexName): AlterInstructions;

Expand All @@ -798,7 +798,7 @@ public function addForeignKey(Table $table, ForeignKey $foreignKey): void
*
* @param \Migrations\Db\Table\Table $table The table to add the constraint to
* @param \Migrations\Db\Table\ForeignKey $foreignKey The foreign key to add
* @return \Migrations\Db\Util\AlterInstructions
* @return \Migrations\Db\AlterInstructions
*/
abstract protected function getAddForeignKeyInstructions(Table $table, ForeignKey $foreignKey): AlterInstructions;

Expand All @@ -821,7 +821,7 @@ public function dropForeignKey(string $tableName, array $columns, ?string $const
*
* @param string $tableName The table where the foreign key constraint is
* @param string $constraint Constraint name
* @return \Migrations\Db\Util\AlterInstructions
* @return \Migrations\Db\AlterInstructions
*/
abstract protected function getDropForeignKeyInstructions(string $tableName, string $constraint): AlterInstructions;

Expand All @@ -830,7 +830,7 @@ abstract protected function getDropForeignKeyInstructions(string $tableName, str
*
* @param string $tableName The table where the foreign key constraint is
* @param string[] $columns The list of column names
* @return \Migrations\Db\Util\AlterInstructions
* @return \Migrations\Db\AlterInstructions
*/
abstract protected function getDropForeignKeyByColumnsInstructions(string $tableName, array $columns): AlterInstructions;

Expand All @@ -847,16 +847,16 @@ public function dropTable(string $tableName): void
* Returns the instructions to drop the specified database table.
*
* @param string $tableName Table name
* @return \Migrations\Db\Util\AlterInstructions
* @return \Migrations\Db\AlterInstructions
*/
abstract protected function getDropTableInstructions(string $tableName): AlterInstructions;

/**
* @inheritdoc
*/
public function renameTable(string $tableName, string $newTableName): void
public function renameTable(string $tableName, string $newName): void

Check warning on line 857 in src/Db/Adapter/PdoAdapter.php

View check run for this annotation

Codecov / codecov/patch

src/Db/Adapter/PdoAdapter.php#L857

Added line #L857 was not covered by tests
{
$instructions = $this->getRenameTableInstructions($tableName, $newTableName);
$instructions = $this->getRenameTableInstructions($tableName, $newName);
$this->executeAlterSteps($tableName, $instructions);

Check warning on line 860 in src/Db/Adapter/PdoAdapter.php

View check run for this annotation

Codecov / codecov/patch

src/Db/Adapter/PdoAdapter.php#L859-L860

Added lines #L859 - L860 were not covered by tests
}

Expand All @@ -865,7 +865,7 @@ public function renameTable(string $tableName, string $newTableName): void
*
* @param string $tableName Table name
* @param string $newTableName New Name
* @return \Migrations\Db\Util\AlterInstructions
* @return \Migrations\Db\AlterInstructions
*/
abstract protected function getRenameTableInstructions(string $tableName, string $newTableName): AlterInstructions;

Expand Down
30 changes: 15 additions & 15 deletions src/Db/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@
class Table
{
/**
* @var \Phinx\Db\Table\Table
* @var \Migrations\Db\Table\Table
*/
protected TableValue $table;

/**
* @var \Phinx\Db\Adapter\AdapterInterface|null
* @var \Migrations\Db\Adapter\AdapterInterface|null
*/
protected ?AdapterInterface $adapter = null;

/**
* @var \Phinx\Db\Plan\Intent
* @var \Migrations\Db\Plan\Intent
*/
protected Intent $actions;

Expand All @@ -61,7 +61,7 @@ class Table
/**
* @param string $name Table Name
* @param array<string, mixed> $options Options
* @param \Phinx\Db\Adapter\AdapterInterface|null $adapter Database Adapter
* @param \Migrations\Db\Adapter\AdapterInterface|null $adapter Database Adapter
*/
public function __construct(string $name, array $options = [], ?AdapterInterface $adapter = null)
{
Expand Down Expand Up @@ -96,7 +96,7 @@ public function getOptions(): array
/**
* Gets the table name and options as an object
*
* @return \Phinx\Db\Table\Table
* @return \Migrations\Db\Table\Table
*/
public function getTable(): TableValue

Check warning on line 101 in src/Db/Table.php

View check run for this annotation

Codecov / codecov/patch

src/Db/Table.php#L101

Added line #L101 was not covered by tests
{
Expand All @@ -106,7 +106,7 @@ public function getTable(): TableValue
/**
* Sets the database adapter.
*
* @param \Phinx\Db\Adapter\AdapterInterface $adapter Database Adapter
* @param \Migrations\Db\Adapter\AdapterInterface $adapter Database Adapter
* @return $this
*/
public function setAdapter(AdapterInterface $adapter)
Expand All @@ -120,7 +120,7 @@ public function setAdapter(AdapterInterface $adapter)
* Gets the database adapter.
*
* @throws \RuntimeException
* @return \Phinx\Db\Adapter\AdapterInterface
* @return \Migrations\Db\Adapter\AdapterInterface
*/
public function getAdapter(): AdapterInterface
{
Expand Down Expand Up @@ -217,7 +217,7 @@ public function changeComment(?string $comment)
/**
* Gets an array of the table columns.
*
* @return \Phinx\Db\Table\Column[]
* @return \Migrations\Db\Table\Column[]
*/
public function getColumns(): array

Check warning on line 222 in src/Db/Table.php

View check run for this annotation

Codecov / codecov/patch

src/Db/Table.php#L222

Added line #L222 was not covered by tests
{
Expand All @@ -228,7 +228,7 @@ public function getColumns(): array
* Gets a table column if it exists.
*
* @param string $name Column name
* @return \Phinx\Db\Table\Column|null
* @return \Migrations\Db\Table\Column|null
*/
public function getColumn(string $name): ?Column

Check warning on line 233 in src/Db/Table.php

View check run for this annotation

Codecov / codecov/patch

src/Db/Table.php#L233

Added line #L233 was not covered by tests
{
Expand Down Expand Up @@ -294,8 +294,8 @@ public function reset(): void
*
* Valid options can be: limit, default, null, precision or scale.
*
* @param string|\Phinx\Db\Table\Column $columnName Column Name
* @param string|\Phinx\Util\Literal|null $type Column Type
* @param string|\Migrations\Db\Table\Column $columnName Column Name
* @param string|\Migrations\Db\Literal|null $type Column Type
* @param array<string, mixed> $options Column Options
* @throws \InvalidArgumentException
* @return $this
Expand Down Expand Up @@ -358,7 +358,7 @@ public function renameColumn(string $oldName, string $newName)
* Change a table column type.
*
* @param string $columnName Column Name
* @param string|\Phinx\Db\Table\Column|\Phinx\Util\Literal $newColumnType New Column Type
* @param string|\Migrations\Db\Table\Column|\Migrations\Db\Literal $newColumnType New Column Type
* @param array<string, mixed> $options Options
* @return $this
*/
Expand Down Expand Up @@ -390,7 +390,7 @@ public function hasColumn(string $columnName): bool
*
* In $options you can specify unique = true/false, and name (index name).
*
* @param string|array|\Phinx\Db\Table\Index $columns Table Column(s)
* @param string|array|\Migrations\Db\Table\Index $columns Table Column(s)
* @param array<string, mixed> $options Index Options
* @return $this
*/
Expand Down Expand Up @@ -459,7 +459,7 @@ public function hasIndexByName(string $indexName): bool
* on_update, constraint = constraint name.
*
* @param string|string[] $columns Columns
* @param string|\Phinx\Db\Table\Table $referencedTable Referenced Table
* @param string|\Migrations\Db\Table\Table $referencedTable Referenced Table
* @param string|string[] $referencedColumns Referenced Columns
* @param array<string, mixed> $options Options
* @return $this
Expand All @@ -480,7 +480,7 @@ public function addForeignKey(string|array $columns, string|TableValue $referenc
*
* @param string $name The constraint name
* @param string|string[] $columns Columns
* @param string|\Phinx\Db\Table\Table $referencedTable Referenced Table
* @param string|\Migrations\Db\Table\Table $referencedTable Referenced Table
* @param string|string[] $referencedColumns Referenced Columns
* @param array<string, mixed> $options Options
* @return $this
Expand Down

0 comments on commit 4559efe

Please sign in to comment.