While it’s possible to use HackBuilder directly to build up definitions of classes, functions, and so on, helpers are provided and recommended; assuming you have a HackCodegenFactory, you can create definitions with methods like:

  • ->codegenClass('SomeClass'): CodegenClass
  • ->codegenTrait('SomeTrait'): CodegenTrait
  • ->codegenMethod('someMethod'): CodegenMethod
  • ->codegenShape($members): CodegenShape

Using these helpers is recommended; see IHackCodegenFactory for a complete list.

Edit on GitHub