formatter

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package formatter pretty-prints phpscript ASTs in a gofmt-like style: hard tabs, canonical `function` keywords, parentheses on control structures, semicolons, collapsed blank lines, and a trailing newline. Class, function, and control-structure opening braces stay on the declaration line.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangedPaths

func ChangedPaths(paths []string) ([]string, error)

ChangedPaths formats each path argument in place and returns the files changed.

func File

func File(path string) (bool, error)

File formats path in place. Reports whether the file contents changed.

func Paths

func Paths(paths []string) (int, error)

Paths formats each path argument in place. Returns the number of files changed.

func Print

func Print(prog *model.Program, opts Options) string

Print renders prog as formatted PHP source.

func Source

func Source(src string) (string, error)

Source parses src and pretty-prints the AST.

Types

type Options

type Options struct {
	LeadingComments     []string           // emitted after <?php, before namespace/stmts
	DeclarationComments map[int][][]string // comment groups keyed by declaration source line
}

Options controls AST pretty-printing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL