ir

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Code generated by the `ir/codegen` package. DO NOT EDIT.

Code generated by the `ir/codegen` package. DO NOT EDIT.

Code generated by the `ir/codegen` package. DO NOT EDIT.

Package ir declares intermediate representation type suitable for the analysis.

IR is generated from the AST, see ir/irconv package.

Code generated by the `ir/codegen` package. DO NOT EDIT.

Code generated by the `ir/codegen` package. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFirstToken added in v0.4.0

func GetFirstToken(n Node) *token.Token

func GetPosition

func GetPosition(n Node) *position.Position

Types

type AnonClassExpr

type AnonClassExpr struct {
	Position             *position.Position
	ClassTkn             *token.Token
	OpenParenthesisTkn   *token.Token
	Args                 []Node
	SeparatorTkns        []*token.Token
	CloseParenthesisTkn  *token.Token
	OpenCurlyBracketTkn  *token.Token
	CloseCurlyBracketTkn *token.Token
	Class
}

AnonClassExpr is an anonymous class expression. $Args may contain constructor call arguments `new class ($Args...) {}`.

func (*AnonClassExpr) Arg

func (n *AnonClassExpr) Arg(i int) *Argument

Arg returns the ith argument.

func (*AnonClassExpr) IterateTokens added in v0.4.0

func (n *AnonClassExpr) IterateTokens(cb func(*token.Token) bool)

func (*AnonClassExpr) Walk

func (n *AnonClassExpr) Walk(v Visitor)

type Argument

type Argument struct {
	Position     *position.Position
	Name         *Identifier
	ColonTkn     *token.Token
	VariadicTkn  *token.Token
	AmpersandTkn *token.Token
	Expr         Node
	Variadic     bool
	IsReference  bool
}

Argument is a wrapper node for func/method arguments. Possible syntax's:

$Name: $Expr
$Expr

If $Variadic is true, it's `...$Expr`. If $IsReference is true, it's `&$Expr`.

func (*Argument) IterateTokens added in v0.4.0

func (n *Argument) IterateTokens(cb func(*token.Token) bool)

func (*Argument) Walk

func (n *Argument) Walk(v Visitor)

type ArrayDimFetchExpr

type ArrayDimFetchExpr struct {
	Position        *position.Position
	Variable        Node
	OpenBracketTkn  *token.Token
	Dim             Node
	CloseBracketTkn *token.Token
	CurlyBrace      bool
}

ArrayDimFetchExpr is a `$Variable[$Dim]` expression. If $CurlyBrace is true, it's `$Variable{$Dim}`

func (*ArrayDimFetchExpr) IterateTokens added in v0.4.0

func (n *ArrayDimFetchExpr) IterateTokens(cb func(*token.Token) bool)

func (*ArrayDimFetchExpr) Walk

func (n *ArrayDimFetchExpr) Walk(v Visitor)

type ArrayExpr

type ArrayExpr struct {
	Position        *position.Position
	ArrayTkn        *token.Token
	OpenBracketTkn  *token.Token
	Items           []*ArrayItemExpr
	SeparatorTkns   []*token.Token
	CloseBracketTkn *token.Token
	ShortSyntax     bool
}

ArrayExpr is a `array($Items...)` expression. If $ShortSyntax is true, it's `[$Items...]`.

func (*ArrayExpr) IterateTokens added in v0.4.0

func (n *ArrayExpr) IterateTokens(cb func(*token.Token) bool)

func (*ArrayExpr) Walk

func (n *ArrayExpr) Walk(v Visitor)

type ArrayItemExpr

type ArrayItemExpr struct {
	Position       *position.Position
	EllipsisTkn    *token.Token
	Key            Node
	DoubleArrowTkn *token.Token
	AmpersandTkn   *token.Token
	Val            Node
	Unpack         bool
}

ArrayItemExpr is a `$Key => $Val` expression. If $Unpack is true, it's `...$Val` ($Key is nil).

TODO: make unpack a separate node?

func (*ArrayItemExpr) IterateTokens added in v0.4.0

func (n *ArrayItemExpr) IterateTokens(cb func(*token.Token) bool)

func (*ArrayItemExpr) Walk

func (n *ArrayItemExpr) Walk(v Visitor)

type ArrowFunctionExpr

type ArrowFunctionExpr struct {
	Position            *position.Position
	AttrGroups          []*AttributeGroup
	StaticTkn           *token.Token
	FnTkn               *token.Token
	AmpersandTkn        *token.Token
	OpenParenthesisTkn  *token.Token
	Params              []Node
	SeparatorTkns       []*token.Token
	CloseParenthesisTkn *token.Token
	ColonTkn            *token.Token
	ReturnType          Node
	DoubleArrowTkn      *token.Token
	Expr                Node
	ReturnsRef          bool
	Static              bool

	Doc phpdoc.Comment
}

ArrowFunctionExpr is a `#[$AttrGroups] fn($Params...): $ReturnType => $Expr` expression. If $ReturnsRef is true, it's `fn&($Params...): $ReturnType => $Expr`. If $Static is true, it's `static fn($Params...): $ReturnType => $Expr`. $ReturnType is optional, without it we have `fn($Params...) => $Expr` syntax.

func (*ArrowFunctionExpr) IterateTokens added in v0.4.0

func (n *ArrowFunctionExpr) IterateTokens(cb func(*token.Token) bool)

func (*ArrowFunctionExpr) Walk

func (n *ArrowFunctionExpr) Walk(v Visitor)

type Assign

type Assign struct {
	Position *position.Position
	Variable Node
	EqualTkn *token.Token
	Expr     Node
}

Assign is a `$Variable = $Expression` expression.

func (*Assign) IterateTokens added in v0.4.0

func (n *Assign) IterateTokens(cb func(*token.Token) bool)

func (*Assign) Walk

func (n *Assign) Walk(v Visitor)

type AssignBitwiseAnd

type AssignBitwiseAnd struct {
	Position *position.Position
	Variable Node
	EqualTkn *token.Token
	Expr     Node
}

AssignBitwiseAnd is a `$Variable &= $Expression` expression.

func (*AssignBitwiseAnd) IterateTokens added in v0.4.0

func (n *AssignBitwiseAnd) IterateTokens(cb func(*token.Token) bool)

func (*AssignBitwiseAnd) Walk

func (n *AssignBitwiseAnd) Walk(v Visitor)

type AssignBitwiseOr

type AssignBitwiseOr struct {
	Position *position.Position
	Variable Node
	EqualTkn *token.Token
	Expr     Node
}

AssignBitwiseOr is a `$Variable |= $Expression` expression.

func (*AssignBitwiseOr) IterateTokens added in v0.4.0

func (n *AssignBitwiseOr) IterateTokens(cb func(*token.Token) bool)

func (*AssignBitwiseOr) Walk

func (n *AssignBitwiseOr) Walk(v Visitor)

type AssignBitwiseXor

type AssignBitwiseXor struct {
	Position *position.Position
	Variable Node
	EqualTkn *token.Token
	Expr     Node
}

AssignBitwiseXor is a `$Variable ^= $Expression` expression.

func (*AssignBitwiseXor) IterateTokens added in v0.4.0

func (n *AssignBitwiseXor) IterateTokens(cb func(*token.Token) bool)

func (*AssignBitwiseXor) Walk

func (n *AssignBitwiseXor) Walk(v Visitor)

type AssignCoalesce

type AssignCoalesce struct {
	Position *position.Position
	Variable Node
	EqualTkn *token.Token
	Expr     Node
}

AssignCoalesce is a `$Variable ??= $Expression` expression.

func (*AssignCoalesce) IterateTokens added in v0.4.0

func (n *AssignCoalesce) IterateTokens(cb func(*token.Token) bool)

func (*AssignCoalesce) Walk

func (n *AssignCoalesce) Walk(v Visitor)

type AssignConcat

type AssignConcat struct {
	Position *position.Position
	Variable Node
	EqualTkn *token.Token
	Expr     Node
}

AssignConcat is a `$Variable .= $Expression` expression.

func (*AssignConcat) IterateTokens added in v0.4.0

func (n *AssignConcat) IterateTokens(cb func(*token.Token) bool)

func (*AssignConcat) Walk

func (n *AssignConcat) Walk(v Visitor)

type AssignDiv

type AssignDiv struct {
	Position *position.Position
	Variable Node
	EqualTkn *token.Token
	Expr     Node
}

AssignDiv is a `$Variable /= $Expression` expression.

func (*AssignDiv) IterateTokens added in v0.4.0

func (n *AssignDiv) IterateTokens(cb func(*token.Token) bool)

func (*AssignDiv) Walk

func (n *AssignDiv) Walk(v Visitor)

type AssignMinus

type AssignMinus struct {
	Position *position.Position
	Variable Node
	EqualTkn *token.Token
	Expr     Node
}

AssignMinus is a `$Variable -= $Expression` expression.

func (*AssignMinus) IterateTokens added in v0.4.0

func (n *AssignMinus) IterateTokens(cb func(*token.Token) bool)

func (*AssignMinus) Walk

func (n *AssignMinus) Walk(v Visitor)

type AssignMod

type AssignMod struct {
	Position *position.Position
	Variable Node
	EqualTkn *token.Token
	Expr     Node
}

AssignMod is a `$Variable %= $Expression` expression.

func (*AssignMod) IterateTokens added in v0.4.0

func (n *AssignMod) IterateTokens(cb func(*token.Token) bool)

func (*AssignMod) Walk

func (n *AssignMod) Walk(v Visitor)

type AssignMul

type AssignMul struct {
	Position *position.Position
	Variable Node
	EqualTkn *token.Token
	Expr     Node
}

AssignMul is a `$Variable *= $Expression` expression.

func (*AssignMul) IterateTokens added in v0.4.0

func (n *AssignMul) IterateTokens(cb func(*token.Token) bool)

func (*AssignMul) Walk

func (n *AssignMul) Walk(v Visitor)

type AssignPlus

type AssignPlus struct {
	Position *position.Position
	Variable Node
	EqualTkn *token.Token
	Expr     Node
}

AssignPlus is a `$Variable += $Expression` expression.

func (*AssignPlus) IterateTokens added in v0.4.0

func (n *AssignPlus) IterateTokens(cb func(*token.Token) bool)

func (*AssignPlus) Walk

func (n *AssignPlus) Walk(v Visitor)

type AssignPow

type AssignPow struct {
	Position *position.Position
	Variable Node
	EqualTkn *token.Token
	Expr     Node
}

AssignPow is a `$Variable **= $Expression` expression.

func (*AssignPow) IterateTokens added in v0.4.0

func (n *AssignPow) IterateTokens(cb func(*token.Token) bool)

func (*AssignPow) Walk

func (n *AssignPow) Walk(v Visitor)

type AssignReference

type AssignReference struct {
	Position *position.Position
	Variable Node
	EqualTkn *token.Token
	Expr     Node
}

AssignReference is a `$Variable &= $Expression` expression.

func (*AssignReference) IterateTokens added in v0.4.0

func (n *AssignReference) IterateTokens(cb func(*token.Token) bool)

func (*AssignReference) Walk

func (n *AssignReference) Walk(v Visitor)

type AssignShiftLeft

type AssignShiftLeft struct {
	Position *position.Position
	Variable Node
	EqualTkn *token.Token
	Expr     Node
}

AssignShiftLeft is a `$Variable <<= $Expression` expression.

func (*AssignShiftLeft) IterateTokens added in v0.4.0

func (n *AssignShiftLeft) IterateTokens(cb func(*token.Token) bool)

func (*AssignShiftLeft) Walk

func (n *AssignShiftLeft) Walk(v Visitor)

