---
layout: docs
title: addTrait
id: class.Facebook.HackCodegen.CodegenFile.addTrait
docid: class.Facebook.HackCodegen.CodegenFile.addTrait
permalink: /docs/reference/class.Facebook.HackCodegen.CodegenFile.addTrait/
---
# Facebook\\HackCodegen\\CodegenFile::addTrait()




``` Hack
public function addTrait(
  Facebook\HackCodegen\CodegenTrait $trait,
): this;
```




## Parameters




+ [` Facebook\HackCodegen\CodegenTrait `](<class.Facebook.HackCodegen.CodegenTrait.md>)`` $trait ``




## Returns




* ` this `