@@ -293,13 +293,14 @@ public function reset(): void
293
293
* Valid options can be: limit, default, null, precision or scale.
294
294
*
295
295
* @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
297
297
* @param array<string, mixed> $options Column Options
298
298
* @throws \InvalidArgumentException
299
299
* @return $this
300
300
*/
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 = [])
302
302
{
303
+ assert ($ columnName instanceof Column || $ type !== null );
303
304
if ($ columnName instanceof Column) {
304
305
$ action = new AddColumn ($ this ->table , $ columnName );
305
306
} elseif ($ type instanceof Literal) {
@@ -312,7 +313,7 @@ public function addColumn(string|Column $columnName, string|Literal $type, array
312
313
if (!$ this ->getAdapter ()->isValidColumnType ($ action ->getColumn ())) {
313
314
throw new InvalidArgumentException (sprintf (
314
315
'An invalid column type "%s" was specified for column "%s". ' ,
315
- $ type ,
316
+ $ action -> getColumn ()-> getType () ,
316
317
$ action ->getColumn ()->getName ()
317
318
));
318
319
}
0 commit comments