type AssignShiftRight

type AssignShiftRight struct {
	Position *position.Position
	Variable Node
	EqualTkn *token.Token
	Expr     Node
}

AssignShiftRight is a `$Variable >>= $Expression` expression.

func (*AssignShiftRight) IterateTokens added in v0.4.0

func (n *AssignShiftRight) IterateTokens(cb func(*token.Token) bool)

func (*AssignShiftRight) Walk

func (n *AssignShiftRight) Walk(v Visitor)

type Attribute added in v0.4.0

type Attribute struct {
	Position            *position.Position
	Name                Node
	OpenParenthesisTkn  *token.Token
	Args                []Node
	SeparatorTkns       []*token.Token
	CloseParenthesisTkn *token.Token
}

Attribute node is a `$Name($Args)` inside `#[...]`

func (*Attribute) Arg added in v0.5.1

func (n *Attribute) Arg(i int) *Argument

Arg returns the ith argument.

func (*Attribute) IterateTokens added in v0.4.0

func (n *Attribute) IterateTokens(cb func(*token.Token) bool)

func (*Attribute) Walk added in v0.4.0

func (n *Attribute) Walk(v Visitor)

type AttributeGroup added in v0.4.0

type AttributeGroup struct {
	Position          *position.Position
	OpenAttributeTkn  *token.Token
	Attrs             []*Attribute
	SeparatorTkns     []*token.Token
	CloseAttributeTkn *token.Token
}

AttributeGroup node is #[$Attrs]

func (*AttributeGroup) IterateTokens added in v0.4.0

func (n *AttributeGroup) IterateTokens(cb func(*token.Token) bool)

func (*AttributeGroup) Walk added in v0.4.0

func (n *AttributeGroup) Walk(v Visitor)

type BadString

type BadString struct {
	String
	Error string
}

BadString is a string that we couldn't interpret correctly. The $Value contains uninterpreted (raw) string bytes. $Error contains the reason why this string is "bad".

func (*BadString) IterateTokens added in v0.4.0

func (n *BadString) IterateTokens(cb func(*token.Token) bool)

func (*BadString) Walk

func (n *BadString) Walk(v Visitor)

type BitwiseAndExpr

type BitwiseAndExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

BitwiseAndExpr is a `$Left & $Right` expression.

func (*BitwiseAndExpr) IterateTokens added in v0.4.0

func (n *BitwiseAndExpr) IterateTokens(cb func(*token.Token) bool)

func (*BitwiseAndExpr) Walk

func (n *BitwiseAndExpr) Walk(v Visitor)

type BitwiseNotExpr

type BitwiseNotExpr struct {
	TildaTkn *token.Token
	Position *position.Position
	Expr     Node
}

BitwiseNotExpr is a `~$Expr` expression.

func (*BitwiseNotExpr) IterateTokens added in v0.4.0

func (n *BitwiseNotExpr) IterateTokens(cb func(*token.Token) bool)

func (*BitwiseNotExpr) Walk

func (n *BitwiseNotExpr) Walk(v Visitor)

type BitwiseOrExpr

type BitwiseOrExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

BitwiseOrExpr is a `$Left | $Right` expression.

func (*BitwiseOrExpr) IterateTokens added in v0.4.0

func (n *BitwiseOrExpr) IterateTokens(cb func(*token.Token) bool)

func (*BitwiseOrExpr) Walk

func (n *BitwiseOrExpr) Walk(v Visitor)

type BitwiseXorExpr

type BitwiseXorExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

BitwiseXorExpr is a `$Left ^ $Right` expression.

func (*BitwiseXorExpr) IterateTokens added in v0.4.0

func (n *BitwiseXorExpr) IterateTokens(cb func(*token.Token) bool)

func (*BitwiseXorExpr) Walk

func (n *BitwiseXorExpr) Walk(v Visitor)

type BooleanAndExpr

type BooleanAndExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

BooleanAndExpr is a `$Left && $Right` expression.

func (*BooleanAndExpr) IterateTokens added in v0.4.0

func (n *BooleanAndExpr) IterateTokens(cb func(*token.Token) bool)

func (*BooleanAndExpr) Walk

func (n *BooleanAndExpr) Walk(v Visitor)

type BooleanNotExpr

type BooleanNotExpr struct {
	ExclamationTkn *token.Token
	Position       *position.Position
	Expr           Node
}

BooleanNotExpr is a `!$Expr` expression.

func (*BooleanNotExpr) IterateTokens added in v0.4.0

func (n *BooleanNotExpr) IterateTokens(cb func(*token.Token) bool)

func (*BooleanNotExpr) Walk

func (n *BooleanNotExpr) Walk(v Visitor)

type BooleanOrExpr

type BooleanOrExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

BooleanOrExpr is a `$Left || $Right` expression.

func (*BooleanOrExpr) IterateTokens added in v0.4.0

func (n *BooleanOrExpr) IterateTokens(cb func(*token.Token) bool)

func (*BooleanOrExpr) Walk

func (n *BooleanOrExpr) Walk(v Visitor)

type BreakStmt

type BreakStmt struct {
	Position     *position.Position
	BreakTkn     *token.Token
	Expr         Node
	SemiColonTkn *token.Token
}

BreakStmt is a `break $Expr` statement.

func (*BreakStmt) IterateTokens added in v0.4.0

func (n *BreakStmt) IterateTokens(cb func(*token.Token) bool)

func (*BreakStmt) Walk

func (n *BreakStmt) Walk(v Visitor)

type CaseStmt

type CaseStmt struct {
	Position         *position.Position
	CaseTkn          *token.Token
	Cond             Node
	CaseSeparatorTkn *token.Token
	Stmts            []Node
}

CaseStmt is a `case $Cond: $Stmts...` statement.

func (*CaseStmt) IterateTokens added in v0.4.0

func (n *CaseStmt) IterateTokens(cb func(*token.Token) bool)

func (*CaseStmt) Walk

func (n *CaseStmt) Walk(v Visitor)

type CatchStmt

type CatchStmt struct {
	Position             *position.Position
	CatchTkn             *token.Token
	OpenParenthesisTkn   *token.Token
	Types                []Node
	SeparatorTkns        []*token.Token
	Variable             Node
	CloseParenthesisTkn  *token.Token
	OpenCurlyBracketTkn  *token.Token
	Stmts                []Node
	CloseCurlyBracketTkn *token.Token
}

CatchStmt is a `catch ($Types... $Variable) { $Stmts... }` statement. Note that $Types are |-separated, like in `T1 | T2`.

func (*CatchStmt) IterateTokens added in v0.4.0

func (n *CatchStmt) IterateTokens(cb func(*token.Token) bool)

func (*CatchStmt) Walk

func (n *CatchStmt) Walk(v Visitor)

type Class

type Class struct {
	Extends    *ClassExtendsStmt
	Implements *ClassImplementsStmt
	Stmts      []Node

	Doc phpdoc.Comment
}

Class is a common shape between the ClassStmt and AnonClassExpr. It doesn't include positions info.

type ClassConstFetchExpr

type ClassConstFetchExpr struct {
	Position       *position.Position
	Class          Node
	DoubleColonTkn *token.Token
	ConstantName   *Identifier
}

ClassConstFetchExpr is a `$Class::$ConstantName` expression.

func (*ClassConstFetchExpr) IterateTokens added in v0.4.0

func (n *ClassConstFetchExpr) IterateTokens(cb func(*token.Token) bool)

func (*ClassConstFetchExpr) Walk

func (n *ClassConstFetchExpr) Walk(v Visitor)

type ClassConstListStmt

type ClassConstListStmt struct {
	Position      *position.Position
	AttrGroups    []*AttributeGroup
	Modifiers     []*Identifier
	ConstTkn      *token.Token
	Consts        []Node
	SeparatorTkns []*token.Token
	SemiColonTkn  *token.Token

	Doc phpdoc.Comment
}

ClassConstListStmt is a `#[$AttrGroups] $Modifiers... const $Consts...` statement. $Modifiers may specify the constant access level. Every element in $Consts is a *ConstantStmt.

func (*ClassConstListStmt) IterateTokens added in v0.4.0

func (n *ClassConstListStmt) IterateTokens(cb func(*token.Token) bool)

func (*ClassConstListStmt) Walk

func (n *ClassConstListStmt) Walk(v Visitor)

type ClassExtendsStmt

type ClassExtendsStmt struct {
	Position   *position.Position
	ExtendsTkn *token.Token
	ClassName  *Name
}

ClassExtendsStmt is a `extends $ClassName` statement.

func (*ClassExtendsStmt) IterateTokens added in v0.4.0

func (n *ClassExtendsStmt) IterateTokens(cb func(*token.Token) bool)

func (*ClassExtendsStmt) Walk

func (n *ClassExtendsStmt) Walk(v Visitor)

type ClassImplementsStmt

type ClassImplementsStmt struct {
	Position                *position.Position
	ImplementsTkn           *token.Token
	ImplementsSeparatorTkns []*token.Token
	InterfaceNames          []Node
}

ClassImplementsStmt is a `implements $InterfaceNames...` statement. TODO: shouldn't every InterfaceName be a *Name?

func (*ClassImplementsStmt) IterateTokens added in v0.4.0

func (n *ClassImplementsStmt) IterateTokens(cb func(*token.Token) bool)

func (*ClassImplementsStmt) Walk

func (n *ClassImplementsStmt) Walk(v Visitor)

type ClassMethodStmt

type ClassMethodStmt struct {
	Position            *position.Position
	AttrGroups          []*AttributeGroup
	Modifiers           []*Identifier
	FunctionTkn         *token.Token
	AmpersandTkn        *token.Token
	MethodName          *Identifier
	OpenParenthesisTkn  *token.Token
	Params              []Node
	SeparatorTkns       []*token.Token
	CloseParenthesisTkn *token.Token
	ColonTkn            *token.Token
	ReturnType          Node
	Stmt                Node
	ReturnsRef          bool

	Doc phpdoc.Comment
}

ClassMethodStmt is a class method declaration.

func (*ClassMethodStmt) IterateTokens added in v0.4.0

func (n *ClassMethodStmt) IterateTokens(cb func(*token.Token) bool)

func (*ClassMethodStmt) Walk

func (n *ClassMethodStmt) Walk(v Visitor)

type ClassStmt

type ClassStmt struct {
	Position             *position.Position
	AttrGroups           []*AttributeGroup
	Modifiers            []*Identifier
	ClassTkn             *token.Token
	ClassName            *Identifier
	OpenCurlyBracketTkn  *token.Token
	CloseCurlyBracketTkn *token.Token
	Class
}

ClassStmt is a named class declaration. $Modifiers consist of identifiers like `final` and `abstract`.

func (*ClassStmt) IterateTokens added in v0.4.0

func (n *ClassStmt) IterateTokens(cb func(*token.Token) bool)

func (*ClassStmt) Walk

func (n *ClassStmt) Walk(v Visitor)

type CloneExpr

type CloneExpr struct {
	Position *position.Position
	CloneTkn *token.Token
	Expr     Node
}

CloneExpr is a `clone $Expr` expression.

func (*CloneExpr) IterateTokens added in v0.4.0

func (n *CloneExpr) IterateTokens(cb func(*token.Token) bool)

func (*CloneExpr) Walk

func (n *CloneExpr) Walk(v Visitor)

type CloseTagStmt added in v0.4.0

type CloseTagStmt struct {
	Position *position.Position
	TagTkn   *token.Token
}

CloseTagStmt is `?>` (script closing marker).

func (*CloseTagStmt) IterateTokens added in v0.4.0

func (n *CloseTagStmt) IterateTokens(cb func(*token.Token) bool)

