Documentation
¶
Index ¶
- type CallEdge
- type CallGraph
- func (cg *CallGraph) AddEdge(edge *CallEdge)
- func (cg *CallGraph) AddNode(node *CallNode)
- func (cg *CallGraph) CollapseToClassLevel() *CallGraph
- func (cg *CallGraph) ExcludeMethods(methods []string) *CallGraph
- func (cg *CallGraph) FilterByClasses(includes, excludes []string) *CallGraph
- func (cg *CallGraph) FilterByEntryPoints(entryPoints []NodeID, maxDepth int) *CallGraph
- func (cg *CallGraph) FilterByNamespaces(includes, excludes []string) *CallGraph
- func (cg *CallGraph) Stats() string
- type CallNode
- type CallType
- type NodeID
- type TypeResolver
- func (tr *TypeResolver) EnterClass(fqn string)
- func (tr *TypeResolver) EnterMethod(params []phpparse.ParamInfo)
- func (tr *TypeResolver) LeaveClass()
- func (tr *TypeResolver) ResolveNewExprType(classNode ast.Vertex) string
- func (tr *TypeResolver) ResolveParent() string
- func (tr *TypeResolver) ResolvePropertyFetch(receiverVar string, propName string) string
- func (tr *TypeResolver) ResolveSelf() string
- func (tr *TypeResolver) ResolveStaticKeyword() string
- func (tr *TypeResolver) ResolveVariable(varName string) string
- func (tr *TypeResolver) TrackAssignment(varName string, exprTypeFQN string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallEdge ¶
type CallEdge struct {
From NodeID
To NodeID
Type CallType
Label string // human-readable label for the edge
FileLine string // "file.php:42" where the call occurs
}
CallEdge represents a directed edge in the call graph.
type CallGraph ¶
type CallGraph struct {
Nodes map[NodeID]*CallNode
Edges []*CallEdge
// Index: from node → list of edges.
OutEdges map[NodeID][]*CallEdge
InEdges map[NodeID][]*CallEdge
}
CallGraph is the internal call graph data structure.
func BuildCallGraph ¶
func BuildCallGraph( results []*phpparse.ParseResult, symbols *phpparse.SymbolTable, typeMappings map[string]string, resolveTypes bool, showFunctions bool, ) *CallGraph
BuildCallGraph constructs the call graph from all parsed files.
func (*CallGraph) CollapseToClassLevel ¶
CollapseToClassLevel merges all methods of each class into a single node, producing a class→class dependency graph.
func (*CallGraph) ExcludeMethods ¶
ExcludeMethods removes edges pointing to methods in the exclude list.
func (*CallGraph) FilterByClasses ¶
FilterByClasses returns a new graph keeping only nodes whose ClassFQN or short ClassName matches the include/exclude lists.
func (*CallGraph) FilterByEntryPoints ¶
FilterByEntryPoints returns a new graph containing only nodes reachable from the given entry points within maxDepth steps (0 = unlimited).
func (*CallGraph) FilterByNamespaces ¶
FilterByNamespaces returns a new graph keeping only nodes whose ClassFQN matches at least one include pattern and none of the exclude patterns.
type CallNode ¶
type CallNode struct {
ID NodeID
Label string // short display label, e.g. "getUser"
ClassFQN string // "" for standalone functions
ClassName string // short class name for display
Method string // method/function name
IsStatic bool
Kind string // "class", "interface", "trait", "enum", "function"
File string
}
CallNode represents a node in the call graph (a method or function).
type NodeID ¶
type NodeID string
NodeID uniquely identifies a graph node (a method or function).
func MakeFunctionID ¶
MakeFunctionID creates a NodeID for a standalone function.
func MakeMethodID ¶
MakeMethodID creates a NodeID for a class method.
type TypeResolver ¶
type TypeResolver struct {
// contains filtered or unexported fields
}
TypeResolver provides heuristic type resolution for PHP variables. It tracks:
- $this → current class
- $var = new ClassName() → $var is ClassName
- Type-hinted parameters: function foo(UserRepo $repo) → $repo is UserRepo
- Type-hinted properties: private UserRepo $repo → $this->repo is UserRepo
- Manual overrides from config.yaml type_mappings
func NewTypeResolver ¶
func NewTypeResolver( symbols *phpparse.SymbolTable, resolvedNames map[ast.Vertex]string, typeMappings map[string]string, ) *TypeResolver
NewTypeResolver creates a resolver with the given context.
func (*TypeResolver) EnterClass ¶
func (tr *TypeResolver) EnterClass(fqn string)
EnterClass sets the current class context.
func (*TypeResolver) EnterMethod ¶
func (tr *TypeResolver) EnterMethod(params []phpparse.ParamInfo)
EnterMethod resets the variable scope and seeds it with parameter types.
func (*TypeResolver) LeaveClass ¶
func (tr *TypeResolver) LeaveClass()
LeaveClass clears the current class context.
func (*TypeResolver) ResolveNewExprType ¶
func (tr *TypeResolver) ResolveNewExprType(classNode ast.Vertex) string
ResolveNewExprType resolves the type for a `new ClassName()` expression.
func (*TypeResolver) ResolveParent ¶
func (tr *TypeResolver) ResolveParent() string
ResolveParent resolves "parent" to the parent class FQN.
func (*TypeResolver) ResolvePropertyFetch ¶
func (tr *TypeResolver) ResolvePropertyFetch(receiverVar string, propName string) string
ResolvePropertyFetch resolves $this->prop to the property type.
func (*TypeResolver) ResolveSelf ¶
func (tr *TypeResolver) ResolveSelf() string
ResolveSelf resolves "self" to the current class FQN.
func (*TypeResolver) ResolveStaticKeyword ¶
func (tr *TypeResolver) ResolveStaticKeyword() string
ResolveStaticKeyword resolves the "static" keyword. Since this is late static binding, we return the current class but mark it as potentially polymorphic.
func (*TypeResolver) ResolveVariable ¶
func (tr *TypeResolver) ResolveVariable(varName string) string
ResolveVariable tries to determine the FQN type of a variable.
func (*TypeResolver) TrackAssignment ¶
func (tr *TypeResolver) TrackAssignment(varName string, exprTypeFQN string)
TrackAssignment records a variable assignment like $var = new ClassName().