Skip to content

Commit 3cfd71a

Browse files
committed
more typing
1 parent 937871c commit 3cfd71a

18 files changed

+178
-180
lines changed

src/Phinx/Db/Action/AddIndex.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ public static function build(Table $table, $columns, array $options = []): AddIn
4848
if (!$columns instanceof Index) {
4949
$index = new Index();
5050

51-
if (is_string($columns)) {
52-
$columns = [$columns]; // str to array
53-
}
54-
5551
$index->setColumns($columns);
5652
$index->setOptions($options);
5753
}

src/Phinx/Db/Plan/AlterTable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(Table $table)
4545
* @param \Phinx\Db\Action\Action $action The action to add
4646
* @return void
4747
*/
48-
public function addAction(Action $action)
48+
public function addAction(Action $action): void
4949
{
5050
$this->actions[] = $action;
5151
}
@@ -55,7 +55,7 @@ public function addAction(Action $action)
5555
*
5656
* @return \Phinx\Db\Table\Table
5757
*/
58-
public function getTable()
58+
public function getTable(): Table
5959
{
6060
return $this->table;
6161
}
@@ -65,7 +65,7 @@ public function getTable()
6565
*
6666
* @return \Phinx\Db\Action\Action[]
6767
*/
68-
public function getActions()
68+
public function getActions(): array
6969
{
7070
return $this->actions;
7171
}

src/Phinx/Db/Plan/Intent.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Intent
2727
* @param \Phinx\Db\Action\Action $action The action to add
2828
* @return void
2929
*/
30-
public function addAction(Action $action)
30+
public function addAction(Action $action): void
3131
{
3232
$this->actions[] = $action;
3333
}
@@ -37,7 +37,7 @@ public function addAction(Action $action)
3737
*
3838
* @return \Phinx\Db\Action\Action[]
3939
*/
40-
public function getActions()
40+
public function getActions(): array
4141
{
4242
return $this->actions;
4343
}
@@ -48,7 +48,7 @@ public function getActions()
4848
* @param \Phinx\Db\Plan\Intent $another The other intent to merge in
4949
* @return void
5050
*/
51-
public function merge(Intent $another)
51+
public function merge(Intent $another): void
5252
{
5353
$this->actions = array_merge($this->actions, $another->getActions());
5454
}

src/Phinx/Db/Plan/NewTable.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function __construct(Table $table)
5353
* @param \Phinx\Db\Table\Column $column The column description
5454
* @return void
5555
*/
56-
public function addColumn(Column $column)
56+
public function addColumn(Column $column): void
5757
{
5858
$this->columns[] = $column;
5959
}
@@ -64,7 +64,7 @@ public function addColumn(Column $column)
6464
* @param \Phinx\Db\Table\Index $index The index description
6565
* @return void
6666
*/
67-
public function addIndex(Index $index)
67+
public function addIndex(Index $index): void
6868
{
6969
$this->indexes[] = $index;
7070
}
@@ -74,7 +74,7 @@ public function addIndex(Index $index)
7474
*
7575
* @return \Phinx\Db\Table\Table
7676
*/
77-
public function getTable()
77+
public function getTable(): Table
7878
{
7979
return $this->table;
8080
}
@@ -84,7 +84,7 @@ public function getTable()
8484
*
8585
* @return \Phinx\Db\Table\Column[]
8686
*/
87-
public function getColumns()
87+
public function getColumns(): array
8888
{
8989
return $this->columns;
9090
}
@@ -94,7 +94,7 @@ public function getColumns()
9494
*
9595
* @return \Phinx\Db\Table\Index[]
9696
*/
97-
public function getIndexes()
97+
public function getIndexes(): array
9898
{
9999
return $this->indexes;
100100
}

