compile($compiler); if ($nodes !== []) { $compiler = $compiler->write("\n"); } } return $compiler; } public function sub(): self { return new self(); } public function write(string $code): self { $self = clone $this; $self->code .= $code; return $self; } public function indent(): self { $self = clone $this; $self->indentation++; return $self; } public function code(): string { $indent = str_repeat(' ', $this->indentation); return $indent . str_replace("\n", "\n" . $indent, $this->code); } }