Facebook\HackCodegen\CodegenFile
Facebook\HackCodegen\CodegenFile
File of generated code
The file is composed by classes. The file will be signed, either as autogenerated or partially generated, depending on whether there are manual sections.
Interface Synopsis
namespace Facebook\HackCodegen;
final class CodegenFile {...}
Public Methods
->__construct(IHackCodegenConfig $config, string $file_name)
->addAfterType(CodegenType $type): \this
->addAfterTypes(Traversable<CodegenType> $types): \this
->addBeforeType(CodegenType $type): \this
->addBeforeTypes(Traversable<CodegenType> $types): \this
->addClass(CodegenClassish $class): \this
->addClasses(Traversable<CodegenClassish> $classes): \this
->addConstant(CodegenConstant $const): \this
->addConstants(Traversable<CodegenConstant> $constants): \this
->addFunction(CodegenFunction $function): \this
->addFunctions(Traversable<CodegenFunction> $functions): \this
->addOriginalFile(string $file_name): \this
Use this when refactoring generated code->addTrait(CodegenTrait $trait): \this
->createOnly(): \this
If called, save() will only write the file if it doesn’t exist->exists(): bool
->getAfterTypes(): vec<CodegenType>
->getBeforeTypes(): vec<CodegenType>
->getClasses(): vec<CodegenClassish>
->getFileName(): string
The absolute path->getFunctions(): vec<CodegenFunction>
->getRelativeFileName(): string
->rekeyManualSection(string $old_key, string $new_key): \this
Use this to pull manual code from a section keyed by $old_key and place it in a section keyed by $new_key->render(): string
->save(): CodegenFileResult
Saves the generated file->setDoClobber(bool $do_force): \this
Use this to skip reading in the existing file->setDocBlock(string $comment): \this
->setFileType(CodegenFileType $type): \this
->setGeneratedFrom(CodegenGeneratedFrom $from): \this
->setIsSignedFile(bool $value): \this
->setNamespace(string $file_namespace): \this
->setPseudoMainFooter(string $code): \this
Use to execute code after declarations->setPseudoMainFooterf(\HH\Lib\Str\SprintfFormatString $format, \mixed ...$args): \this
->setPseudoMainHeader(string $code): \this
Use to execute code before declarations->setPseudoMainHeaderf(\HH\Lib\Str\SprintfFormatString $format, \mixed ...$args): \this
->setShebangLine(string $shebang): \this
Useful when creating scripts->setShebangLinef(\HH\Lib\Str\SprintfFormatString $format, \mixed ...$args): \this
->useConst(string $ns, ?string $as = NULL): \this
->useFunction(string $ns, ?string $as = NULL): \this
->useNamespace(string $ns, ?string $as = NULL): \this
->useType(string $ns, ?string $as = NULL): \this