func (*CloseTagStmt) Walk added in v0.4.0

func (n *CloseTagStmt) Walk(v Visitor)

type ClosureExpr

type ClosureExpr struct {
	Position             *position.Position
	AttrGroups           []*AttributeGroup
	StaticTkn            *token.Token
	FunctionTkn          *token.Token
	AmpersandTkn         *token.Token
	OpenParenthesisTkn   *token.Token
	Params               []Node
	SeparatorTkns        []*token.Token
	CloseParenthesisTkn  *token.Token
	ClosureUse           *ClosureUsesExpr
	ColonTkn             *token.Token
	ReturnType           Node
	OpenCurlyBracketTkn  *token.Token
	Stmts                []Node
	CloseCurlyBracketTkn *token.Token
	ReturnsRef           bool
	Static               bool

	Doc phpdoc.Comment
}

ClosureExpr is a `#[$AttrGroups] function($Params...) use ($ClosureUse) : $ReturnType { $Stmts... }` expression. If $ReturnsRef is true, it's `function&($Params...) use ($ClosureUse) : $ReturnType { $Stmts... }`. If $Static is true, it's `static function($Params...) use ($ClosureUse) : $ReturnType { $Stmts... }`. $ReturnType is optional, without it we have `function($Params...) use ($ClosureUse) { $Stmts... }` syntax. $ClosureUse is optional, without it we have `function($Params...) : $ReturnType { $Stmts... }` syntax.

func (*ClosureExpr) IterateTokens added in v0.4.0

func (n *ClosureExpr) IterateTokens(cb func(*token.Token) bool)

func (*ClosureExpr) Walk

func (n *ClosureExpr) Walk(v Visitor)

type ClosureUsesExpr added in v0.4.0

type ClosureUsesExpr struct {
	Position               *position.Position
	UseTkn                 *token.Token
	UseOpenParenthesisTkn  *token.Token
	Uses                   []Node
	UseSeparatorTkns       []*token.Token
	UseCloseParenthesisTkn *token.Token
}

ClosureUsesExpr is a `use ($Uses...)` expression. TODO: it's not a expression really.

func (*ClosureUsesExpr) IterateTokens added in v0.4.0

func (n *ClosureUsesExpr) IterateTokens(cb func(*token.Token) bool)

func (*ClosureUsesExpr) Walk added in v0.4.0

func (n *ClosureUsesExpr) Walk(v Visitor)

type CoalesceExpr

type CoalesceExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

CoalesceExpr is a `$Left ?? $Right` expression.

func (*CoalesceExpr) IterateTokens added in v0.4.0

func (n *CoalesceExpr) IterateTokens(cb func(*token.Token) bool)

func (*CoalesceExpr) Walk

func (n *CoalesceExpr) Walk(v Visitor)

type ConcatExpr

type ConcatExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

ConcatExpr is a `$Left . $Right` expression.

func (*ConcatExpr) IterateTokens added in v0.4.0

func (n *ConcatExpr) IterateTokens(cb func(*token.Token) bool)

func (*ConcatExpr) Walk

func (n *ConcatExpr) Walk(v Visitor)

type ConstFetchExpr

type ConstFetchExpr struct {
	Position *position.Position
	Constant *Name
}

ConstFetchExpr is a `$Constant` expression.

func (*ConstFetchExpr) IterateTokens added in v0.4.0

func (n *ConstFetchExpr) IterateTokens(cb func(*token.Token) bool)

func (*ConstFetchExpr) Walk

func (n *ConstFetchExpr) Walk(v Visitor)

type ConstListStmt

type ConstListStmt struct {
	Position      *position.Position
	ConstTkn      *token.Token
	Consts        []Node
	SeparatorTkns []*token.Token
	SemiColonTkn  *token.Token
}

ConstListStmt is a `const $Consts` statement. Every element in $Consts is a *ConstantStmt.

func (*ConstListStmt) IterateTokens added in v0.4.0

func (n *ConstListStmt) IterateTokens(cb func(*token.Token) bool)

func (*ConstListStmt) Walk

func (n *ConstListStmt) Walk(v Visitor)

type ConstantStmt

type ConstantStmt struct {
	Position     *position.Position
	ConstantName *Identifier
	EqualTkn     *token.Token
	Expr         Node
}

ConstantStmt is a `$ConstantName = $Expr` statement. It's a part of the *ConstListStmt, *ClassConstListStmt and *DeclareStmt.

func (*ConstantStmt) IterateTokens added in v0.4.0

func (n *ConstantStmt) IterateTokens(cb func(*token.Token) bool)

func (*ConstantStmt) Walk

func (n *ConstantStmt) Walk(v Visitor)

type ContinueStmt

type ContinueStmt struct {
	Position     *position.Position
	ContinueTkn  *token.Token
	Expr         Node
	SemiColonTkn *token.Token
}

ContinueStmt is a `continue $Expr` statement.

func (*ContinueStmt) IterateTokens added in v0.4.0

func (n *ContinueStmt) IterateTokens(cb func(*token.Token) bool)

func (*ContinueStmt) Walk

func (n *ContinueStmt) Walk(v Visitor)

type DeclareStmt

type DeclareStmt struct {
	Position            *position.Position
	DeclareTkn          *token.Token
	OpenParenthesisTkn  *token.Token
	Consts              []Node
	SeparatorTkns       []*token.Token
	CloseParenthesisTkn *token.Token
	ColonTkn            *token.Token
	Stmt                Node
	EndDeclareTkn       *token.Token
	SemiColonTkn        *token.Token
	Alt                 bool
}

DeclareStmt is a `declare ($Consts...) $Stmt` statement. $Stmt can be an empty statement, like in `declare ($Consts...);`, but it can also be a block like in `declare ($Consts...) {}`. If $Alt is true, the block will begin with `:` and end with `enddeclare`. Every element in $Consts is a *ConstantStmt.

func (*DeclareStmt) IterateTokens added in v0.4.0

func (n *DeclareStmt) IterateTokens(cb func(*token.Token) bool)

func (*DeclareStmt) Walk

func (n *DeclareStmt) Walk(v Visitor)

type DefaultStmt

type DefaultStmt struct {
	Position         *position.Position
	DefaultTkn       *token.Token
	CaseSeparatorTkn *token.Token
	Stmts            []Node
}

DefaultStmt is a `default: $Stmts...` statement.

func (*DefaultStmt) IterateTokens added in v0.4.0

func (n *DefaultStmt) IterateTokens(cb func(*token.Token) bool)

func (*DefaultStmt) Walk

func (n *DefaultStmt) Walk(v Visitor)

type DivExpr

type DivExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

DivExpr is a `$Left / $Right` expression.

func (*DivExpr) IterateTokens added in v0.4.0

func (n *DivExpr) IterateTokens(cb func(*token.Token) bool)

func (*DivExpr) Walk

func (n *DivExpr) Walk(v Visitor)

type Dnumber

type Dnumber struct {
	Position  *position.Position
	NumberTkn *token.Token
	Value     string
}

Dnumber is a floating point literal.

func (*Dnumber) IterateTokens added in v0.4.0

func (n *Dnumber) IterateTokens(cb func(*token.Token) bool)

func (*Dnumber) Walk

func (n *Dnumber) Walk(v Visitor)

type DoStmt

type DoStmt struct {
	Position            *position.Position
	DoTkn               *token.Token
	Stmt                Node
	WhileTkn            *token.Token
	OpenParenthesisTkn  *token.Token
	Cond                Node
	CloseParenthesisTkn *token.Token
	SemiColonTkn        *token.Token
}

DoStmt is a `do $Stmt while ($Cond)` statement.

func (*DoStmt) IterateTokens added in v0.4.0

func (n *DoStmt) IterateTokens(cb func(*token.Token) bool)

func (*DoStmt) Walk

func (n *DoStmt) Walk(v Visitor)

type EchoStmt

type EchoStmt struct {
	Position      *position.Position
	EchoTkn       *token.Token
	Exprs         []Node
	SeparatorTkns []*token.Token
	SemiColonTkn  *token.Token
}

EchoStmt is a `echo $Exprs...` statement.

func (*EchoStmt) IterateTokens added in v0.4.0

func (n *EchoStmt) IterateTokens(cb func(*token.Token) bool)

func (*EchoStmt) Walk

func (n *EchoStmt) Walk(v Visitor)

type ElseIfStmt

type ElseIfStmt struct {
	Position            *position.Position
	ElseIfTkn           *token.Token
	ElseTkn             *token.Token
	IfTkn               *token.Token
	OpenParenthesisTkn  *token.Token
	Cond                Node
	CloseParenthesisTkn *token.Token
	ColonTkn            *token.Token
	Stmt                Node
	AltSyntax           bool
	Merged              bool
}

ElseIfStmt is a `elseif ($Cond) $Stmt` statement. If $AltSyntax is true, the block will begin with `:` and end with `endif`. $Merged tells whether this elseif is a merged `else if` statement.

func (*ElseIfStmt) IterateTokens added in v0.4.0

func (n *ElseIfStmt) IterateTokens(cb func(*token.Token) bool)

func (*ElseIfStmt) Walk

func (n *ElseIfStmt) Walk(v Visitor)

type ElseStmt

type ElseStmt struct {
	Position  *position.Position
	ElseTkn   *token.Token
	ColonTkn  *token.Token
	Stmt      Node
	AltSyntax bool
}

ElseStmt is a `else $Stmt` statement. If $AltSyntax is true, the block will begin with `:`.

func (*ElseStmt) IterateTokens added in v0.4.0

func (n *ElseStmt) IterateTokens(cb func(*token.Token) bool)

func (*ElseStmt) Walk

func (n *ElseStmt) Walk(v Visitor)

type EmptyExpr

type EmptyExpr struct {
	Position            *position.Position
	EmptyTkn            *token.Token
	OpenParenthesisTkn  *token.Token
	Expr                Node
	CloseParenthesisTkn *token.Token
}

EmptyExpr is a `empty($Expr)` expression.

func (*EmptyExpr) IterateTokens added in v0.4.0

func (n *EmptyExpr) IterateTokens(cb func(*token.Token) bool)

func (*EmptyExpr) Walk

func (n *EmptyExpr) Walk(v Visitor)

type Encapsed

type Encapsed struct {
	Position      *position.Position
	OpenQuoteTkn  *token.Token
	Parts         []Node
	CloseQuoteTkn *token.Token
}

Encapsed is a string literal with interpolated parts.

func (*Encapsed) IterateTokens added in v0.4.0

func (n *Encapsed) IterateTokens(cb func(*token.Token) bool)

func (*Encapsed) Walk

func (n *Encapsed) Walk(v Visitor)

type EncapsedStringPart

type EncapsedStringPart struct {
	Position       *position.Position
	EncapsedStrTkn *token.Token
	Value          string
}

EncapsedStringPart is a part of the Encapsed literal.

func (*EncapsedStringPart) IterateTokens added in v0.4.0

func (n *EncapsedStringPart) IterateTokens(cb func(*token.Token) bool)

func (*EncapsedStringPart) Walk

func (n *EncapsedStringPart) Walk(v Visitor)

type EqualExpr

type EqualExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

EqualExpr is a `$Left == $Right` expression.

func (*EqualExpr) IterateTokens added in v0.4.0

func (n *EqualExpr) IterateTokens(cb func(*token.Token) bool)

func (*EqualExpr) Walk

func (n *EqualExpr) Walk(v Visitor)

type ErrorSuppressExpr

type ErrorSuppressExpr struct {
	Position *position.Position
	AtTkn    *token.Token
	Expr     Node
}

ErrorSuppressExpr is a `@$Expr` expression.

