Facebook\HackCodegen\PartiallyGeneratedCode
Facebook\HackCodegen\PartiallyGeneratedCode
Manage partially generated code
The main operation is to merge existing code (that probably has some handwritten code) with generated code.
Interface Synopsis
namespace Facebook\HackCodegen;
final class PartiallyGeneratedCode {...}
Public Methods
::containsManualSection(string $code): bool
::getBeginManualSection(string $id): string
::getEndManualSection(): string
->__construct(string $code)
->assertValidManualSections(): \void
Validate the manual sections and throws PartiallyGeneratedCodeException if there are any errors (e->extractGeneratedCode(): string
Extract the generated code and returns it as a string->merge(string $existing_code, ?KeyedContainer<string, Traversable<string>> $rekeys = NULL): string
Merge the code with the existing code
Private Methods
::getBeginManualSectionRegex(string $regex): string
->extractManualCode(string $code): dict<string, string>
Extract manually generated code and returns a map of ids to chunks of code->iterateCodeSections(string $code): \\Generator<int, \tuple<?string, string>, \void>
Iterates through the code yielding tuples of ($id, $chunk), where $id is the id of the manual section or null if it’s an auto-generated section, and chunk is the code belonging to that section