Skip to content

Commit

Permalink
fix phpcs, stan, and psalm
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Dec 7, 2023
1 parent fae0341 commit 804e6bc
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
8 changes: 4 additions & 4 deletions src/Db/Action/AddColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

namespace Migrations\Db\Action;

use Migrations\Db\Literal;
use Migrations\Db\Table\Column;
use Migrations\Db\Table\Table;
use Migrations\Db\Literal;

class AddColumn extends Action
{
Expand Down Expand Up @@ -40,16 +40,16 @@ public function __construct(Table $table, Column $column)
* @param string $columnName The column name
* @param string|\Migrations\Db\Literal $type The column type
* @param array<string, mixed> $options The column options
* @return static
* @return self
*/
public static function build(Table $table, string $columnName, string|Literal $type, array $options = []): static
public static function build(Table $table, string $columnName, string|Literal $type, array $options = []): self
{
$column = new Column();
$column->setName($columnName);
$column->setType($type);
$column->setOptions($options); // map options to column methods

return new static($table, $column);
return new AddColumn($table, $column);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Db/Action/AddForeignKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public function __construct(Table $table, ForeignKey $fk)
* @param string|string[] $referencedColumns The columns in the referenced table
* @param array<string, mixed> $options Extra options for the foreign key
* @param string|null $name The name of the foreign key
* @return static
* @return self
*/
public static function build(Table $table, string|array $columns, Table|string $referencedTable, string|array $referencedColumns = ['id'], array $options = [], ?string $name = null): static
public static function build(Table $table, string|array $columns, Table|string $referencedTable, string|array $referencedColumns = ['id'], array $options = [], ?string $name = null): self
{
if (is_string($referencedColumns)) {
$referencedColumns = [$referencedColumns]; // str to array
Expand All @@ -64,7 +64,7 @@ public static function build(Table $table, string|array $columns, Table|string $
$fk->setConstraint($name);
}

return new static($table, $fk);
return new AddForeignKey($table, $fk);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/Db/Action/AddIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@ public function __construct(Table $table, Index $index)
* @param \Migrations\Db\Table\Table $table The table to add the index to
* @param string|string[]|\Migrations\Db\Table\Index $columns The columns to index
* @param array<string, mixed> $options Additional options for the index creation
* @return static
* @return self
*/
public static function build(Table $table, string|array|Index $columns, array $options = []): static
public static function build(Table $table, string|array|Index $columns, array $options = []): self
{
// create a new index object if strings or an array of strings were supplied
$index = $columns;

if (!$columns instanceof Index) {
if (!($columns instanceof Index)) {
$index = new Index();

$index->setColumns($columns);
$index->setOptions($options);
} else {
$index = $columns;
}

return new static($table, $index);
return new AddIndex($table, $index);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/Db/Action/ChangeColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

namespace Migrations\Db\Action;

use Migrations\Db\Literal;
use Migrations\Db\Table\Column;
use Migrations\Db\Table\Table;
use Migrations\Db\Literal;

class ChangeColumn extends Action
{
Expand Down Expand Up @@ -42,7 +42,7 @@ public function __construct(Table $table, string $columnName, Column $column)
$this->column = $column;

// if the name was omitted use the existing column name
if ($column->getName() === null || strlen($column->getName()) === 0) {
if ($column->getName() === null || strlen((string)$column->getName()) === 0) {
$column->setName($columnName);
}
}
Expand All @@ -55,16 +55,16 @@ public function __construct(Table $table, string $columnName, Column $column)
* @param string $columnName The name of the column to change
* @param string|\Migrations\Db\Literal $type The type of the column
* @param array<string, mixed> $options Additional options for the column
* @return static
* @return self
*/
public static function build(Table $table, string $columnName, string|Literal $type, array $options = []): static
public static function build(Table $table, string $columnName, string|Literal $type, array $options = []): self
{
$column = new Column();
$column->setName($columnName);
$column->setType($type);
$column->setOptions($options); // map options to column methods

return new static($table, $columnName, $column);
return new ChangeColumn($table, $columnName, $column);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Db/Action/DropForeignKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public function __construct(Table $table, ForeignKey $foreignKey)
* @param \Migrations\Db\Table\Table $table The table to delete the foreign key from
* @param string|string[] $columns The columns participating in the foreign key
* @param string|null $constraint The constraint name
* @return static
* @return self
*/
public static function build(Table $table, string|array $columns, ?string $constraint = null): static
public static function build(Table $table, string|array $columns, ?string $constraint = null): self
{
if (is_string($columns)) {
$columns = [$columns];
Expand All @@ -54,7 +54,7 @@ public static function build(Table $table, string|array $columns, ?string $const
$foreignKey->setConstraint($constraint);
}

return new static($table, $foreignKey);
return new DropForeignKey($table, $foreignKey);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/Db/Action/DropIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ public function __construct(Table $table, Index $index)
*
* @param \Migrations\Db\Table\Table $table The table where the index is
* @param string[] $columns the indexed columns
* @return static
* @return self
*/
public static function build(Table $table, array $columns = []): static
public static function build(Table $table, array $columns = []): self
{
$index = new Index();
$index->setColumns($columns);

return new static($table, $index);
return new DropIndex($table, $index);
}

/**
Expand All @@ -54,14 +54,14 @@ public static function build(Table $table, array $columns = []): static
*
* @param \Migrations\Db\Table\Table $table The table where the index is
* @param string $name The name of the index
* @return static
* @return self
*/
public static function buildFromName(Table $table, string $name): static
public static function buildFromName(Table $table, string $name): self
{
$index = new Index();
$index->setName($name);

return new static($table, $index);
return new DropIndex($table, $index);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Db/Action/RemoveColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ public function __construct(Table $table, Column $column)
*
* @param \Migrations\Db\Table\Table $table The table where the column is
* @param string $columnName The name of the column to drop
* @return static
* @return self
*/
public static function build(Table $table, string $columnName): static
public static function build(Table $table, string $columnName): self
{
$column = new Column();
$column->setName($columnName);

return new static($table, $column);
return new RemoveColumn($table, $column);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Db/Action/RenameColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ public function __construct(Table $table, Column $column, string $newName)
* @param \Migrations\Db\Table\Table $table The table where the column is
* @param string $columnName The name of the column to be changed
* @param string $newName The new name for the column
* @return static
* @return self
*/
public static function build(Table $table, string $columnName, string $newName): static
public static function build(Table $table, string $columnName, string $newName): self
{
$column = new Column();
$column->setName($columnName);

return new static($table, $column, $newName);
return new RenameColumn($table, $column, $newName);
}

/**
Expand Down

0 comments on commit 804e6bc

Please sign in to comment.