func (*ErrorSuppressExpr) IterateTokens added in v0.4.0

func (n *ErrorSuppressExpr) IterateTokens(cb func(*token.Token) bool)

func (*ErrorSuppressExpr) Walk

func (n *ErrorSuppressExpr) Walk(v Visitor)

type EvalExpr

type EvalExpr struct {
	Position            *position.Position
	EvalTkn             *token.Token
	OpenParenthesisTkn  *token.Token
	Expr                Node
	CloseParenthesisTkn *token.Token
}

EvalExpr is a `eval($Expr)` expression.

func (*EvalExpr) IterateTokens added in v0.4.0

func (n *EvalExpr) IterateTokens(cb func(*token.Token) bool)

func (*EvalExpr) Walk

func (n *EvalExpr) Walk(v Visitor)

type ExitExpr

type ExitExpr struct {
	Position            *position.Position
	ExitTkn             *token.Token
	OpenParenthesisTkn  *token.Token
	Expr                Node
	CloseParenthesisTkn *token.Token
	Die                 bool
}

ExitExpr is a `exit($Expr)` expression. If $Die is true, it's `die($Expr)`.

func (*ExitExpr) IterateTokens added in v0.4.0

func (n *ExitExpr) IterateTokens(cb func(*token.Token) bool)

func (*ExitExpr) Walk

func (n *ExitExpr) Walk(v Visitor)

type ExpressionStmt

type ExpressionStmt struct {
	Position     *position.Position
	Expr         Node
	SemiColonTkn *token.Token
}

ExpressionStmt is an expression $Expr that is evaluated for side-effects only. When expression is used in a place where statement is expected, it becomes an ExpressionStmt.

func (*ExpressionStmt) IterateTokens added in v0.4.0

func (n *ExpressionStmt) IterateTokens(cb func(*token.Token) bool)

func (*ExpressionStmt) Walk

func (n *ExpressionStmt) Walk(v Visitor)

type FinallyStmt

type FinallyStmt struct {
	Position             *position.Position
	FinallyTkn           *token.Token
	OpenCurlyBracketTkn  *token.Token
	Stmts                []Node
	CloseCurlyBracketTkn *token.Token
}

FinallyStmt is a `finally { $Stmts... }` statement.

func (*FinallyStmt) IterateTokens added in v0.4.0

func (n *FinallyStmt) IterateTokens(cb func(*token.Token) bool)

func (*FinallyStmt) Walk

func (n *FinallyStmt) Walk(v Visitor)

type ForStmt

type ForStmt struct {
	Position            *position.Position
	ForTkn              *token.Token
	OpenParenthesisTkn  *token.Token
	Init                []Node
	InitSeparatorTkns   []*token.Token
	InitSemiColonTkn    *token.Token
	Cond                []Node
	CondSeparatorTkns   []*token.Token
	CondSemiColonTkn    *token.Token
	Loop                []Node
	LoopSeparatorTkns   []*token.Token
	CloseParenthesisTkn *token.Token
	ColonTkn            *token.Token
	Stmt                Node
	EndForTkn           *token.Token
	SemiColonTkn        *token.Token
	AltSyntax           bool
}

ForStmt is a `for ($Init; $Cond; $Loop) $Stmt` statement. If $AltSyntax is true, the block will begin with `:` and end with `endfor`.

func (*ForStmt) IterateTokens added in v0.4.0

func (n *ForStmt) IterateTokens(cb func(*token.Token) bool)

func (*ForStmt) Walk

func (n *ForStmt) Walk(v Visitor)

type ForeachStmt

type ForeachStmt struct {
	Position            *position.Position
	ForeachTkn          *token.Token
	OpenParenthesisTkn  *token.Token
	Expr                Node
	AsTkn               *token.Token
	Key                 Node
	DoubleArrowTkn      *token.Token
	AmpersandTkn        *token.Token
	Variable            Node
	CloseParenthesisTkn *token.Token
	ColonTkn            *token.Token
	Stmt                Node
	EndForeachTkn       *token.Token
	SemiColonTkn        *token.Token
	AltSyntax           bool
}

ForeachStmt is a `foreach ($Expr as $Key => $Variable) $Stmt` statement. If $AltSyntax is true, the block will begin with `:` and end with `endforeach`.

func (*ForeachStmt) IterateTokens added in v0.4.0

func (n *ForeachStmt) IterateTokens(cb func(*token.Token) bool)

func (*ForeachStmt) Walk

func (n *ForeachStmt) Walk(v Visitor)

type FunctionCallExpr

type FunctionCallExpr struct {
	Position            *position.Position
	Function            Node
	OpenParenthesisTkn  *token.Token
	Args                []Node
	SeparatorTkns       []*token.Token
	CloseParenthesisTkn *token.Token
}

FunctionCallExpr is a `$Function($Args...)` expression.

func (*FunctionCallExpr) Arg

func (n *FunctionCallExpr) Arg(i int) *Argument

Arg returns the ith argument.

func (*FunctionCallExpr) IterateTokens added in v0.4.0

func (n *FunctionCallExpr) IterateTokens(cb func(*token.Token) bool)

func (*FunctionCallExpr) Walk

func (n *FunctionCallExpr) Walk(v Visitor)

type FunctionStmt

type FunctionStmt struct {
	Position             *position.Position
	AttrGroups           []*AttributeGroup
	FunctionTkn          *token.Token
	AmpersandTkn         *token.Token
	FunctionName         *Identifier
	OpenParenthesisTkn   *token.Token
	Params               []Node
	SeparatorTkns        []*token.Token
	CloseParenthesisTkn  *token.Token
	ColonTkn             *token.Token
	ReturnType           Node
	OpenCurlyBracketTkn  *token.Token
	Stmts                []Node
	CloseCurlyBracketTkn *token.Token
	ReturnsRef           bool

	Doc phpdoc.Comment
}

FunctionStmt is a named function declaration.

func (*FunctionStmt) IterateTokens added in v0.4.0

func (n *FunctionStmt) IterateTokens(cb func(*token.Token) bool)

func (*FunctionStmt) Walk

func (n *FunctionStmt) Walk(v Visitor)

type GlobalStmt

type GlobalStmt struct {
	Position      *position.Position
	GlobalTkn     *token.Token
	Vars          []Node
	SeparatorTkns []*token.Token
	SemiColonTkn  *token.Token
}

GlobalStmt is a `global $Vars` statement.

func (*GlobalStmt) IterateTokens added in v0.4.0

func (n *GlobalStmt) IterateTokens(cb func(*token.Token) bool)

func (*GlobalStmt) Walk

func (n *GlobalStmt) Walk(v Visitor)

type GotoStmt

type GotoStmt struct {
	Position     *position.Position
	GotoTkn      *token.Token
	Label        *Identifier
	SemiColonTkn *token.Token
}

GotoStmt is a `goto $Label` statement.

func (*GotoStmt) IterateTokens added in v0.4.0

func (n *GotoStmt) IterateTokens(cb func(*token.Token) bool)

func (*GotoStmt) Walk

func (n *GotoStmt) Walk(v Visitor)

type GreaterExpr

type GreaterExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

GreaterExpr is a `$Left > $Right` expression.

func (*GreaterExpr) IterateTokens added in v0.4.0

func (n *GreaterExpr) IterateTokens(cb func(*token.Token) bool)

func (*GreaterExpr) Walk

func (n *GreaterExpr) Walk(v Visitor)

type GreaterOrEqualExpr

type GreaterOrEqualExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

GreaterOrEqualExpr is a `$Left >= $Right` expression.

func (*GreaterOrEqualExpr) IterateTokens added in v0.4.0

func (n *GreaterOrEqualExpr) IterateTokens(cb func(*token.Token) bool)

func (*GreaterOrEqualExpr) Walk

func (n *GreaterOrEqualExpr) Walk(v Visitor)

type GroupUseStmt

type GroupUseStmt struct {
	Position              *position.Position
	UseTkn                *token.Token
	UseType               *Identifier
	LeadingNsSeparatorTkn *token.Token
	Prefix                *Name
	NsSeparatorTkn        *token.Token
	OpenCurlyBracketTkn   *token.Token
	UseList               []Node
	SeparatorTkns         []*token.Token
	CloseCurlyBracketTkn  *token.Token
	SemiColonTkn          *token.Token
}

GroupUseStmt is a `use $UseType $Prefix\{ $UseList }` statement. $UseType is a "function" or "const".

func (*GroupUseStmt) IterateTokens added in v0.4.0

func (n *GroupUseStmt) IterateTokens(cb func(*token.Token) bool)

func (*GroupUseStmt) Walk

func (n *GroupUseStmt) Walk(v Visitor)

type HaltCompilerStmt

type HaltCompilerStmt struct {
	Position            *position.Position
	HaltCompilerTkn     *token.Token
	OpenParenthesisTkn  *token.Token
	CloseParenthesisTkn *token.Token
	SemiColonTkn        *token.Token
}

HaltCompilerStmt is a `__halt_compiler()` statement.

func (*HaltCompilerStmt) IterateTokens added in v0.4.0

func (n *HaltCompilerStmt) IterateTokens(cb func(*token.Token) bool)

func (*HaltCompilerStmt) Walk

func (n *HaltCompilerStmt) Walk(v Visitor)

type Heredoc

type Heredoc struct {
	Position        *position.Position
	Label           string
	OpenHeredocTkn  *token.Token
	Parts           []Node
	CloseHeredocTkn *token.Token
}

Heredoc is special PHP literal. Note that it may be a nowdoc, depending on the label.

func (*Heredoc) IterateTokens added in v0.4.0

func (n *Heredoc) IterateTokens(cb func(*token.Token) bool)

func (*Heredoc) Walk

func (n *Heredoc) Walk(v Visitor)

type IdenticalExpr

type IdenticalExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

IdenticalExpr is a `$Left === $Right` expression.

func (*IdenticalExpr) IterateTokens added in v0.4.0

func (n *IdenticalExpr) IterateTokens(cb func(*token.Token) bool)

func (*IdenticalExpr) Walk

func (n *IdenticalExpr) Walk(v Visitor)

type Identifier

type Identifier struct {
	Position      *position.Position
	IdentifierTkn *token.Token
	Value         string
}

Identifier is like a name, but it's always resolved to itself. Identifier always consists of a single part.

func (*Identifier) IterateTokens added in v0.4.0

func (n *Identifier) IterateTokens(cb func(*token.Token) bool)

func (*Identifier) Walk

func (n *Identifier) Walk(v Visitor)

type IfStmt

type IfStmt struct {
	Position            *position.Position
	IfTkn               *token.Token
	OpenParenthesisTkn  *token.Token
	Cond                Node
	CloseParenthesisTkn *token.Token
	ColonTkn            *token.Token
	Stmt                Node
	ElseIf              []Node
	Else                Node
	EndIfTkn            *token.Token
	SemiColonTkn        *token.Token
	ElseTkn             *token.Token
	AltSyntax           bool
}

IfStmt is a `if ($Cond) $Stmt` statement. $ElseIf contains an entire elseif chain, if any. $Else may contain an else part of the statement.

func (*IfStmt) IterateTokens added in v0.4.0

func (n *IfStmt) IterateTokens(cb func(*token.Token) bool)

func (*IfStmt) Walk

func (n *IfStmt) Walk(v Visitor)

type ImportExpr

type ImportExpr struct {
	Position  *position.Position
	ImportTkn *token.Token
	Func      string // "include" "include_once" "require" "require_once"
	Expr      Node
}

ImportExpr is a `$Func $Expr` expression. It could be `include $Expr`, `require $Expr` and so on.

func (*ImportExpr) IterateTokens added in v0.4.0

