Skip to content

Commit

Permalink
Merge pull request #2224 from cakephp/table-nullable-type
Browse files Browse the repository at this point in the history
Allow Table::addColumn() to use type from Column object again
  • Loading branch information
othercorey authored Sep 22, 2023
2 parents acda135 + b4811d3 commit 26753bd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Phinx/Db/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,14 @@ 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 $type Column Type
* @param string|\Phinx\Util\Literal|null $type Column Type
* @param array<string, mixed> $options Column Options
* @throws \InvalidArgumentException
* @return $this
*/
public function addColumn(string|Column $columnName, string|Literal $type, array $options = [])
public function addColumn(string|Column $columnName, string|Literal|null $type, array $options = [])
{
assert($columnName instanceof Column || $type !== null);
if ($columnName instanceof Column) {
$action = new AddColumn($this->table, $columnName);
} elseif ($type instanceof Literal) {
Expand All @@ -312,7 +313,7 @@ public function addColumn(string|Column $columnName, string|Literal $type, array
if (!$this->getAdapter()->isValidColumnType($action->getColumn())) {
throw new InvalidArgumentException(sprintf(
'An invalid column type "%s" was specified for column "%s".',
$type,
$action->getColumn()->getType(),
$action->getColumn()->getName()
));
}
Expand Down

0 comments on commit 26753bd

Please sign in to comment.