src/Phinx/Db/Plan/Plan.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function __construct(Intent $intent)
9292
* @param \Phinx\Db\Action\Action[] $actions The actions to use for the plan
9393
* @return void
9494
*/
95-
protected function createPlan($actions)
95+
protected function createPlan(array $actions): void
9696
{
9797
$this->gatherCreates($actions);
9898
$this->gatherUpdates($actions);
@@ -107,7 +107,7 @@ protected function createPlan($actions)
107107
*
108108
* @return \Phinx\Db\Plan\AlterTable[][]
109109
*/
110-
protected function updatesSequence()
110+
protected function updatesSequence(): array
111111
{
112112
return [
113113
$this->tableUpdates,
@@ -123,7 +123,7 @@ protected function updatesSequence()
123123
*
124124
* @return \Phinx\Db\Plan\AlterTable[][]
125125
*/
126-
protected function inverseUpdatesSequence()
126+
protected function inverseUpdatesSequence(): array
127127
{
128128
return [
129129
$this->constraints,
@@ -140,7 +140,7 @@ protected function inverseUpdatesSequence()
140140
* @param \Phinx\Db\Adapter\AdapterInterface $executor The executor object for the plan
141141
* @return void
142142
*/
143-
public function execute(AdapterInterface $executor)
143+
public function execute(AdapterInterface $executor): void
144144
{
145145
foreach ($this->tableCreates as $newTable) {
146146
$executor->createTable($newTable->getTable(), $newTable->getColumns(), $newTable->getIndexes());
@@ -159,7 +159,7 @@ public function execute(AdapterInterface $executor)
159159
* @param \Phinx\Db\Adapter\AdapterInterface $executor The executor object for the plan
160160
* @return void
161161
*/
162-
public function executeInverse(AdapterInterface $executor)
162+
public function executeInverse(AdapterInterface $executor): void
163163
{
164164
foreach ($this->inverseUpdatesSequence() as $updates) {
165165
foreach ($updates as $update) {
@@ -177,7 +177,7 @@ public function executeInverse(AdapterInterface $executor)
177177
*
178178
* @return void
179179
*/
180-
protected function resolveConflicts()
180+
protected function resolveConflicts(): void
181181
{
182182
foreach ($this->tableMoves as $alterTable) {
183183
foreach ($alterTable->getActions() as $action) {
@@ -251,7 +251,7 @@ function (DropForeignKey $a, AddForeignKey $b) {
251251
* @param \Phinx\Db\Plan\AlterTable[] $actions The actions to transform
252252
* @return \Phinx\Db\Plan\AlterTable[] The list of actions without actions for the given table
253253
*/
254-
protected function forgetTable(Table $table, $actions)
254+
protected function forgetTable(Table $table, array $actions): array
255255
{
256256
$result = [];
257257
foreach ($actions as $action) {
@@ -273,7 +273,7 @@ protected function forgetTable(Table $table, $actions)
273273
* @return \Phinx\Db\Plan\AlterTable The updated AlterTable object. This function
274274
* has the side effect of changing the `$this->indexes` property.
275275
*/
276-
protected function remapContraintAndIndexConflicts(AlterTable $alter)
276+
protected function remapContraintAndIndexConflicts(AlterTable $alter): AlterTable
277277
{
278278
$newAlter = new AlterTable($alter->getTable());
279279

@@ -303,7 +303,7 @@ protected function remapContraintAndIndexConflicts(AlterTable $alter)
303303
* @return array A tuple containing the list of actions without actions for dropping the index
304304
* and a list of drop index actions that were removed.
305305
*/
306-
protected function forgetDropIndex(Table $table, array $columns, array $actions)
306+
protected function forgetDropIndex(Table $table, array $columns, array $actions): array
307307
{
308308
$dropIndexActions = new ArrayObject();
309309
$indexes = array_map(function ($alter) use ($table, $columns, $dropIndexActions) {
@@ -335,7 +335,7 @@ protected function forgetDropIndex(Table $table, array $columns, array $actions)
335335
* @return array A tuple containing the list of actions without actions for removing the column
336336
* and a list of remove column actions that were removed.
337337
*/
338-
protected function forgetRemoveColumn(Table $table, array $columns, array $actions)
338+
protected function forgetRemoveColumn(Table $table, array $columns, array $actions): array
339339
{
340340
$removeColumnActions = new ArrayObject();
341341
$indexes = array_map(function ($alter) use ($table, $columns, $removeColumnActions) {
@@ -364,7 +364,7 @@ protected function forgetRemoveColumn(Table $table, array $columns, array $actio
364364
* @param \Phinx\Db\Action\Action[] $actions The actions to parse
365365
* @return void
366366
*/
367-
protected function gatherCreates($actions)
367+
protected function gatherCreates(array $actions): void
368368
{
369369
foreach ($actions as $action) {
370370
if ($action instanceof CreateTable) {
@@ -396,7 +396,7 @@ protected function gatherCreates($actions)
396396
* @param \Phinx\Db\Action\Action[] $actions The actions to parse
397397
* @return void
398398
*/
399-
protected function gatherUpdates($actions)
399+
protected function gatherUpdates(array $actions): void
400400
{
401401
foreach ($actions as $action) {
402402
if (
@@ -432,7 +432,7 @@ protected function gatherUpdates($actions)
432432
* @param \Phinx\Db\Action\Action[] $actions The actions to parse
433433
* @return void
434434
*/
435-
protected function gatherTableMoves($actions)
435+
protected function gatherTableMoves(array $actions): void
436436
{
437437
foreach ($actions as $action) {
438438
if (
@@ -460,7 +460,7 @@ protected function gatherTableMoves($actions)
460460
* @param \Phinx\Db\Action\Action[] $actions The actions to parse
461461
* @return void
462462
*/
463-
protected function gatherIndexes($actions)
463+
protected function gatherIndexes(array $actions): void
464464
{
465465
foreach ($actions as $action) {
466466
if (!($action instanceof AddIndex) && !($action instanceof DropIndex)) {
@@ -486,7 +486,7 @@ protected function gatherIndexes($actions)
486486
* @param \Phinx\Db\Action\Action[] $actions The actions to parse
487487
* @return void
488488
*/
489-
protected function gatherConstraints($actions)
489+
protected function gatherConstraints(array $actions): void
490490
{
491491
foreach ($actions as $action) {
492492
if (!($action instanceof AddForeignKey || $action instanceof DropForeignKey)) {

src/Phinx/Db/Plan/Solver/ActionSplitter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ActionSplitter
5252
* which is the dual of $conflictClass. For example `AddColumn` and `DropColumn` are duals.
5353
* @param callable $conflictFilter The collection of actions to inspect
5454
*/
55-
public function __construct($conflictClass, $conflictClassDual, callable $conflictFilter)
55+
public function __construct(string $conflictClass, string $conflictClassDual, callable $conflictFilter)
5656
{
5757
$this->conflictClass = $conflictClass;
5858
$this->conflictClassDual = $conflictClassDual;
@@ -67,7 +67,7 @@ public function __construct($conflictClass, $conflictClassDual, callable $confli
6767
* @return \Phinx\Db\Plan\AlterTable[] A list of AlterTable that can be executed without
6868
* this type of conflict
6969
*/
70-
public function __invoke(AlterTable $alter)
70+
public function __invoke(AlterTable $alter): array
7171
{
7272
$conflictActions = array_filter($alter->getActions(), function ($action) {
7373
return $action instanceof $this->conflictClass;

0 commit comments

Comments
 (0)