func (n *ImportExpr) IterateTokens(cb func(*token.Token) bool)

func (*ImportExpr) Walk

func (n *ImportExpr) Walk(v Visitor)

type InlineHTMLStmt

type InlineHTMLStmt struct {
	Position      *position.Position
	InlineHTMLTkn *token.Token
	Value         string
}

InlineHTMLStmt is a part of the script that will not be interpreted as a PHP script. In other words, it's everything outside of the <? and ?> tags.

func (*InlineHTMLStmt) IterateTokens added in v0.4.0

func (n *InlineHTMLStmt) IterateTokens(cb func(*token.Token) bool)

func (*InlineHTMLStmt) Walk

func (n *InlineHTMLStmt) Walk(v Visitor)

type InstanceOfExpr

type InstanceOfExpr struct {
	Position      *position.Position
	Expr          Node
	InstanceOfTkn *token.Token
	Class         Node
}

InstanceOfExpr is a `$Expr instanceof $Class` expression.

func (*InstanceOfExpr) IterateTokens added in v0.4.0

func (n *InstanceOfExpr) IterateTokens(cb func(*token.Token) bool)

func (*InstanceOfExpr) Walk

func (n *InstanceOfExpr) Walk(v Visitor)

type InterfaceExtendsStmt

type InterfaceExtendsStmt struct {
	Position             *position.Position
	ExtendsTkn           *token.Token
	InterfaceNames       []Node
	ExtendsSeparatorTkns []*token.Token
}

InterfaceExtendsStmt is a `extends $InterfaceNames...` statement. TODO: InterfaceNames could be a []*Name.

func (*InterfaceExtendsStmt) IterateTokens added in v0.4.0

func (n *InterfaceExtendsStmt) IterateTokens(cb func(*token.Token) bool)

func (*InterfaceExtendsStmt) Walk

func (n *InterfaceExtendsStmt) Walk(v Visitor)

type InterfaceStmt

type InterfaceStmt struct {
	Position             *position.Position
	AttrGroups           []*AttributeGroup
	InterfaceTkn         *token.Token
	InterfaceName        *Identifier
	Extends              *InterfaceExtendsStmt
	OpenCurlyBracketTkn  *token.Token
	Stmts                []Node
	CloseCurlyBracketTkn *token.Token

	Doc phpdoc.Comment
}

InterfaceStmt is an interface declaration.

func (*InterfaceStmt) IterateTokens added in v0.4.0

func (n *InterfaceStmt) IterateTokens(cb func(*token.Token) bool)

func (*InterfaceStmt) Walk

func (n *InterfaceStmt) Walk(v Visitor)

type IssetExpr

type IssetExpr struct {
	Position            *position.Position
	IssetTkn            *token.Token
	OpenParenthesisTkn  *token.Token
	Variables           []Node
	SeparatorTkns       []*token.Token
	CloseParenthesisTkn *token.Token
}

IssetExpr is a `isset($Variables...)` expression.

func (*IssetExpr) IterateTokens added in v0.4.0

func (n *IssetExpr) IterateTokens(cb func(*token.Token) bool)

func (*IssetExpr) Walk

func (n *IssetExpr) Walk(v Visitor)

type LabelStmt

type LabelStmt struct {
	Position  *position.Position
	LabelName *Identifier
	ColonTkn  *token.Token
}

LabelStmt is a `$LabelName:` statement.

func (*LabelStmt) IterateTokens added in v0.4.0

func (n *LabelStmt) IterateTokens(cb func(*token.Token) bool)

func (*LabelStmt) Walk

func (n *LabelStmt) Walk(v Visitor)

type ListExpr

type ListExpr struct {
	Position        *position.Position
	ListTkn         *token.Token
	OpenBracketTkn  *token.Token
	Items           []*ArrayItemExpr
	SeparatorTkns   []*token.Token
	CloseBracketTkn *token.Token
	ShortSyntax     bool
}

ListExpr is a `list($Items...)` expression. Note that it may appear not only in assignments as LHS, but also in foreach value expressions. If $ShortSyntax is true, it's `[$Items]`.

func (*ListExpr) IterateTokens added in v0.4.0

func (n *ListExpr) IterateTokens(cb func(*token.Token) bool)

func (*ListExpr) Walk

func (n *ListExpr) Walk(v Visitor)

type Lnumber

type Lnumber struct {
	Position  *position.Position
	NumberTkn *token.Token
	Value     string
}

Lnumber is an integer literal.

func (*Lnumber) IterateTokens added in v0.4.0

func (n *Lnumber) IterateTokens(cb func(*token.Token) bool)

func (*Lnumber) Walk

func (n *Lnumber) Walk(v Visitor)

type Location added in v0.4.0

type Location struct {
	StartLine int
	EndLine   int
	StartChar int
	EndChar   int
}

Location stores the position of some element, where StartChar and EndChar are offsets relative to the current line, as opposed to position.Position, where the offset is relative to the beginning of the file.

func NewLocation added in v0.4.0

func NewLocation(startLine int, endLine int, startChar int, endChar int) *Location

type LogicalAndExpr

type LogicalAndExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

LogicalAndExpr is a `$Left and $Right` expression.

func (*LogicalAndExpr) IterateTokens added in v0.4.0

func (n *LogicalAndExpr) IterateTokens(cb func(*token.Token) bool)

func (*LogicalAndExpr) Walk

func (n *LogicalAndExpr) Walk(v Visitor)

type LogicalOrExpr

type LogicalOrExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

LogicalOrExpr is a `$Left or $Right` expression.

func (*LogicalOrExpr) IterateTokens added in v0.4.0

func (n *LogicalOrExpr) IterateTokens(cb func(*token.Token) bool)

func (*LogicalOrExpr) Walk

func (n *LogicalOrExpr) Walk(v Visitor)

type LogicalXorExpr

type LogicalXorExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

LogicalXorExpr is a `$Left xor $Right` expression.

func (*LogicalXorExpr) IterateTokens added in v0.4.0

func (n *LogicalXorExpr) IterateTokens(cb func(*token.Token) bool)

func (*LogicalXorExpr) Walk

func (n *LogicalXorExpr) Walk(v Visitor)

type MagicConstant

type MagicConstant struct {
	Position      *position.Position
	MagicConstTkn *token.Token
	Value         string
}

MagicConstant is a special PHP constant like __FILE__ or __CLASS__.

func (*MagicConstant) IterateTokens added in v0.4.0

func (n *MagicConstant) IterateTokens(cb func(*token.Token) bool)

func (*MagicConstant) Walk

func (n *MagicConstant) Walk(v Visitor)

type MatchArm added in v0.4.0

type MatchArm struct {
	Position        *position.Position
	DefaultTkn      *token.Token
	DefaultCommaTkn *token.Token
	Exprs           []Node
	SeparatorTkns   []*token.Token
	DoubleArrowTkn  *token.Token
	ReturnExpr      Node
	IsDefault       bool
}

MatchArm node is a `$Exprs or 'default' => $ReturnExpr`

func (*MatchArm) IterateTokens added in v0.4.0

func (n *MatchArm) IterateTokens(cb func(*token.Token) bool)

func (*MatchArm) Walk added in v0.4.0

func (n *MatchArm) Walk(v Visitor)

type MatchExpr added in v0.4.0

type MatchExpr struct {
	Position             *position.Position
	MatchTkn             *token.Token
	OpenParenthesisTkn   *token.Token
	Expr                 Node
	CloseParenthesisTkn  *token.Token
	OpenCurlyBracketTkn  *token.Token
	Arms                 []*MatchArm
	SeparatorTkns        []*token.Token
	CloseCurlyBracketTkn *token.Token
}

MatchExpr node is a `match($Expr) { $Arms }`

func (*MatchExpr) IterateTokens added in v0.4.0

func (n *MatchExpr) IterateTokens(cb func(*token.Token) bool)

func (*MatchExpr) Walk added in v0.4.0

func (n *MatchExpr) Walk(v Visitor)

type MethodCallExpr

type MethodCallExpr struct {
	Position             *position.Position
	Variable             Node
	ObjectOperatorTkn    *token.Token
	OpenCurlyBracketTkn  *token.Token
	Method               Node
	CloseCurlyBracketTkn *token.Token
	OpenParenthesisTkn   *token.Token
	Args                 []Node
	SeparatorTkns        []*token.Token
	CloseParenthesisTkn  *token.Token
}

MethodCallExpr is a `$Variable->$Method($Args...)` expression.

func (*MethodCallExpr) Arg

func (n *MethodCallExpr) Arg(i int) *Argument

Arg returns the ith argument.

func (*MethodCallExpr) IterateTokens added in v0.4.0

func (n *MethodCallExpr) IterateTokens(cb func(*token.Token) bool)

func (*MethodCallExpr) Walk

func (n *MethodCallExpr) Walk(v Visitor)

type MinusExpr

type MinusExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

MinusExpr is a `$Left - $Right` expression.

func (*MinusExpr) IterateTokens added in v0.4.0

func (n *MinusExpr) IterateTokens(cb func(*token.Token) bool)

func (*MinusExpr) Walk

func (n *MinusExpr) Walk(v Visitor)

type ModExpr

type ModExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

ModExpr is a `$Left % $Right` expression.

func (*ModExpr) IterateTokens added in v0.4.0

func (n *ModExpr) IterateTokens(cb func(*token.Token) bool)

func (*ModExpr) Walk

func (n *ModExpr) Walk(v Visitor)

type MulExpr

type MulExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

MulExpr is a `$Left * $Right` expression.

func (*MulExpr) IterateTokens added in v0.4.0

func (n *MulExpr) IterateTokens(cb func(*token.Token) bool)

func (*MulExpr) Walk

func (n *MulExpr) Walk(v Visitor)

type Name

type Name struct {
	Position *position.Position
	NameTkn  *token.Token
	Value    string
}

Name is either a FQN, local name or a name that may need a further resolving. Use Name methods to interpret the $Value correctly.

func (*Name) FirstPart

func (n *Name) FirstPart() string

FirstPart returns only the first name part. If name contains only one part, that part is returned.

func (*Name) HeadTail

func (n *Name) HeadTail() (head, tail string)

HeadTail is an efficient way to get <FirstPart, RestParts> pair.

func (*Name) IsFullyQualified

func (n *Name) IsFullyQualified() bool

IsFullyQualified reports whether the name is fully qualified. FQN don't need any further resolution.

func (*Name) IterateTokens added in v0.4.0

func (n *Name) IterateTokens(cb func(*token.Token) bool)

func (*Name) LastPart

func (n *Name) LastPart() string

LastPart returns only the last name part. If name contains only one part, that part is returned.

func (*Name) NumParts

func (n *Name) NumParts() int

NumParts reports number of the name parts.

func (*Name) RestParts

func (n *Name) RestParts() string

RestParts returns all but first name parts. If name contains only one part, empty string is returned.

func (*Name) Walk

func (n *Name) Walk(v Visitor)

type NamespaceStmt

type NamespaceStmt struct {
	Position             *position.Position
	NsTkn                *token.Token
	NamespaceName        *Name
	OpenCurlyBracketTkn  *token.Token
	Stmts                []Node
	CloseCurlyBracketTkn *token.Token
	SemiColonTkn         *token.Token
}

NamespaceStmt is a `namespace $NamespaceName` statement. If $Stmts is not nil, it's `namespace $NamespaceName { $Stmts... }`.

func (*NamespaceStmt) IterateTokens added in v0.4.0

func (n *NamespaceStmt) IterateTokens(cb func(*token.Token) bool)

func (*NamespaceStmt) Walk

func (n *NamespaceStmt) Walk(v Visitor)

