Как, по Вашему мнению корректнее? :
public function add(\Data\Group $group, $name, \Data\Type $type, $required = false, $sort = NULL): ?\Data\Field {
$field = new \Data\Field;
$field->data_group = $group->id;
$field->name = $name;
$field->type = $type->id;
$field->required = $required? : 0;
$field->sort = $sort;
return $this->dao->add($field)?:NULL;
}
ИЛИ
$field = new \Data\Field;
$field->data_group = $group->id;
$field->name = $name;
$field->type = $type->id;
$field->required = $required ? : 0;
$field->sort = $sort;
public function add(\Data\Field $field): ?\Data\Field {
return $this->dao->add($field)?:NULL;
}