phpparse

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VariableName

func VariableName(v *ast.ExprVariable) string

VariableName extracts the name from an ExprVariable node (without $).

func VertexToName

func VertexToName(v ast.Vertex) string

VertexToName extracts a name string from a Name/Identifier AST node.

Types

type ClassInfo

type ClassInfo struct {
	FQN                string
	Kind               string // "class", "interface", "trait", "enum"
	File               string
	Extends            string   // parent FQN (single for class, empty for trait)
	Implements         []string // interface FQNs
	Traits             []string // trait FQNs used by this class
	Methods            map[string]*MethodInfo
	Properties         map[string]string // property name → type FQN (from type hints)
	HasMagicCall       bool              // has __call
	HasMagicCallStatic bool              // has __callStatic
}

ClassInfo describes a class, interface, trait, or enum.

type FunctionInfo

type FunctionInfo struct {
	FQN        string
	Name       string
	Params     []ParamInfo
	ReturnType string
	File       string
	Position   string
}

FunctionInfo describes a standalone (non-method) function.

type MethodInfo

type MethodInfo struct {
	Name       string // short name, e.g. "getUser"
	FQN        string // fully qualified: "App\\UserService::getUser"
	IsStatic   bool
	Params     []ParamInfo
	ReturnType string // FQN of return type if available
	Position   string // "file.php:42"
}

MethodInfo describes a single class/interface/trait method.

type ParamInfo

type ParamInfo struct {
	Name    string // e.g. "$repo"
	TypeFQN string // e.g. "App\\UserRepository" or "" if untyped
}

ParamInfo describes a method/function parameter.

type ParseResult

type ParseResult struct {
	FilePath      string
	Root          ast.Vertex
	ResolvedNames map[ast.Vertex]string
}

ParseResult holds the AST and resolved names for a single PHP file.

func ParseFiles

func ParseFiles(dirs []string, phpVer string, numWorkers int) ([]*ParseResult, error)

ParseFiles discovers and parses all .php files in the given directories using numWorkers parallel goroutines. Returns a slice of ParseResult.

type SymbolTable

type SymbolTable struct {
	Classes   map[string]*ClassInfo    // FQN → ClassInfo
	Functions map[string]*FunctionInfo // FQN → FunctionInfo
}

SymbolTable is the global symbol table built from all parsed files.

func BuildSymbolTable

func BuildSymbolTable(results []*ParseResult) *SymbolTable

BuildSymbolTable constructs a global symbol table from all parse results.

func NewSymbolTable

func NewSymbolTable() *SymbolTable

NewSymbolTable creates an empty symbol table.

func (*SymbolTable) LookupMethod

func (st *SymbolTable) LookupMethod(classFQN, methodName string) (*ClassInfo, *MethodInfo)

LookupMethod finds a method by class FQN and method name, traversing the inheritance hierarchy if needed.

Jump to

Keyboard shortcuts

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