type NewExpr

type NewExpr struct {
	Position            *position.Position
	NewTkn              *token.Token
	Class               Node
	OpenParenthesisTkn  *token.Token
	Args                []Node
	SeparatorTkns       []*token.Token
	CloseParenthesisTkn *token.Token
}

NewExpr is a `new $Class($Args...)` expression. If $Args is nil, it's `new $Class`.

func (*NewExpr) Arg

func (n *NewExpr) Arg(i int) *Argument

Arg returns the ith argument.

func (*NewExpr) IterateTokens added in v0.4.0

func (n *NewExpr) IterateTokens(cb func(*token.Token) bool)

func (*NewExpr) Walk

func (n *NewExpr) Walk(v Visitor)

type Node

type Node interface {
	Walk(Visitor)
	IterateTokens(func(*token.Token) bool)
}

Node is a type that is implemented by all IR types. node_types.go contains all implementations.

type NodeKind

type NodeKind int
const (
	KindAnonClassExpr NodeKind = iota
	KindArgument
	KindArrayDimFetchExpr
	KindArrayExpr
	KindArrayItemExpr
	KindArrowFunctionExpr
	KindAssign
	KindAssignBitwiseAnd
	KindAssignBitwiseOr
	KindAssignBitwiseXor
	KindAssignCoalesce
	KindAssignConcat
	KindAssignDiv
	KindAssignMinus
	KindAssignMod
	KindAssignMul
	KindAssignPlus
	KindAssignPow
	KindAssignReference
	KindAssignShiftLeft
	KindAssignShiftRight
	KindAttribute
	KindAttributeGroup
	KindBadString
	KindBitwiseAndExpr
	KindBitwiseNotExpr
	KindBitwiseOrExpr
	KindBitwiseXorExpr
	KindBooleanAndExpr
	KindBooleanNotExpr
	KindBooleanOrExpr
	KindBreakStmt
	KindCaseStmt
	KindCatchStmt
	KindClassConstFetchExpr
	KindClassConstListStmt
	KindClassExtendsStmt
	KindClassImplementsStmt
	KindClassMethodStmt
	KindClassStmt
	KindCloneExpr
	KindCloseTagStmt
	KindClosureExpr
	KindClosureUsesExpr
	KindCoalesceExpr
	KindConcatExpr
	KindConstFetchExpr
	KindConstListStmt
	KindConstantStmt
	KindContinueStmt
	KindDeclareStmt
	KindDefaultStmt
	KindDivExpr
	KindDnumber
	KindDoStmt
	KindEchoStmt
	KindElseIfStmt
	KindElseStmt
	KindEmptyExpr
	KindEncapsed
	KindEncapsedStringPart
	KindEqualExpr
	KindErrorSuppressExpr
	KindEvalExpr
	KindExitExpr
	KindExpressionStmt
	KindFinallyStmt
	KindForStmt
	KindForeachStmt
	KindFunctionCallExpr
	KindFunctionStmt
	KindGlobalStmt
	KindGotoStmt
	KindGreaterExpr
	KindGreaterOrEqualExpr
	KindGroupUseStmt
	KindHaltCompilerStmt
	KindHeredoc
	KindIdenticalExpr
	KindIdentifier
	KindIfStmt
	KindImportExpr
	KindInlineHTMLStmt
	KindInstanceOfExpr
	KindInterfaceExtendsStmt
	KindInterfaceStmt
	KindIssetExpr
	KindLabelStmt
	KindListExpr
	KindLnumber
	KindLogicalAndExpr
	KindLogicalOrExpr
	KindLogicalXorExpr
	KindMagicConstant
	KindMatchArm
	KindMatchExpr
	KindMethodCallExpr
	KindMinusExpr
	KindModExpr
	KindMulExpr
	KindName
	KindNamespaceStmt
	KindNewExpr
	KindNopStmt
	KindNotEqualExpr
	KindNotIdenticalExpr
	KindNullable
	KindNullsafeMethodCallExpr
	KindNullsafePropertyFetchExpr
	KindParameter
	KindParenExpr
	KindPlusExpr
	KindPostDecExpr
	KindPostIncExpr
	KindPowExpr
	KindPreDecExpr
	KindPreIncExpr
	KindPrintExpr
	KindPropertyFetchExpr
	KindPropertyListStmt
	KindPropertyStmt
	KindReferenceExpr
	KindReturnStmt
	KindRoot
	KindShellExecExpr
	KindShiftLeftExpr
	KindShiftRightExpr
	KindSimpleVar
	KindSmallerExpr
	KindSmallerOrEqualExpr
	KindSpaceshipExpr
	KindStaticCallExpr
	KindStaticPropertyFetchExpr
	KindStaticStmt
	KindStaticVarStmt
	KindStmtList
	KindString
	KindSwitchStmt
	KindTernaryExpr
	KindThrowExpr
	KindThrowStmt
	KindTraitAdaptationListStmt
	KindTraitMethodRefStmt
	KindTraitStmt
	KindTraitUseAliasStmt
	KindTraitUsePrecedenceStmt
	KindTraitUseStmt
	KindTryStmt
	KindTypeCastExpr
	KindUnaryMinusExpr
	KindUnaryPlusExpr
	KindUnion
	KindUnsetCastExpr
	KindUnsetStmt
	KindUseListStmt
	KindUseStmt
	KindVar
	KindWhileStmt
	KindYieldExpr
	KindYieldFromExpr

	NumKinds
)

func GetNodeKind

func GetNodeKind(x Node) NodeKind

type NopStmt

type NopStmt struct {
	Position     *position.Position
	SemiColonTkn *token.Token
}

NopStmt is a `;` statement. It's also known as "empty statement".

func (*NopStmt) IterateTokens added in v0.4.0

func (n *NopStmt) IterateTokens(cb func(*token.Token) bool)

func (*NopStmt) Walk

func (n *NopStmt) Walk(v Visitor)

type NotEqualExpr

type NotEqualExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

NotEqualExpr is a `$Left != $Right` expression.

func (*NotEqualExpr) IterateTokens added in v0.4.0

func (n *NotEqualExpr) IterateTokens(cb func(*token.Token) bool)

func (*NotEqualExpr) Walk

func (n *NotEqualExpr) Walk(v Visitor)

type NotIdenticalExpr

type NotIdenticalExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

NotIdenticalExpr is a `$Left !== $Right` expression.

func (*NotIdenticalExpr) IterateTokens added in v0.4.0

func (n *NotIdenticalExpr) IterateTokens(cb func(*token.Token) bool)

func (*NotIdenticalExpr) Walk

func (n *NotIdenticalExpr) Walk(v Visitor)

type Nullable

type Nullable struct {
	Position    *position.Position
	QuestionTkn *token.Token
	Expr        Node
}

Nullable is a `?$Expr` expression.

func (*Nullable) IterateTokens added in v0.4.0

func (n *Nullable) IterateTokens(cb func(*token.Token) bool)

func (*Nullable) Walk

func (n *Nullable) Walk(v Visitor)

type NullsafeMethodCallExpr added in v0.4.0

type NullsafeMethodCallExpr struct {
	Position             *position.Position
	Variable             Node
	ObjectOperatorTkn    *token.Token
	OpenCurlyBracketTkn  *token.Token
	Method               Node
	CloseCurlyBracketTkn *token.Token
	OpenParenthesisTkn   *token.Token
	Args                 []Node
	SeparatorTkns        []*token.Token
	CloseParenthesisTkn  *token.Token
}

NullsafeMethodCallExpr node is a `$Var?->$Method($Args)`

func (*NullsafeMethodCallExpr) IterateTokens added in v0.4.0

func (n *NullsafeMethodCallExpr) IterateTokens(cb func(*token.Token) bool)

func (*NullsafeMethodCallExpr) Walk added in v0.4.0

func (n *NullsafeMethodCallExpr) Walk(v Visitor)

type NullsafePropertyFetchExpr added in v0.4.0

type NullsafePropertyFetchExpr struct {
	Position             *position.Position
	Variable             Node
	ObjectOperatorTkn    *token.Token
	OpenCurlyBracketTkn  *token.Token
	Property             Node
	CloseCurlyBracketTkn *token.Token
}

NullsafePropertyFetchExpr node is a `$Var?->Prop`

func (*NullsafePropertyFetchExpr) IterateTokens added in v0.4.0

func (n *NullsafePropertyFetchExpr) IterateTokens(cb func(*token.Token) bool)

func (*NullsafePropertyFetchExpr) Walk added in v0.4.0

type Parameter

type Parameter struct {
	Position     *position.Position
	AttrGroups   []*AttributeGroup
	Modifiers    []*Identifier
	VariableType Node
	AmpersandTkn *token.Token
	VariadicTkn  *token.Token
	Variable     *SimpleVar
	EqualTkn     *token.Token
	DefaultValue Node
	ByRef        bool
	Variadic     bool
}

Parameter is a function param declaration. Possible syntax's:

#[$AttrGroups] $Modifiers  $VariableType $Variable = $DefaultValue
#[$AttrGroups]             $VariableType $Variable = $DefaultValue
                           $VariableType $Variable = $DefaultValue
                           $VariableType $Variable
                                         $Variable

If $ByRef is true, it's `&$Variable`. If $Variadic is true, it's `...$Variable`.

func (*Parameter) IterateTokens added in v0.4.0

func (n *Parameter) IterateTokens(cb func(*token.Token) bool)

func (*Parameter) Walk

func (n *Parameter) Walk(v Visitor)

type ParenExpr

type ParenExpr struct {
	Position            *position.Position
	OpenParenthesisTkn  *token.Token
	Expr                Node
	CloseParenthesisTkn *token.Token
}

ParenExpr is a `($Expr)` expression.

func (*ParenExpr) IterateTokens added in v0.4.0

func (n *ParenExpr) IterateTokens(cb func(*token.Token) bool)

func (*ParenExpr) Walk

func (n *ParenExpr) Walk(v Visitor)

type PlusExpr

type PlusExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

PlusExpr is a `$Left + $Right` expression.

func (*PlusExpr) IterateTokens added in v0.4.0

func (n *PlusExpr) IterateTokens(cb func(*token.Token) bool)

func (*PlusExpr) Walk

func (n *PlusExpr) Walk(v Visitor)

type PostDecExpr

type PostDecExpr struct {
	Position *position.Position
	Variable Node
	DecTkn   *token.Token
}

PostDecExpr is a `$Variable--` expression.

func (*PostDecExpr) IterateTokens added in v0.4.0

func (n *PostDecExpr) IterateTokens(cb func(*token.Token) bool)

func (*PostDecExpr) Walk

func (n *PostDecExpr) Walk(v Visitor)

type PostIncExpr

type PostIncExpr struct {
	Position *position.Position
	Variable Node
	IncTkn   *token.Token
}

PostIncExpr is a `$Variable++` expression.

func (*PostIncExpr) IterateTokens added in v0.4.0

func (n *PostIncExpr) IterateTokens(cb func(*token.Token) bool)

func (*PostIncExpr) Walk

func (n *PostIncExpr) Walk(v Visitor)

type PowExpr

type PowExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

PowExpr is a `$Left ** $Right` expression.

func (*PowExpr) IterateTokens added in v0.4.0

func (n *PowExpr) IterateTokens(cb func(*token.Token) bool)

func (*PowExpr) Walk

func (n *PowExpr) Walk(v Visitor)

type PreDecExpr

type PreDecExpr struct {
	Position *position.Position
	DecTkn   *token.Token
	Variable Node
}

PreDecExpr is a `--$Variable` expression.

func (*PreDecExpr) IterateTokens added in v0.4.0

