Documentation ¶
Index ¶
- Constants
- Variables
- type AnonymousFunction
- type ArrayAppendExpr
- type ArrayExpr
- type ArrayLookupExpr
- type ArrayPair
- type ArrayType
- type Assignable
- type AssignmentExpr
- type BasicType
- type BinaryExpr
- type Block
- type BreakStmt
- type CatchStmt
- type Class
- type ClassExpr
- type Classer
- type Constant
- type ConstantExpr
- type ContinueStmt
- type DeclarationType
- type DeclareBlock
- type DefaultWalker
- type DoWhileStmt
- type Dynamic
- type EchoStmt
- type EmptyStatement
- type ExitStmt
- type Expr
- type ExprStmt
- type File
- type FileSet
- type ForStmt
- type ForeachStmt
- type Format
- type FunctionArgument
- type FunctionCallExpr
- 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 MethodCallExpr
- type Namespace
- type NewCallExpr
- type Node
- type ObjectType
- type Property
- type PropertyCallExpr
- type ReturnStmt
- type Scope
- type ShellCommand
- type Statement
- type StaticVariableDeclaration
- type SuperGlobalScope
- type SwitchCase
- type SwitchStmt
- type TernaryCallExpr
- type ThrowStmt
- type TryStmt
- type Type
- type UnaryCallExpr
- 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{}{}}
Numeric represents either a float or an integer
var Unknown = new(unknownType)
Unknown represents an unknown type
Functions ¶
This section is empty.
Types ¶
type AnonymousFunction ¶
type AnonymousFunction struct { ClosureVariables []*FunctionArgument Arguments []*FunctionArgument Body *Block }
AnonymousFunction is an anonymous function
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 ArrayAppendExpr ¶
type ArrayAppendExpr struct {
Array Dynamic
}
ArrayAppendExpr is an array append expression
func (ArrayAppendExpr) AssignableType ¶
func (a ArrayAppendExpr) AssignableType() Type
func (ArrayAppendExpr) Children ¶
func (a ArrayAppendExpr) Children() []Node
func (ArrayAppendExpr) Declares ¶
func (ArrayAppendExpr) Declares() DeclarationType
func (ArrayAppendExpr) EvaluatesTo ¶
func (a ArrayAppendExpr) EvaluatesTo() Type
func (ArrayAppendExpr) String ¶
func (a ArrayAppendExpr) String() string
type ArrayExpr ¶
ArrayExpr is an array expression
func (ArrayExpr) AssignableType ¶
func (ArrayExpr) Declares ¶
func (ArrayExpr) Declares() DeclarationType
func (ArrayExpr) EvaluatesTo ¶
type ArrayLookupExpr ¶
ArrayLookupExpr is an array lookup expression
func (ArrayLookupExpr) AssignableType ¶
func (a ArrayLookupExpr) AssignableType() Type
func (ArrayLookupExpr) Children ¶
func (a ArrayLookupExpr) Children() []Node
func (ArrayLookupExpr) Declares ¶
func (ArrayLookupExpr) Declares() DeclarationType
func (ArrayLookupExpr) EvaluatesTo ¶
func (a ArrayLookupExpr) EvaluatesTo() Type
func (ArrayLookupExpr) String ¶
func (a ArrayLookupExpr) String() string
type ArrayType ¶
type ArrayType struct { KeyType keyType ValueType Type }
ArrayType is an array type
type Assignable ¶
Assignable is an assignable
type AssignmentExpr ¶
type AssignmentExpr struct { Assignee Assignable Value Expr Operator string }
AssignmentExpr is an assighment expression
func (AssignmentExpr) Children ¶
func (a AssignmentExpr) Children() []Node
func (AssignmentExpr) Declares ¶
func (AssignmentExpr) Declares() DeclarationType
func (AssignmentExpr) EvaluatesTo ¶
func (a AssignmentExpr) EvaluatesTo() Type
func (AssignmentExpr) String ¶
func (a AssignmentExpr) String() string
type BinaryExpr ¶
BinaryExpr is an expression that applies an operator to one, two, or three operands. The operator determines how many operands it should contain.
func (BinaryExpr) Children ¶
func (b BinaryExpr) Children() []Node
func (BinaryExpr) Declares ¶
func (b BinaryExpr) Declares() DeclarationType
func (BinaryExpr) EvaluatesTo ¶
func (b BinaryExpr) EvaluatesTo() Type
func (BinaryExpr) String ¶
func (b BinaryExpr) String() string
type Class ¶
type Class struct { Name string Extends string Implements []string Methods []*Method Properties []*Property Constants []*Constant }
Class is a class
func (Class) Declares ¶
func (c Class) Declares() DeclarationType
type ClassExpr ¶
ClassExpr is a class expression
func NewClassExpression ¶
NewClassExpression returns a new ClassExpression
func (ClassExpr) AssignableType ¶
func (ClassExpr) Declares ¶
func (c ClassExpr) Declares() DeclarationType
func (ClassExpr) EvaluatesTo ¶
type Constant ¶
type Constant struct { Name string Value interface{} }
Constant is a constant
func (Constant) Declares ¶
func (c Constant) Declares() DeclarationType
func (Constant) EvaluatesTo ¶
type ContinueStmt ¶
type ContinueStmt struct {
Expr
}
ContinueStmt is a continue statement
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 ¶
DeclareBlock is a declare block
func (DeclareBlock) Children ¶
func (d DeclareBlock) Children() []Node
func (DeclareBlock) Declares ¶
func (DeclareBlock) Declares() DeclarationType
func (DeclareBlock) String ¶
func (d DeclareBlock) String() string
type DefaultWalker ¶
DefaultWalker is the default walker implementation
func (*DefaultWalker) Errorf ¶
func (d *DefaultWalker) Errorf(format string, params ...interface{})
type DoWhileStmt ¶
DoWhileStmt is a do while 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 EchoStmt ¶
type EchoStmt struct {
Expressions []Expr
}
EchoStmt 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 {
Expr Expr
}
ExitStmt is an exit statment
func (ExitStmt) Declares ¶
func (e ExitStmt) Declares() DeclarationType
type Expr ¶
Expr describes a snippet of code that evaluates to a single value when run and does not represent a program instruction.
type ExprStmt ¶
type ExprStmt struct {
Expr
}
ExprStmt is a expression statement
func (ExprStmt) Declares ¶
func (e ExprStmt) Declares() DeclarationType
type FileSet ¶
type FileSet struct { Files map[string]*File Namespaces map[string]*Namespace GlobalNamespace *Namespace *Scope }
FileSet is a file set
type ForStmt ¶
type ForStmt struct { Initialization []Expr Termination []Expr Iteration []Expr LoopBlock Statement }
ForStmt is a for statment
func (ForStmt) Declares ¶
func (ForStmt) Declares() DeclarationType
type ForeachStmt ¶
ForeachStmt is a for each statment
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 ¶
FunctionArgument is a function argument
func (FunctionArgument) Children ¶
func (fa FunctionArgument) Children() []Node
func (FunctionArgument) String ¶
func (fa FunctionArgument) String() string
type FunctionCallExpr ¶
FunctionCallExpr is a function call expression
func (FunctionCallExpr) Children ¶
func (f FunctionCallExpr) Children() []Node
func (FunctionCallExpr) Declares ¶
func (f FunctionCallExpr) Declares() DeclarationType
func (FunctionCallExpr) EvaluatesTo ¶
func (f FunctionCallExpr) EvaluatesTo() Type
func (FunctionCallExpr) String ¶
func (f FunctionCallExpr) String() string
type FunctionCallStmt ¶
type FunctionCallStmt struct {
FunctionCallExpr
}
FunctionCallStmt is a function call statement
type FunctionDefinition ¶
type FunctionDefinition struct { Name string Arguments []*FunctionArgument Type string }
FunctionDefinition is a function defintion
func (FunctionDefinition) Children ¶
func (fd FunctionDefinition) Children() []Node
func (FunctionDefinition) String ¶
func (fd FunctionDefinition) String() string
type FunctionStmt ¶
type FunctionStmt struct { *FunctionDefinition Body *Block }
FunctionStmt is a function statment
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
}
GlobalDeclaration is a global declaration
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
NewGlobalScope returns a new 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
Static checks wether input is a identifier and returns it
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 IfStmt ¶
IfStmt is an if statment
func (IfStmt) Declares ¶
func (i IfStmt) Declares() DeclarationType
type Include ¶
type Include struct {
Expressions []Expr
}
Include is a include statement
func (Include) Declares ¶
func (i Include) Declares() DeclarationType
func (Include) EvaluatesTo ¶
type Interface ¶
Interface is an interface
func (Interface) Declares ¶
func (i Interface) Declares() DeclarationType
type ListStatement ¶
type ListStatement struct { Assignees []Assignable Value Expr Operator string }
ListStatement is a list statement
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 ¶
Literal is a literal
func (Literal) Declares ¶
func (Literal) Declares() DeclarationType
func (Literal) EvaluatesTo ¶
type MethodCallExpr ¶
type MethodCallExpr struct { Receiver Dynamic *FunctionCallExpr }
MethodCallExpr is a method call expression
func (MethodCallExpr) Children ¶
func (m MethodCallExpr) Children() []Node
func (MethodCallExpr) String ¶
func (m MethodCallExpr) String() string
type Namespace ¶
type Namespace struct { Name string ClassesAndInterfaces map[string]Statement Constants map[string][]*Variable Functions map[string]*FunctionStmt }
Namespace is a namespace
type NewCallExpr ¶
NewCallExpr is a `new call` expression
func (NewCallExpr) Children ¶
func (n NewCallExpr) Children() []Node
func (NewCallExpr) Declares ¶
func (n NewCallExpr) Declares() DeclarationType
func (NewCallExpr) EvaluatesTo ¶
func (n NewCallExpr) EvaluatesTo() Type
func (NewCallExpr) String ¶
func (n NewCallExpr) String() string
type ObjectType ¶
type ObjectType struct {
Class string
}
ObjectType is an object type
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 Expr }
Property is a property
func (Property) AssignableType ¶
type PropertyCallExpr ¶
PropertyCallExpr is a property call expression
func (PropertyCallExpr) AssignableType ¶
func (p PropertyCallExpr) AssignableType() Type
func (PropertyCallExpr) Children ¶
func (p PropertyCallExpr) Children() []Node
func (PropertyCallExpr) Declares ¶
func (p PropertyCallExpr) Declares() DeclarationType
func (PropertyCallExpr) EvaluatesTo ¶
func (p PropertyCallExpr) EvaluatesTo() Type
func (PropertyCallExpr) String ¶
func (p PropertyCallExpr) String() string
type ReturnStmt ¶
type ReturnStmt struct {
Expr
}
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
NewScope returns a Scope
type ShellCommand ¶
type ShellCommand struct {
Command string
}
ShellCommand is a shell command
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 returns the DeclarationType of the statement Declares() DeclarationType }
Statement describes 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
}
StaticVariableDeclaration is a static variable declaration
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
NewSuperGlobalScope returns a new SuperGlobalScope
type SwitchCase ¶
SwitchCase is a switch case
func (SwitchCase) Children ¶
func (s SwitchCase) Children() []Node
func (SwitchCase) String ¶
func (s SwitchCase) String() string
type SwitchStmt ¶
type SwitchStmt struct { Expr Expr Cases []*SwitchCase DefaultCase *Block }
SwitchStmt is a switch statment
func (SwitchStmt) Children ¶
func (s SwitchStmt) Children() []Node
func (SwitchStmt) Declares ¶
func (SwitchStmt) Declares() DeclarationType
func (SwitchStmt) String ¶
func (s SwitchStmt) String() string
type TernaryCallExpr ¶
TernaryCallExpr is a ternary call expression
func (TernaryCallExpr) Children ¶
func (t TernaryCallExpr) Children() []Node
func (TernaryCallExpr) Declares ¶
func (t TernaryCallExpr) Declares() DeclarationType
func (TernaryCallExpr) EvaluatesTo ¶
func (t TernaryCallExpr) EvaluatesTo() Type
func (TernaryCallExpr) String ¶
func (t TernaryCallExpr) String() string
type ThrowStmt ¶
type ThrowStmt struct {
Expr
}
ThrowStmt is a throw statment
func (ThrowStmt) Declares ¶
func (t ThrowStmt) Declares() DeclarationType
type TryStmt ¶
TryStmt is a try statment
func (TryStmt) Declares ¶
func (TryStmt) 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 is a type
type UnaryCallExpr ¶
UnaryCallExpr is an expression that applies an operator to only one operand. The operator may precede or follow the operand.
func (UnaryCallExpr) Children ¶
func (u UnaryCallExpr) Children() []Node
func (UnaryCallExpr) Declares ¶
func (u UnaryCallExpr) Declares() DeclarationType
func (UnaryCallExpr) EvaluatesTo ¶
func (u UnaryCallExpr) EvaluatesTo() Type
func (UnaryCallExpr) String ¶
func (u UnaryCallExpr) String() string
type Variable ¶
type Variable struct { // Name is the identifier for the variable, which may be // a dynamic expression. Name Dynamic Type Type }
Variable is a variable
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 ¶
VariableGroup is a variable group
type Visibility ¶
type Visibility int
Visibility is a visibility
const ( Private Visibility = iota Protected Public )
func (Visibility) Token ¶
func (v Visibility) Token() token.Token