Skip to content

Commit b4811d3

Browse files
committed
Allow Table::addColumn() to use type from Column object again
1 parent acda135 commit b4811d3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Phinx/Db/Table.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,14 @@ public function reset(): void
293293
* Valid options can be: limit, default, null, precision or scale.
294294
*
295295
* @param string|\Phinx\Db\Table\Column $columnName Column Name
296-
* @param string|\Phinx\Util\Literal $type Column Type
296+
* @param string|\Phinx\Util\Literal|null $type Column Type
297297
* @param array<string, mixed> $options Column Options
298298
* @throws \InvalidArgumentException
299299
* @return $this
300300
*/
301-
public function addColumn(string|Column $columnName, string|Literal $type, array $options = [])
301+
public function addColumn(string|Column $columnName, string|Literal|null $type, array $options = [])
302302
{
303+
assert($columnName instanceof Column || $type !== null);
303304
if ($columnName instanceof Column) {
304305
$action = new AddColumn($this->table, $columnName);
305306
} elseif ($type instanceof Literal) {
@@ -312,7 +313,7 @@ public function addColumn(string|Column $columnName, string|Literal $type, array
312313
if (!$this->getAdapter()->isValidColumnType($action->getColumn())) {
313314
throw new InvalidArgumentException(sprintf(
314315
'An invalid column type "%s" was specified for column "%s".',
315-
$type,
316+
$action->getColumn()->getType(),
316317
$action->getColumn()->getName()
317318
));
318319
}

0 commit comments

Comments
 (0)