func (n *PreDecExpr) IterateTokens(cb func(*token.Token) bool)

func (*PreDecExpr) Walk

func (n *PreDecExpr) Walk(v Visitor)

type PreIncExpr

type PreIncExpr struct {
	Position *position.Position
	IncTkn   *token.Token
	Variable Node
}

PreIncExpr is a `++$Variable` expression.

func (*PreIncExpr) IterateTokens added in v0.4.0

func (n *PreIncExpr) IterateTokens(cb func(*token.Token) bool)

func (*PreIncExpr) Walk

func (n *PreIncExpr) Walk(v Visitor)

type PrintExpr

type PrintExpr struct {
	Position *position.Position
	PrintTkn *token.Token
	Expr     Node
}

PrintExpr is a `print $Expr` expression.

func (*PrintExpr) IterateTokens added in v0.4.0

func (n *PrintExpr) IterateTokens(cb func(*token.Token) bool)

func (*PrintExpr) Walk

func (n *PrintExpr) Walk(v Visitor)

type PropertyFetchExpr

type PropertyFetchExpr struct {
	Position             *position.Position
	Variable             Node
	ObjectOperatorTkn    *token.Token
	OpenCurlyBracketTkn  *token.Token
	Property             Node
	CloseCurlyBracketTkn *token.Token
}

PropertyFetchExpr is a `$Variable->$Property` expression.

func (*PropertyFetchExpr) IterateTokens added in v0.4.0

func (n *PropertyFetchExpr) IterateTokens(cb func(*token.Token) bool)

func (*PropertyFetchExpr) Walk

func (n *PropertyFetchExpr) Walk(v Visitor)

type PropertyListStmt

type PropertyListStmt struct {
	Position      *position.Position
	AttrGroups    []*AttributeGroup
	Modifiers     []*Identifier
	Type          Node
	Properties    []Node
	SeparatorTkns []*token.Token
	SemiColonTkn  *token.Token

	Doc phpdoc.Comment
}

PropertyListStmt is a `#[$AttrGroups] $Modifiers $Type $Properties` statement. Every element in $Properties is a *PropertyStmt.

func (*PropertyListStmt) IterateTokens added in v0.4.0

func (n *PropertyListStmt) IterateTokens(cb func(*token.Token) bool)

func (*PropertyListStmt) Walk

func (n *PropertyListStmt) Walk(v Visitor)

type PropertyStmt

type PropertyStmt struct {
	Position *position.Position
	Variable *SimpleVar
	EqualTkn *token.Token
	Expr     Node
}

PropertyStmt is a `$Variable = $Expr` statement. It's a part of the *PropertyListStmt.

func (*PropertyStmt) IterateTokens added in v0.4.0

func (n *PropertyStmt) IterateTokens(cb func(*token.Token) bool)

func (*PropertyStmt) Walk

func (n *PropertyStmt) Walk(v Visitor)

type ReferenceExpr

type ReferenceExpr struct {
	AmpersandTkn *token.Token
	Position     *position.Position
	Variable     Node
}

ReferenceExpr is a `&$Variable` expression.

func (*ReferenceExpr) IterateTokens added in v0.4.0

func (n *ReferenceExpr) IterateTokens(cb func(*token.Token) bool)

func (*ReferenceExpr) Walk

func (n *ReferenceExpr) Walk(v Visitor)

type ReturnStmt

type ReturnStmt struct {
	Position     *position.Position
	ReturnTkn    *token.Token
	Expr         Node
	SemiColonTkn *token.Token
}

ReturnStmt is a `return $Expr` statement.

func (*ReturnStmt) IterateTokens added in v0.4.0

func (n *ReturnStmt) IterateTokens(cb func(*token.Token) bool)

func (*ReturnStmt) Walk

func (n *ReturnStmt) Walk(v Visitor)

type Root

type Root struct {
	Position *position.Position
	Stmts    []Node
	EndTkn   *token.Token
}

Root is a node that wraps all file statements.

func (*Root) IterateTokens added in v0.4.0

func (n *Root) IterateTokens(cb func(*token.Token) bool)

func (*Root) Walk

func (n *Root) Walk(v Visitor)

type ShellExecExpr

type ShellExecExpr struct {
	Position         *position.Position
	OpenBacktickTkn  *token.Token
	Parts            []Node
	CloseBacktickTkn *token.Token
}

ShellExecExpr is a “-quoted string.

func (*ShellExecExpr) IterateTokens added in v0.4.0

func (n *ShellExecExpr) IterateTokens(cb func(*token.Token) bool)

func (*ShellExecExpr) Walk

func (n *ShellExecExpr) Walk(v Visitor)

type ShiftLeftExpr

type ShiftLeftExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

ShiftLeftExpr is a `$Left << $Right` expression.

func (*ShiftLeftExpr) IterateTokens added in v0.4.0

func (n *ShiftLeftExpr) IterateTokens(cb func(*token.Token) bool)

func (*ShiftLeftExpr) Walk

func (n *ShiftLeftExpr) Walk(v Visitor)

type ShiftRightExpr

type ShiftRightExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

ShiftRightExpr is a `$Left >> $Right` expression.

func (*ShiftRightExpr) IterateTokens added in v0.4.0

func (n *ShiftRightExpr) IterateTokens(cb func(*token.Token) bool)

func (*ShiftRightExpr) Walk

func (n *ShiftRightExpr) Walk(v Visitor)

type SimpleVar

type SimpleVar struct {
	Position      *position.Position
	DollarTkn     *token.Token
	IdentifierTkn *token.Token
	Name          string
}

SimpleVar is a normal PHP variable like `$foo` or `$bar`.

func (*SimpleVar) IterateTokens added in v0.4.0

func (n *SimpleVar) IterateTokens(cb func(*token.Token) bool)

func (*SimpleVar) Walk

func (n *SimpleVar) Walk(v Visitor)

type SmallerExpr

type SmallerExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

SmallerExpr is a `$Left < $Right` expression.

func (*SmallerExpr) IterateTokens added in v0.4.0

func (n *SmallerExpr) IterateTokens(cb func(*token.Token) bool)

func (*SmallerExpr) Walk

func (n *SmallerExpr) Walk(v Visitor)

type SmallerOrEqualExpr

type SmallerOrEqualExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

SmallerOrEqualExpr is a `$Left <= $Right` expression.

func (*SmallerOrEqualExpr) IterateTokens added in v0.4.0

func (n *SmallerOrEqualExpr) IterateTokens(cb func(*token.Token) bool)

func (*SmallerOrEqualExpr) Walk

func (n *SmallerOrEqualExpr) Walk(v Visitor)

type SpaceshipExpr

type SpaceshipExpr struct {
	Position *position.Position
	Left     Node
	OpTkn    *token.Token
	Right    Node
}

SpaceshipExpr is a `$Left <=> $Right` expression.

func (*SpaceshipExpr) IterateTokens added in v0.4.0

func (n *SpaceshipExpr) IterateTokens(cb func(*token.Token) bool)

func (*SpaceshipExpr) Walk

func (n *SpaceshipExpr) Walk(v Visitor)

type StaticCallExpr

type StaticCallExpr struct {
	Position             *position.Position
	Class                Node
	DoubleColonTkn       *token.Token
	OpenCurlyBracketTkn  *token.Token
	Call                 Node
	CloseCurlyBracketTkn *token.Token
	OpenParenthesisTkn   *token.Token
	Args                 []Node
	SeparatorTkns        []*token.Token
	CloseParenthesisTkn  *token.Token
}

StaticCallExpr is a `$Class::$Call($Args...)` expression.

func (*StaticCallExpr) Arg

func (n *StaticCallExpr) Arg(i int) *Argument

Arg returns the ith argument.

func (*StaticCallExpr) IterateTokens added in v0.4.0

func (n *StaticCallExpr) IterateTokens(cb func(*token.Token) bool)

func (*StaticCallExpr) Walk

func (n *StaticCallExpr) Walk(v Visitor)

type StaticPropertyFetchExpr

type StaticPropertyFetchExpr struct {
	Position       *position.Position
	Class          Node
	DoubleColonTkn *token.Token
	Property       Node
}

StaticPropertyFetchExpr is a `$Class::$Property` expression.

func (*StaticPropertyFetchExpr) IterateTokens added in v0.4.0

func (n *StaticPropertyFetchExpr) IterateTokens(cb func(*token.Token) bool)

func (*StaticPropertyFetchExpr) Walk

func (n *StaticPropertyFetchExpr) Walk(v Visitor)

type StaticStmt

type StaticStmt struct {
	Position      *position.Position
	StaticTkn     *token.Token
	Vars          []Node
	SeparatorTkns []*token.Token
	SemiColonTkn  *token.Token
}

StaticStmt is a `static $Vars...` statement. Every element in $Vars is a *StaticVarStmt.

func (*StaticStmt) IterateTokens added in v0.4.0

func (n *StaticStmt) IterateTokens(cb func(*token.Token) bool)

func (*StaticStmt) Walk

func (n *StaticStmt) Walk(v Visitor)

type StaticVarStmt

type StaticVarStmt struct {
	Position *position.Position
	Variable *SimpleVar
	EqualTkn *token.Token
	Expr     Node
}

StaticVarStmt is a `$Variable = $Expr`. It's a part of the *StaticStmt.

func (*StaticVarStmt) IterateTokens added in v0.4.0

func (n *StaticVarStmt) IterateTokens(cb func(*token.Token) bool)

func (*StaticVarStmt) Walk

func (n *StaticVarStmt) Walk(v Visitor)

type StmtList

type StmtList struct {
	Position             *position.Position
	OpenCurlyBracketTkn  *token.Token
	Stmts                []Node
	CloseCurlyBracketTkn *token.Token
}

StmtList is a `{ $Stmts... }` statement. It's also known as "block statement".

func (*StmtList) IterateTokens added in v0.4.0

func (n *StmtList) IterateTokens(cb func(*token.Token) bool)

func (*StmtList) Walk

func (n *StmtList) Walk(v Visitor)

type String

type String struct {
	Position     *position.Position
	MinusTkn     *token.Token
	StringTkn    *token.Token
	Value        string
	DoubleQuotes bool
}

String is a simple (no interpolation) string literal.

The $Value contains interpreted string bytes, if you need a raw string value, use positions and fetch relevant the source bytes.

$DoubleQuotes tell whether originally this string literal was ""-quoted.

func (*String) IterateTokens added in v0.4.0

func (n *String) IterateTokens(cb func(*token.Token) bool)

func (*String) Walk

func (n *String) Walk(v Visitor)

type SwitchStmt

type SwitchStmt struct {
	Position             *position.Position
	SwitchTkn            *token.Token
	OpenParenthesisTkn   *token.Token
	Cond                 Node
	CloseParenthesisTkn  *token.Token
	ColonTkn             *token.Token
	OpenCurlyBracketTkn  *token.Token
	CaseSeparatorTkn     *token.Token
	Cases                []Node
	CloseCurlyBracketTkn *token.Token
	EndSwitchTkn         *token.Token
	SemiColonTkn         *token.Token
	AltSyntax            bool
}

SwitchStmt is a `switch ($Cond) $CaseList` statement. If $AltSyntax is true, the block will begin with `:` and end with `endswitch`.

func (*SwitchStmt) IterateTokens added in v0.4.0

func (n *SwitchStmt) IterateTokens(cb func(*token.Token) bool)

func (*SwitchStmt) Walk

func (n *SwitchStmt) Walk(v Visitor)

type TernaryExpr

type TernaryExpr struct {
	Position    *position.Position
	Condition   Node
	QuestionTkn *token.Token
	IfTrue      Node
	ColonTkn    *token.Token
	IfFalse     Node
}

