Documentation
¶
Index ¶
- Constants
- Variables
- type AnonymousFunction
- type ArrayAppendExpression
- type ArrayExpression
- type ArrayLookupExpression
- type ArrayPair
- type ArrayType
- type Assignable
- type AssignmentExpression
- type BasicType
- type BinaryExpression
- type Block
- type BreakStmt
- type CatchStmt
- type Class
- type ClassExpression
- type Classer
- type Constant
- type ConstantExpression
- type ContinueStmt
- type DeclarationType
- type DeclareBlock
- type DefaultWalker
- type DoWhileStmt
- type Dynamic
- type EchoStmt
- type EmptyStatement
- type ExitStmt
- type Expression
- type ExpressionStmt
- type File
- type FileSet
- type ForStmt
- type ForeachStmt
- type Format
- type FunctionArgument
- type FunctionCallExpression
- type FunctionCallStmt
- type FunctionDefinition
- type FunctionStmt
- type GlobalDeclaration
- type GlobalScope
- type Identifier
- type IfBranch
- type IfStmt
- type Include
- type IncludeStmt
- type Interface
- type ListStatement
- type Literal
- type Method
- type MethodCallExpression
- type Namespace
- type NewExpression
- type Node
- type ObjectType
- type Property
- type PropertyExpression
- type ReturnStmt
- type Scope
- type ShellCommand
- type Statement
- type StaticVariableDeclaration
- type SuperGlobalScope
- type SwitchCase
- type SwitchStmt
- type TernaryExpression
- type ThrowStmt
- type TryStmt
- type Type
- type UnaryExpression
- type Variable
- type VariableGroup
- type Visibility
- type Walker
- type WhileStmt
Constants ¶
const ( MixedKey = String | Integer StringKey = String IntegerKey = Integer )
Variables ¶
var Numeric = compoundType{Integer: struct{}{}, Float: struct{}{}}
var Unknown = new(unknownType)
Functions ¶
This section is empty.
Types ¶
type AnonymousFunction ¶
type AnonymousFunction struct { ClosureVariables []*FunctionArgument Arguments []*FunctionArgument Body *Block }
func (AnonymousFunction) Children ¶
func (a AnonymousFunction) Children() []Node
func (AnonymousFunction) Declares ¶
func (a AnonymousFunction) Declares() DeclarationType
func (AnonymousFunction) EvaluatesTo ¶
func (a AnonymousFunction) EvaluatesTo() Type
func (AnonymousFunction) String ¶
func (a AnonymousFunction) String() string
type ArrayAppendExpression ¶
type ArrayAppendExpression struct {
Array Dynamic
}
func (ArrayAppendExpression) AssignableType ¶
func (a ArrayAppendExpression) AssignableType() Type
func (ArrayAppendExpression) Children ¶
func (a ArrayAppendExpression) Children() []Node
func (ArrayAppendExpression) Declares ¶
func (_ ArrayAppendExpression) Declares() DeclarationType
func (ArrayAppendExpression) EvaluatesTo ¶
func (a ArrayAppendExpression) EvaluatesTo() Type
func (ArrayAppendExpression) String ¶
func (a ArrayAppendExpression) String() string
type ArrayExpression ¶
func (ArrayExpression) AssignableType ¶
func (a ArrayExpression) AssignableType() Type
func (ArrayExpression) Children ¶
func (a ArrayExpression) Children() []Node
func (ArrayExpression) Declares ¶
func (_ ArrayExpression) Declares() DeclarationType
func (ArrayExpression) EvaluatesTo ¶
func (a ArrayExpression) EvaluatesTo() Type
func (ArrayExpression) String ¶
func (a ArrayExpression) String() string
type ArrayLookupExpression ¶
type ArrayLookupExpression struct { Array Dynamic Index Expression }
func (ArrayLookupExpression) AssignableType ¶
func (a ArrayLookupExpression) AssignableType() Type
func (ArrayLookupExpression) Children ¶
func (a ArrayLookupExpression) Children() []Node
func (ArrayLookupExpression) Declares ¶
func (_ ArrayLookupExpression) Declares() DeclarationType
func (ArrayLookupExpression) EvaluatesTo ¶
func (a ArrayLookupExpression) EvaluatesTo() Type
func (ArrayLookupExpression) String ¶
func (a ArrayLookupExpression) String() string
type ArrayPair ¶
type ArrayPair struct { Key Expression Value Expression }
type Assignable ¶
type AssignmentExpression ¶
type AssignmentExpression struct { Assignee Assignable Value Expression Operator string }
func (AssignmentExpression) Children ¶
func (a AssignmentExpression) Children() []Node
func (AssignmentExpression) Declares ¶
func (a AssignmentExpression) Declares() DeclarationType
func (AssignmentExpression) EvaluatesTo ¶
func (a AssignmentExpression) EvaluatesTo() Type
func (AssignmentExpression) String ¶
func (a AssignmentExpression) String() string
type BinaryExpression ¶
type BinaryExpression struct { Antecedent Expression Subsequent Expression Type Type Operator string }
BinaryExpression is an expression that applies an operator to one, two, or three operands. The operator determines how many operands it should contain.
func (BinaryExpression) Children ¶
func (b BinaryExpression) Children() []Node
func (BinaryExpression) Declares ¶
func (b BinaryExpression) Declares() DeclarationType
func (BinaryExpression) EvaluatesTo ¶
func (b BinaryExpression) EvaluatesTo() Type
func (BinaryExpression) String ¶
func (b BinaryExpression) String() string
type BreakStmt ¶
type BreakStmt struct {
Expression
}
type Class ¶
type Class struct { Name string Extends string Implements []string Methods []*Method Properties []*Property Constants []*Constant }
func (Class) Declares ¶
func (c Class) Declares() DeclarationType
type ClassExpression ¶
func NewClassExpression ¶
func NewClassExpression(r string, e Expression) *ClassExpression
func (ClassExpression) AssignableType ¶
func (c ClassExpression) AssignableType() Type
func (ClassExpression) Children ¶
func (c ClassExpression) Children() []Node
func (ClassExpression) Declares ¶
func (c ClassExpression) Declares() DeclarationType
func (ClassExpression) EvaluatesTo ¶
func (c ClassExpression) EvaluatesTo() Type
func (ClassExpression) String ¶
func (c ClassExpression) String() string
type Constant ¶
type Constant struct { Name string Value interface{} }
func (Constant) Declares ¶
func (c Constant) Declares() DeclarationType
func (Constant) EvaluatesTo ¶
type ConstantExpression ¶
type ConstantExpression struct {
*Variable
}
type ContinueStmt ¶
type ContinueStmt struct {
Expression
}
func (ContinueStmt) Children ¶
func (c ContinueStmt) Children() []Node
func (ContinueStmt) String ¶
func (c ContinueStmt) String() string
type DeclarationType ¶
type DeclarationType int
DeclarationType identifies the type of declarative statements.
const ( // NoDeclaration identifies a statement which declares nothing in the local namespace. NoDeclaration DeclarationType = iota // ConstantDeclaration identifies a statement which declares a constant in the local namespace. ConstantDeclaration // FunctionDeclaration identfies a statement which declares a function in the local namespace. FunctionDeclaration // ClassDeclaration identfies a statement which declares a class in the local namespace. ClassDeclaration // InterfaceDeclaration identfies a statement which declares a interface in the local namespace. InterfaceDeclaration )
type DeclareBlock ¶
func (DeclareBlock) Children ¶
func (d DeclareBlock) Children() []Node
func (DeclareBlock) Declares ¶
func (p DeclareBlock) Declares() DeclarationType
func (DeclareBlock) String ¶
func (d DeclareBlock) String() string
type DefaultWalker ¶
func (*DefaultWalker) Errorf ¶
func (d *DefaultWalker) Errorf(format string, params ...interface{})
type DoWhileStmt ¶
type DoWhileStmt struct { Termination Expression LoopBlock Statement }
func (DoWhileStmt) Children ¶
func (d DoWhileStmt) Children() []Node
func (DoWhileStmt) Declares ¶
func (_ DoWhileStmt) Declares() DeclarationType
func (DoWhileStmt) String ¶
func (d DoWhileStmt) String() string
type Dynamic ¶
type Dynamic Expression
type EchoStmt ¶
type EchoStmt struct {
Expressions []Expression
}
Echo represents an echo statement. It may be either a literal statement or it may be from data outside PHP-mode, such as "here" in: <? not here ?> here <? not here ?>
func (EchoStmt) Declares ¶
func (e EchoStmt) Declares() DeclarationType
type EmptyStatement ¶
type EmptyStatement struct{}
EmptyStatement represents a statement that does nothing.
func (EmptyStatement) Children ¶
func (e EmptyStatement) Children() []Node
func (EmptyStatement) Declares ¶
func (e EmptyStatement) Declares() DeclarationType
func (EmptyStatement) Print ¶
func (e EmptyStatement) Print(f Format) string
func (EmptyStatement) String ¶
func (e EmptyStatement) String() string
type ExitStmt ¶
type ExitStmt struct {
Expression Expression
}
func (ExitStmt) Declares ¶
func (e ExitStmt) Declares() DeclarationType
type Expression ¶
An Expression is a snippet of code that evaluates to a single value when run and does not represent a program instruction.
type ExpressionStmt ¶
type ExpressionStmt struct {
Expression
}
func (ExpressionStmt) Children ¶
func (e ExpressionStmt) Children() []Node
func (ExpressionStmt) Declares ¶
func (e ExpressionStmt) Declares() DeclarationType
func (ExpressionStmt) String ¶
func (e ExpressionStmt) String() string
type FileSet ¶
type FileSet struct { Files map[string]*File Namespaces map[string]*Namespace GlobalNamespace *Namespace *Scope }
func NewFileSet ¶
func NewFileSet() *FileSet
type ForStmt ¶
type ForStmt struct { Initialization []Expression Termination []Expression Iteration []Expression LoopBlock Statement }
func (ForStmt) Declares ¶
func (_ ForStmt) Declares() DeclarationType
type ForeachStmt ¶
type ForeachStmt struct { Source Expression Key *Variable Value *Variable LoopBlock Statement }
func (ForeachStmt) Children ¶
func (f ForeachStmt) Children() []Node
func (ForeachStmt) Declares ¶
func (_ ForeachStmt) Declares() DeclarationType
func (ForeachStmt) String ¶
func (f ForeachStmt) String() string
type FunctionArgument ¶
type FunctionArgument struct { TypeHint string Default Expression Variable *Variable }
func (FunctionArgument) Children ¶
func (fa FunctionArgument) Children() []Node
func (FunctionArgument) String ¶
func (fa FunctionArgument) String() string
type FunctionCallExpression ¶
type FunctionCallExpression struct { FunctionName Dynamic Arguments []Expression }
func (FunctionCallExpression) Children ¶
func (f FunctionCallExpression) Children() []Node
func (FunctionCallExpression) Declares ¶
func (f FunctionCallExpression) Declares() DeclarationType
func (FunctionCallExpression) EvaluatesTo ¶
func (f FunctionCallExpression) EvaluatesTo() Type
func (FunctionCallExpression) String ¶
func (f FunctionCallExpression) String() string
type FunctionCallStmt ¶
type FunctionCallStmt struct {
FunctionCallExpression
}
type FunctionDefinition ¶
type FunctionDefinition struct { Name string Arguments []*FunctionArgument }
func (FunctionDefinition) Children ¶
func (fd FunctionDefinition) Children() []Node
func (FunctionDefinition) String ¶
func (fd FunctionDefinition) String() string
type FunctionStmt ¶
type FunctionStmt struct { *FunctionDefinition Body *Block }
func (FunctionStmt) Children ¶
func (f FunctionStmt) Children() []Node
func (FunctionStmt) Declares ¶
func (f FunctionStmt) Declares() DeclarationType
func (FunctionStmt) String ¶
func (f FunctionStmt) String() string
type GlobalDeclaration ¶
type GlobalDeclaration struct {
Identifiers []*Variable
}
func (GlobalDeclaration) Children ¶
func (g GlobalDeclaration) Children() []Node
func (GlobalDeclaration) Declares ¶
func (g GlobalDeclaration) Declares() DeclarationType
func (GlobalDeclaration) String ¶
func (g GlobalDeclaration) String() string
type GlobalScope ¶
globalScope represents the global scope on which functions and classes are defined. This is always within a namespace, but in many cases that may just be the default global namespace ("\")
func NewGlobalScope ¶
func NewGlobalScope(ns *Namespace) *GlobalScope
type Identifier ¶
An Identifier is a raw string that can be used to identify a variable, function, class, constant, property, etc.
func Static ¶
func Static(d Dynamic) *Identifier
func (Identifier) Children ¶
func (i Identifier) Children() []Node
func (Identifier) Declares ¶
func (i Identifier) Declares() DeclarationType
func (Identifier) EvaluatesTo ¶
func (i Identifier) EvaluatesTo() Type
func (Identifier) String ¶
func (i Identifier) String() string
type IfBranch ¶
type IfBranch struct { Condition Expression Block Statement }
type Include ¶
type Include struct {
Expressions []Expression
}
func (Include) Declares ¶
func (i Include) Declares() DeclarationType
func (Include) EvaluatesTo ¶
type IncludeStmt ¶
type IncludeStmt struct {
Include
}
type ListStatement ¶
type ListStatement struct { Assignees []Assignable Value Expression Operator string }
func (ListStatement) Children ¶
func (l ListStatement) Children() []Node
func (ListStatement) Declares ¶
func (_ ListStatement) Declares() DeclarationType
func (ListStatement) EvaluatesTo ¶
func (l ListStatement) EvaluatesTo() Type
func (ListStatement) String ¶
func (l ListStatement) String() string
type Literal ¶
func (Literal) Declares ¶
func (_ Literal) Declares() DeclarationType
func (Literal) EvaluatesTo ¶
type Method ¶
type Method struct { *FunctionStmt Visibility Visibility }
type MethodCallExpression ¶
type MethodCallExpression struct { Receiver Dynamic *FunctionCallExpression }
func (MethodCallExpression) Children ¶
func (m MethodCallExpression) Children() []Node
func (MethodCallExpression) String ¶
func (m MethodCallExpression) String() string
type Namespace ¶
type Namespace struct { Name string ClassesAndInterfaces map[string]Statement Constants map[string][]*Variable Functions map[string]*FunctionStmt }
func NewNamespace ¶
type NewExpression ¶
type NewExpression struct { Class Dynamic Arguments []Expression }
func (NewExpression) Children ¶
func (c NewExpression) Children() []Node
func (NewExpression) Declares ¶
func (n NewExpression) Declares() DeclarationType
func (NewExpression) EvaluatesTo ¶
func (n NewExpression) EvaluatesTo() Type
func (NewExpression) String ¶
func (n NewExpression) String() string
type ObjectType ¶
type ObjectType struct {
Class string
}
func (ObjectType) Basic ¶
func (_ ObjectType) Basic() []BasicType
func (ObjectType) Contains ¶
func (o ObjectType) Contains(t Type) bool
func (ObjectType) Equals ¶
func (o ObjectType) Equals(t Type) bool
func (ObjectType) Single ¶
func (_ ObjectType) Single() bool
func (ObjectType) String ¶
func (o ObjectType) String() string
func (ObjectType) Union ¶
func (o ObjectType) Union(t Type) Type
type Property ¶
type Property struct { Name string Visibility Visibility Type Type Initialization Expression }
func (Property) AssignableType ¶
type PropertyExpression ¶
func (PropertyExpression) AssignableType ¶
func (p PropertyExpression) AssignableType() Type
func (PropertyExpression) Children ¶
func (p PropertyExpression) Children() []Node
func (PropertyExpression) Declares ¶
func (p PropertyExpression) Declares() DeclarationType
func (PropertyExpression) EvaluatesTo ¶
func (p PropertyExpression) EvaluatesTo() Type
func (PropertyExpression) String ¶
func (p PropertyExpression) String() string
type ReturnStmt ¶
type ReturnStmt struct {
Expression
}
ReturnStmt represents a function return.
func (ReturnStmt) Children ¶
func (r ReturnStmt) Children() []Node
func (ReturnStmt) Declares ¶
func (r ReturnStmt) Declares() DeclarationType
func (ReturnStmt) String ¶
func (r ReturnStmt) String() string
type Scope ¶
type Scope struct { Identifiers map[string]VariableGroup DynamicVariables []*Variable EnclosingScope *Scope GlobalScope *GlobalScope SuperGlobalScope *SuperGlobalScope }
scope represents a particular local scope (such as within a function).
func NewScope ¶
func NewScope(parent *Scope, global *GlobalScope, superGlobal *SuperGlobalScope) *Scope
type ShellCommand ¶
type ShellCommand struct {
Command string
}
func (ShellCommand) Children ¶
func (s ShellCommand) Children() []Node
func (ShellCommand) Declares ¶
func (_ ShellCommand) Declares() DeclarationType
func (ShellCommand) EvaluatesTo ¶
func (s ShellCommand) EvaluatesTo() Type
func (ShellCommand) String ¶
func (s ShellCommand) String() string
type Statement ¶
type Statement interface { Node Declares() DeclarationType }
A statement is an executable piece of code. It may be as simple as a function call or a variable assignment. It also includes things like "if".
type StaticVariableDeclaration ¶
type StaticVariableDeclaration struct {
Declarations []Dynamic
}
func (StaticVariableDeclaration) Children ¶
func (s StaticVariableDeclaration) Children() []Node
func (StaticVariableDeclaration) Declares ¶
func (s StaticVariableDeclaration) Declares() DeclarationType
func (StaticVariableDeclaration) String ¶
func (s StaticVariableDeclaration) String() string
type SuperGlobalScope ¶
superGlobalScope represents the scope containing superglobals such as $_GET
func NewSuperGlobalScope ¶
func NewSuperGlobalScope() *SuperGlobalScope
type SwitchCase ¶
type SwitchCase struct { Expression Expression Block Block }
func (SwitchCase) Children ¶
func (s SwitchCase) Children() []Node
func (SwitchCase) String ¶
func (s SwitchCase) String() string
type SwitchStmt ¶
type SwitchStmt struct { Expression Expression Cases []*SwitchCase DefaultCase *Block }
func (SwitchStmt) Children ¶
func (s SwitchStmt) Children() []Node
func (SwitchStmt) Declares ¶
func (_ SwitchStmt) Declares() DeclarationType
func (SwitchStmt) String ¶
func (s SwitchStmt) String() string
type TernaryExpression ¶
type TernaryExpression struct {
Condition, True, False Expression
Type Type
}
func (TernaryExpression) Children ¶
func (t TernaryExpression) Children() []Node
func (TernaryExpression) Declares ¶
func (t TernaryExpression) Declares() DeclarationType
func (TernaryExpression) EvaluatesTo ¶
func (t TernaryExpression) EvaluatesTo() Type
func (TernaryExpression) String ¶
func (t TernaryExpression) String() string
type ThrowStmt ¶
type ThrowStmt struct {
Expression
}
func (ThrowStmt) Declares ¶
func (t ThrowStmt) Declares() DeclarationType
type Type ¶
type Type interface { // Equals returns true if the receiver is of the same type as the argument. Equals(Type) bool // Contains returns true if the receiver contains the argument type. Contains(Type) bool // Union returns a new type that includes both the receiver and the argument. Union(Type) Type // Single returns true if the receiver expresses one type and only one type. Single() bool // String returns the receiver expressed as a string. String() string // Basic returns the basic type a type expresses. Basic() []BasicType }
type UnaryExpression ¶
type UnaryExpression struct { Operand Expression Operator string Preceding bool }
UnaryExpression is an expression that applies an operator to only one operand. The operator may precede or follow the operand.
func (UnaryExpression) Children ¶
func (u UnaryExpression) Children() []Node
func (UnaryExpression) Declares ¶
func (u UnaryExpression) Declares() DeclarationType
func (UnaryExpression) EvaluatesTo ¶
func (u UnaryExpression) EvaluatesTo() Type
func (UnaryExpression) String ¶
func (u UnaryExpression) String() string
type Variable ¶
type Variable struct { // Name is the identifier for the variable, which may be // a dynamic expression. Name Dynamic Type Type }
func NewVariable ¶
NewVariable intializes a variable node with its name being a simple identifier and its type set to Unknown. The name argument should not include the $ operator.
func (Variable) AssignableType ¶
func (Variable) Declares ¶
func (v Variable) Declares() DeclarationType
func (Variable) EvaluatesTo ¶
EvaluatesTo returns the known type of the variable.
type VariableGroup ¶
type Visibility ¶
type Visibility int
const ( Private Visibility = iota Protected Public )
func (Visibility) Token ¶
func (v Visibility) Token() token.Token