【PHP】可以为空的类型
环境
可为null的类型
如果在类型声明之前加上问号,则允许指定的类型或null。
public static function createPostBy(
    int $userId,
    string $type,
    string $content,
    ?DateTime $deletedAt
)
{
   self::create([
      ...
   ]);
}
如果在参数中放入null而没有给出任何选项,会出现以下错误。
 Argument #2 ($deletedAt) must be of type int, null given, called in 
请参考