TernaryExpr is a `$Condition ? $IfTrue : $IfFalse` expression. If $IfTrue is nil, it's `$Condition ?: $IfFalse`.

func (*TernaryExpr) IterateTokens added in v0.4.0

func (n *TernaryExpr) IterateTokens(cb func(*token.Token) bool)

func (*TernaryExpr) Walk

func (n *TernaryExpr) Walk(v Visitor)

type ThrowExpr added in v0.4.0

type ThrowExpr struct {
	Position     *position.Position
	ThrowTkn     *token.Token
	Expr         Node
	SemiColonTkn *token.Token
}

ThrowExpr node is a `throw $Expr;`

func (*ThrowExpr) IterateTokens added in v0.4.0

func (n *ThrowExpr) IterateTokens(cb func(*token.Token) bool)

func (*ThrowExpr) Walk added in v0.4.0

func (n *ThrowExpr) Walk(v Visitor)

type ThrowStmt

type ThrowStmt struct {
	Position     *position.Position
	ThrowTkn     *token.Token
	Expr         Node
	SemiColonTkn *token.Token
}

ThrowStmt is a `throw $Expr` statement.

func (*ThrowStmt) IterateTokens added in v0.4.0

func (n *ThrowStmt) IterateTokens(cb func(*token.Token) bool)

func (*ThrowStmt) Walk

func (n *ThrowStmt) Walk(v Visitor)

type TraitAdaptationListStmt

type TraitAdaptationListStmt struct {
	Position    *position.Position
	Adaptations []Node
}

TraitAdaptationListStmt is a block inside a *TraitUseStmt.

func (*TraitAdaptationListStmt) IterateTokens added in v0.4.0

func (n *TraitAdaptationListStmt) IterateTokens(cb func(*token.Token) bool)

func (*TraitAdaptationListStmt) Walk

func (n *TraitAdaptationListStmt) Walk(v Visitor)

type TraitMethodRefStmt

type TraitMethodRefStmt struct {
	Position *position.Position
	Trait    Node
	Method   *Identifier
}

func (*TraitMethodRefStmt) IterateTokens added in v0.4.0

func (n *TraitMethodRefStmt) IterateTokens(cb func(*token.Token) bool)

func (*TraitMethodRefStmt) Walk

func (n *TraitMethodRefStmt) Walk(v Visitor)

type TraitStmt

type TraitStmt struct {
	Position             *position.Position
	AttrGroups           []*AttributeGroup
	TraitTkn             *token.Token
	TraitName            *Identifier
	OpenCurlyBracketTkn  *token.Token
	Stmts                []Node
	CloseCurlyBracketTkn *token.Token

	Doc phpdoc.Comment
}

TraitStmt is a trait declaration.

func (*TraitStmt) IterateTokens added in v0.4.0

func (n *TraitStmt) IterateTokens(cb func(*token.Token) bool)

func (*TraitStmt) Walk

func (n *TraitStmt) Walk(v Visitor)

type TraitUseAliasStmt

type TraitUseAliasStmt struct {
	Position       *position.Position
	DoubleColonTkn *token.Token
	Ref            Node
	AsTkn          *token.Token
	Modifier       Node
	Alias          *Identifier
	SemiColonTkn   *token.Token
}

func (*TraitUseAliasStmt) IterateTokens added in v0.4.0

func (n *TraitUseAliasStmt) IterateTokens(cb func(*token.Token) bool)

func (*TraitUseAliasStmt) Walk

func (n *TraitUseAliasStmt) Walk(v Visitor)

type TraitUsePrecedenceStmt

type TraitUsePrecedenceStmt struct {
	Position       *position.Position
	DoubleColonTkn *token.Token
	Ref            Node
	InsteadofTkn   *token.Token
	Insteadof      []Node
	SeparatorTkns  []*token.Token
	SemiColonTkn   *token.Token
}

func (*TraitUsePrecedenceStmt) IterateTokens added in v0.4.0

func (n *TraitUsePrecedenceStmt) IterateTokens(cb func(*token.Token) bool)

func (*TraitUsePrecedenceStmt) Walk

func (n *TraitUsePrecedenceStmt) Walk(v Visitor)

type TraitUseStmt

type TraitUseStmt struct {
	Position             *position.Position
	UseTkn               *token.Token
	Traits               []Node
	SeparatorTkns        []*token.Token
	OpenCurlyBracketTkn  *token.Token
	TraitAdaptationList  Node
	CloseCurlyBracketTkn *token.Token
	SemiColonTkn         *token.Token
}

func (*TraitUseStmt) IterateTokens added in v0.4.0

func (n *TraitUseStmt) IterateTokens(cb func(*token.Token) bool)

func (*TraitUseStmt) Walk

func (n *TraitUseStmt) Walk(v Visitor)

type TryStmt

type TryStmt struct {
	Position             *position.Position
	TryTkn               *token.Token
	OpenCurlyBracketTkn  *token.Token
	Stmts                []Node
	CloseCurlyBracketTkn *token.Token
	Catches              []Node
	Finally              Node
}

TryStmt is a `try { $Stmts... } $Catches` statement. $Finally only presents if `finally {...}` block exists.

func (*TryStmt) IterateTokens added in v0.4.0

func (n *TryStmt) IterateTokens(cb func(*token.Token) bool)

func (*TryStmt) Walk

func (n *TryStmt) Walk(v Visitor)

type TypeCastExpr

type TypeCastExpr struct {
	Position *position.Position
	CastTkn  *token.Token
	Type     string // "array" "bool" "int" "float" "object" "string"
	Expr     Node
}

TypeCastExpr is a `($Type)$Expr` expression.

func (*TypeCastExpr) IterateTokens added in v0.4.0

func (n *TypeCastExpr) IterateTokens(cb func(*token.Token) bool)

func (*TypeCastExpr) Walk

func (n *TypeCastExpr) Walk(v Visitor)

type UnaryMinusExpr

type UnaryMinusExpr struct {
	Position *position.Position
	MinusTkn *token.Token
	Expr     Node
}

UnaryMinusExpr is a `-$Expr` expression.

func (*UnaryMinusExpr) IterateTokens added in v0.4.0

func (n *UnaryMinusExpr) IterateTokens(cb func(*token.Token) bool)

func (*UnaryMinusExpr) Walk

func (n *UnaryMinusExpr) Walk(v Visitor)

type UnaryPlusExpr

type UnaryPlusExpr struct {
	Position *position.Position
	PlusTkn  *token.Token
	Expr     Node
}

UnaryPlusExpr is a `+$Expr` expression.

func (*UnaryPlusExpr) IterateTokens added in v0.4.0

func (n *UnaryPlusExpr) IterateTokens(cb func(*token.Token) bool)

func (*UnaryPlusExpr) Walk

func (n *UnaryPlusExpr) Walk(v Visitor)

type Union added in v0.4.0

type Union struct {
	Position      *position.Position
	Types         []Node
	SeparatorTkns []*token.Token
}

Union node is a `Type|Type1|...`

func (*Union) IterateTokens added in v0.4.0

func (n *Union) IterateTokens(cb func(*token.Token) bool)

func (*Union) Walk added in v0.4.0

func (n *Union) Walk(v Visitor)

type UnsetCastExpr

type UnsetCastExpr struct {
	Position *position.Position
	CastTkn  *token.Token
	Expr     Node
}

UnsetCastExpr is a `(unset)$Expr` expression.

func (*UnsetCastExpr) IterateTokens added in v0.4.0

func (n *UnsetCastExpr) IterateTokens(cb func(*token.Token) bool)

func (*UnsetCastExpr) Walk

func (n *UnsetCastExpr) Walk(v Visitor)

type UnsetStmt

type UnsetStmt struct {
	Position            *position.Position
	UnsetTkn            *token.Token
	OpenParenthesisTkn  *token.Token
	Vars                []Node
	SeparatorTkns       []*token.Token
	CloseParenthesisTkn *token.Token
	SemiColonTkn        *token.Token
}

UnsetStmt is a `unset($Vars...)` statement.

func (*UnsetStmt) IterateTokens added in v0.4.0

func (n *UnsetStmt) IterateTokens(cb func(*token.Token) bool)

func (*UnsetStmt) Walk

func (n *UnsetStmt) Walk(v Visitor)

type UseListStmt

type UseListStmt struct {
	Position      *position.Position
	UseTkn        *token.Token
	UseType       *Identifier
	Uses          []Node
	SeparatorTkns []*token.Token
	SemiColonTkn  *token.Token
}

func (*UseListStmt) IterateTokens added in v0.4.0

func (n *UseListStmt) IterateTokens(cb func(*token.Token) bool)

func (*UseListStmt) Walk

func (n *UseListStmt) Walk(v Visitor)

type UseStmt

type UseStmt struct {
	Position       *position.Position
	UseType        *Identifier
	NsSeparatorTkn *token.Token
	Use            *Name
	AsTkn          *token.Token
	Alias          *Identifier
}

func (*UseStmt) IterateTokens added in v0.4.0

func (n *UseStmt) IterateTokens(cb func(*token.Token) bool)

func (*UseStmt) Walk

func (n *UseStmt) Walk(v Visitor)

type Var

type Var struct {
	Position             *position.Position
	DollarTkn            *token.Token
	OpenCurlyBracketTkn  *token.Token
	Expr                 Node
	CloseCurlyBracketTkn *token.Token
}

Var is variable variable expression like `$$foo` or `${"foo"}`.

func (*Var) IterateTokens added in v0.4.0

func (n *Var) IterateTokens(cb func(*token.Token) bool)

func (*Var) Walk

func (n *Var) Walk(v Visitor)

type Visitor

type Visitor interface {
	EnterNode(Node) bool
	LeaveNode(Node)
}

Visitor is an interface for basic IR nodes traversal.

type WhileStmt

type WhileStmt struct {
	Position            *position.Position
	WhileTkn            *token.Token
	OpenParenthesisTkn  *token.Token
	Cond                Node
	CloseParenthesisTkn *token.Token
	ColonTkn            *token.Token
	Stmt                Node
	EndWhileTkn         *token.Token
	SemiColonTkn        *token.Token
	AltSyntax           bool
}

WhileStmt is a `while ($Cond) $Stmt` statement. If $AltSyntax is true, the block will begin with `:` and end with `endwhile`.

func (*WhileStmt) IterateTokens added in v0.4.0

func (n *WhileStmt) IterateTokens(cb func(*token.Token) bool)

func (*WhileStmt) Walk

func (n *WhileStmt) Walk(v Visitor)

type YieldExpr

type YieldExpr struct {
	Position       *position.Position
	YieldTkn       *token.Token
	Key            Node
	DoubleArrowTkn *token.Token
	Value          Node
}

YieldExpr is a `yield $Key => $Value` expression. If $Key is nil, it's `yield $Value`.

func (*YieldExpr) IterateTokens added in v0.4.0

func (n *YieldExpr) IterateTokens(cb func(*token.Token) bool)

func (*YieldExpr) Walk

func (n *YieldExpr) Walk(v Visitor)

type YieldFromExpr

type YieldFromExpr struct {
	Position     *position.Position
	YieldFromTkn *token.Token
	Expr         Node
}

YieldFromExpr is a `yield from $Expr` expression.

func (*YieldFromExpr) IterateTokens added in v0.4.0

func (n *YieldFromExpr) IterateTokens(cb func(*token.Token) bool)

func (*YieldFromExpr) Walk

func (n *YieldFromExpr) Walk(v Visitor)

Directories

Path Synopsis
Code generated by the `ir/codegen` package.
Code generated by the `ir/codegen` package.

Jump to

Keyboard shortcuts

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