setComment('Some kind of user'); * $class = codegen_class('MyClass') * ->addInterface($i); */ final class CodegenImplementsInterface implements ICodeBuilderRenderer { use HackBuilderRenderer; private ?string $comment; public function __construct(private string $name) {} public function getName(): string { return $this->name; } public function setComment(string $format, ...): this { $comment = vsprintf($format, array_slice(func_get_args(), 1)); $this->comment = $comment; return $this; } public function setGeneratedFrom(CodegenGeneratedFrom $from): this { $this->setComment($from->render()); return $this; } public function appendToBuilder(HackBuilder $builder): HackBuilder { return $builder ->indent() ->addInlineComment($this->comment) ->add($this->name) ->unindent(); } } function codegen_implements_interface( string $name, ): CodegenImplementsInterface { return new CodegenImplementsInterface($name); } function codegen_implements_interfaces( Vector $names, ): Vector { $interfaces = Vector {}; foreach ($names as $name) { $interfaces->add(new CodegenImplementsInterface($name)); } return $interfaces; }