rename meta to freefloating; refactoring

This commit is contained in:
z7zmey
2019-02-13 22:18:07 +02:00
parent a7082117d9
commit b3800a2595
309 changed files with 9671 additions and 10115 deletions

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// AltElse node
type AltElse struct {
Meta meta.Collection
Position *position.Position
Stmt node.Node
FreeFloating freefloating.Collection
Position *position.Position
Stmt node.Node
}
// NewAltElse node constructor
func NewAltElse(Stmt node.Node) *AltElse {
return &AltElse{
Stmt: Stmt,
FreeFloating: nil,
Stmt: Stmt,
}
}
@@ -31,8 +32,8 @@ func (n *AltElse) GetPosition() *position.Position {
return n.Position
}
func (n *AltElse) GetMeta() *meta.Collection {
return &n.Meta
func (n *AltElse) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// AltElseIf node
type AltElseIf struct {
Meta meta.Collection
Position *position.Position
Cond node.Node
Stmt node.Node
FreeFloating freefloating.Collection
Position *position.Position
Cond node.Node
Stmt node.Node
}
// NewAltElseIf node constructor
func NewAltElseIf(Cond node.Node, Stmt node.Node) *AltElseIf {
return &AltElseIf{
Cond: Cond,
Stmt: Stmt,
FreeFloating: nil,
Cond: Cond,
Stmt: Stmt,
}
}
@@ -33,8 +34,8 @@ func (n *AltElseIf) GetPosition() *position.Position {
return n.Position
}
func (n *AltElseIf) GetMeta() *meta.Collection {
return &n.Meta
func (n *AltElseIf) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,21 +9,22 @@ import (
// AltFor node
type AltFor struct {
Meta meta.Collection
Position *position.Position
Init []node.Node
Cond []node.Node
Loop []node.Node
Stmt node.Node
FreeFloating freefloating.Collection
Position *position.Position
Init []node.Node
Cond []node.Node
Loop []node.Node
Stmt node.Node
}
// NewAltFor node constructor
func NewAltFor(Init []node.Node, Cond []node.Node, Loop []node.Node, Stmt node.Node) *AltFor {
return &AltFor{
Init: Init,
Cond: Cond,
Loop: Loop,
Stmt: Stmt,
FreeFloating: nil,
Init: Init,
Cond: Cond,
Loop: Loop,
Stmt: Stmt,
}
}
@@ -37,8 +38,8 @@ func (n *AltFor) GetPosition() *position.Position {
return n.Position
}
func (n *AltFor) GetMeta() *meta.Collection {
return &n.Meta
func (n *AltFor) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,21 +9,22 @@ import (
// AltForeach node
type AltForeach struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
Key node.Node
Variable node.Node
Stmt node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
Key node.Node
Variable node.Node
Stmt node.Node
}
// NewAltForeach node constructor
func NewAltForeach(Expr node.Node, Key node.Node, Variable node.Node, Stmt node.Node) *AltForeach {
return &AltForeach{
Expr: Expr,
Key: Key,
Variable: Variable,
Stmt: Stmt,
FreeFloating: nil,
Expr: Expr,
Key: Key,
Variable: Variable,
Stmt: Stmt,
}
}
@@ -37,8 +38,8 @@ func (n *AltForeach) GetPosition() *position.Position {
return n.Position
}
func (n *AltForeach) GetMeta() *meta.Collection {
return &n.Meta
func (n *AltForeach) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,21 +9,22 @@ import (
// AltIf node
type AltIf struct {
Meta meta.Collection
Position *position.Position
Cond node.Node
Stmt node.Node
ElseIf []node.Node
Else node.Node
FreeFloating freefloating.Collection
Position *position.Position
Cond node.Node
Stmt node.Node
ElseIf []node.Node
Else node.Node
}
// NewAltIf node constructor
func NewAltIf(Cond node.Node, Stmt node.Node, ElseIf []node.Node, Else node.Node) *AltIf {
return &AltIf{
Cond: Cond,
Stmt: Stmt,
ElseIf: ElseIf,
Else: Else,
FreeFloating: nil,
Cond: Cond,
Stmt: Stmt,
ElseIf: ElseIf,
Else: Else,
}
}
@@ -37,8 +38,8 @@ func (n *AltIf) GetPosition() *position.Position {
return n.Position
}
func (n *AltIf) GetMeta() *meta.Collection {
return &n.Meta
func (n *AltIf) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// AltSwitch node
type AltSwitch struct {
Meta meta.Collection
Position *position.Position
Cond node.Node
CaseList *CaseList
FreeFloating freefloating.Collection
Position *position.Position
Cond node.Node
CaseList *CaseList
}
// NewAltSwitch node constructor
func NewAltSwitch(Cond node.Node, CaseList *CaseList) *AltSwitch {
return &AltSwitch{
Cond: Cond,
CaseList: CaseList,
FreeFloating: nil,
Cond: Cond,
CaseList: CaseList,
}
}
@@ -33,8 +34,8 @@ func (n *AltSwitch) GetPosition() *position.Position {
return n.Position
}
func (n *AltSwitch) GetMeta() *meta.Collection {
return &n.Meta
func (n *AltSwitch) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// AltWhile node
type AltWhile struct {
Meta meta.Collection
Position *position.Position
Cond node.Node
Stmt node.Node
FreeFloating freefloating.Collection
Position *position.Position
Cond node.Node
Stmt node.Node
}
// NewAltWhile node constructor
func NewAltWhile(Cond node.Node, Stmt node.Node) *AltWhile {
return &AltWhile{
Cond: Cond,
Stmt: Stmt,
FreeFloating: nil,
Cond: Cond,
Stmt: Stmt,
}
}
@@ -33,8 +34,8 @@ func (n *AltWhile) GetPosition() *position.Position {
return n.Position
}
func (n *AltWhile) GetMeta() *meta.Collection {
return &n.Meta
func (n *AltWhile) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Break node
type Break struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewBreak node constructor
func NewBreak(Expr node.Node) *Break {
return &Break{
Expr: Expr,
FreeFloating: nil,
Expr: Expr,
}
}
@@ -31,8 +32,8 @@ func (n *Break) GetPosition() *position.Position {
return n.Position
}
func (n *Break) GetMeta() *meta.Collection {
return &n.Meta
func (n *Break) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Case node
type Case struct {
Meta meta.Collection
Position *position.Position
Cond node.Node
Stmts []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Cond node.Node
Stmts []node.Node
}
// NewCase node constructor
func NewCase(Cond node.Node, Stmts []node.Node) *Case {
return &Case{
Cond: Cond,
Stmts: Stmts,
FreeFloating: nil,
Cond: Cond,
Stmts: Stmts,
}
}
@@ -33,8 +34,8 @@ func (n *Case) GetPosition() *position.Position {
return n.Position
}
func (n *Case) GetMeta() *meta.Collection {
return &n.Meta
func (n *Case) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// CaseList node
type CaseList struct {
Meta meta.Collection
Position *position.Position
Cases []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Cases []node.Node
}
// NewCaseList node constructor
func NewCaseList(Cases []node.Node) *CaseList {
return &CaseList{
Cases: Cases,
FreeFloating: nil,
Cases: Cases,
}
}
@@ -31,8 +32,8 @@ func (n *CaseList) GetPosition() *position.Position {
return n.Position
}
func (n *CaseList) GetMeta() *meta.Collection {
return &n.Meta
func (n *CaseList) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,19 +9,20 @@ import (
// Catch node
type Catch struct {
Meta meta.Collection
Position *position.Position
Types []node.Node
Variable node.Node
Stmts []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Types []node.Node
Variable node.Node
Stmts []node.Node
}
// NewCatch node constructor
func NewCatch(Types []node.Node, Variable node.Node, Stmts []node.Node) *Catch {
return &Catch{
Types: Types,
Variable: Variable,
Stmts: Stmts,
FreeFloating: nil,
Types: Types,
Variable: Variable,
Stmts: Stmts,
}
}
@@ -35,8 +36,8 @@ func (n *Catch) GetPosition() *position.Position {
return n.Position
}
func (n *Catch) GetMeta() *meta.Collection {
return &n.Meta
func (n *Catch) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,7 +9,7 @@ import (
// Class node
type Class struct {
Meta meta.Collection
FreeFloating freefloating.Collection
Position *position.Position
PhpDocComment string
ClassName node.Node
@@ -23,6 +23,7 @@ type Class struct {
// NewClass node constructor
func NewClass(ClassName node.Node, Modifiers []node.Node, ArgumentList *node.ArgumentList, Extends *ClassExtends, Implements *ClassImplements, Stmts []node.Node, PhpDocComment string) *Class {
return &Class{
FreeFloating: nil,
PhpDocComment: PhpDocComment,
ClassName: ClassName,
Modifiers: Modifiers,
@@ -43,8 +44,8 @@ func (n *Class) GetPosition() *position.Position {
return n.Position
}
func (n *Class) GetMeta() *meta.Collection {
return &n.Meta
func (n *Class) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// ClassConstList node
type ClassConstList struct {
Meta meta.Collection
Position *position.Position
Modifiers []node.Node
Consts []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Modifiers []node.Node
Consts []node.Node
}
// NewClassConstList node constructor
func NewClassConstList(Modifiers []node.Node, Consts []node.Node) *ClassConstList {
return &ClassConstList{
Modifiers: Modifiers,
Consts: Consts,
FreeFloating: nil,
Modifiers: Modifiers,
Consts: Consts,
}
}
@@ -33,8 +34,8 @@ func (n *ClassConstList) GetPosition() *position.Position {
return n.Position
}
func (n *ClassConstList) GetMeta() *meta.Collection {
return &n.Meta
func (n *ClassConstList) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// ClassExtends node
type ClassExtends struct {
Meta meta.Collection
Position *position.Position
ClassName node.Node
FreeFloating freefloating.Collection
Position *position.Position
ClassName node.Node
}
// NewClassExtends node constructor
func NewClassExtends(className node.Node) *ClassExtends {
return &ClassExtends{
ClassName: className,
FreeFloating: nil,
ClassName: className,
}
}
@@ -31,8 +32,8 @@ func (n *ClassExtends) GetPosition() *position.Position {
return n.Position
}
func (n *ClassExtends) GetMeta() *meta.Collection {
return &n.Meta
func (n *ClassExtends) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,7 +9,7 @@ import (
// ClassImplements node
type ClassImplements struct {
Meta meta.Collection
FreeFloating freefloating.Collection
Position *position.Position
InterfaceNames []node.Node
}
@@ -17,6 +17,7 @@ type ClassImplements struct {
// NewClassImplements node constructor
func NewClassImplements(interfaceNames []node.Node) *ClassImplements {
return &ClassImplements{
FreeFloating: nil,
InterfaceNames: interfaceNames,
}
}
@@ -31,8 +32,8 @@ func (n *ClassImplements) GetPosition() *position.Position {
return n.Position
}
func (n *ClassImplements) GetMeta() *meta.Collection {
return &n.Meta
func (n *ClassImplements) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,7 +9,7 @@ import (
// ClassMethod node
type ClassMethod struct {
Meta meta.Collection
FreeFloating freefloating.Collection
Position *position.Position
ReturnsRef bool
PhpDocComment string
@@ -23,6 +23,7 @@ type ClassMethod struct {
// NewClassMethod node constructor
func NewClassMethod(MethodName node.Node, Modifiers []node.Node, ReturnsRef bool, Params []node.Node, ReturnType node.Node, Stmt node.Node, PhpDocComment string) *ClassMethod {
return &ClassMethod{
FreeFloating: nil,
ReturnsRef: ReturnsRef,
PhpDocComment: PhpDocComment,
MethodName: MethodName,
@@ -43,8 +44,8 @@ func (n *ClassMethod) GetPosition() *position.Position {
return n.Position
}
func (n *ClassMethod) GetMeta() *meta.Collection {
return &n.Meta
func (n *ClassMethod) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// ConstList node
type ConstList struct {
Meta meta.Collection
Position *position.Position
Consts []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Consts []node.Node
}
// NewConstList node constructor
func NewConstList(Consts []node.Node) *ConstList {
return &ConstList{
Consts: Consts,
FreeFloating: nil,
Consts: Consts,
}
}
@@ -31,8 +32,8 @@ func (n *ConstList) GetPosition() *position.Position {
return n.Position
}
func (n *ConstList) GetMeta() *meta.Collection {
return &n.Meta
func (n *ConstList) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,7 +9,7 @@ import (
// Constant node
type Constant struct {
Meta meta.Collection
FreeFloating freefloating.Collection
Position *position.Position
PhpDocComment string
ConstantName node.Node
@@ -19,6 +19,7 @@ type Constant struct {
// NewConstant node constructor
func NewConstant(ConstantName node.Node, Expr node.Node, PhpDocComment string) *Constant {
return &Constant{
FreeFloating: nil,
PhpDocComment: PhpDocComment,
ConstantName: ConstantName,
Expr: Expr,
@@ -35,8 +36,8 @@ func (n *Constant) GetPosition() *position.Position {
return n.Position
}
func (n *Constant) GetMeta() *meta.Collection {
return &n.Meta
func (n *Constant) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Continue node
type Continue struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewContinue node constructor
func NewContinue(Expr node.Node) *Continue {
return &Continue{
Expr: Expr,
FreeFloating: nil,
Expr: Expr,
}
}
@@ -31,8 +32,8 @@ func (n *Continue) GetPosition() *position.Position {
return n.Position
}
func (n *Continue) GetMeta() *meta.Collection {
return &n.Meta
func (n *Continue) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,19 +9,20 @@ import (
// Declare node
type Declare struct {
Meta meta.Collection
Position *position.Position
Consts []node.Node
Stmt node.Node
Alt bool
FreeFloating freefloating.Collection
Position *position.Position
Consts []node.Node
Stmt node.Node
Alt bool
}
// NewDeclare node constructor
func NewDeclare(Consts []node.Node, Stmt node.Node, alt bool) *Declare {
return &Declare{
Consts: Consts,
Stmt: Stmt,
Alt: alt,
FreeFloating: nil,
Consts: Consts,
Stmt: Stmt,
Alt: alt,
}
}
@@ -35,8 +36,8 @@ func (n *Declare) GetPosition() *position.Position {
return n.Position
}
func (n *Declare) GetMeta() *meta.Collection {
return &n.Meta
func (n *Declare) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Default node
type Default struct {
Meta meta.Collection
Position *position.Position
Stmts []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Stmts []node.Node
}
// NewDefault node constructor
func NewDefault(Stmts []node.Node) *Default {
return &Default{
Stmts: Stmts,
FreeFloating: nil,
Stmts: Stmts,
}
}
@@ -31,8 +32,8 @@ func (n *Default) GetPosition() *position.Position {
return n.Position
}
func (n *Default) GetMeta() *meta.Collection {
return &n.Meta
func (n *Default) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Do node
type Do struct {
Meta meta.Collection
Position *position.Position
Stmt node.Node
Cond node.Node
FreeFloating freefloating.Collection
Position *position.Position
Stmt node.Node
Cond node.Node
}
// NewDo node constructor
func NewDo(Stmt node.Node, Cond node.Node) *Do {
return &Do{
Stmt: Stmt,
Cond: Cond,
FreeFloating: nil,
Stmt: Stmt,
Cond: Cond,
}
}
@@ -33,8 +34,8 @@ func (n *Do) GetPosition() *position.Position {
return n.Position
}
func (n *Do) GetMeta() *meta.Collection {
return &n.Meta
func (n *Do) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Echo node
type Echo struct {
Meta meta.Collection
Position *position.Position
Exprs []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Exprs []node.Node
}
// NewEcho node constructor
func NewEcho(Exprs []node.Node) *Echo {
return &Echo{
Exprs: Exprs,
FreeFloating: nil,
Exprs: Exprs,
}
}
@@ -31,8 +32,8 @@ func (n *Echo) GetPosition() *position.Position {
return n.Position
}
func (n *Echo) GetMeta() *meta.Collection {
return &n.Meta
func (n *Echo) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Else node
type Else struct {
Meta meta.Collection
Position *position.Position
Stmt node.Node
FreeFloating freefloating.Collection
Position *position.Position
Stmt node.Node
}
// NewElse node constructor
func NewElse(Stmt node.Node) *Else {
return &Else{
Stmt: Stmt,
FreeFloating: nil,
Stmt: Stmt,
}
}
@@ -31,8 +32,8 @@ func (n *Else) GetPosition() *position.Position {
return n.Position
}
func (n *Else) GetMeta() *meta.Collection {
return &n.Meta
func (n *Else) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// ElseIf node
type ElseIf struct {
Meta meta.Collection
Position *position.Position
Cond node.Node
Stmt node.Node
FreeFloating freefloating.Collection
Position *position.Position
Cond node.Node
Stmt node.Node
}
// NewElseIf node constructor
func NewElseIf(Cond node.Node, Stmt node.Node) *ElseIf {
return &ElseIf{
Cond: Cond,
Stmt: Stmt,
FreeFloating: nil,
Cond: Cond,
Stmt: Stmt,
}
}
@@ -33,8 +34,8 @@ func (n *ElseIf) GetPosition() *position.Position {
return n.Position
}
func (n *ElseIf) GetMeta() *meta.Collection {
return &n.Meta
func (n *ElseIf) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Expression node
type Expression struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewExpression node constructor
func NewExpression(Expr node.Node) *Expression {
return &Expression{
Expr: Expr,
FreeFloating: nil,
Expr: Expr,
}
}
@@ -31,8 +32,8 @@ func (n *Expression) GetPosition() *position.Position {
return n.Position
}
func (n *Expression) GetMeta() *meta.Collection {
return &n.Meta
func (n *Expression) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Finally node
type Finally struct {
Meta meta.Collection
Position *position.Position
Stmts []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Stmts []node.Node
}
// NewFinally node constructor
func NewFinally(Stmts []node.Node) *Finally {
return &Finally{
Stmts: Stmts,
FreeFloating: nil,
Stmts: Stmts,
}
}
@@ -31,8 +32,8 @@ func (n *Finally) GetPosition() *position.Position {
return n.Position
}
func (n *Finally) GetMeta() *meta.Collection {
return &n.Meta
func (n *Finally) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,21 +9,22 @@ import (
// For node
type For struct {
Meta meta.Collection
Position *position.Position
Init []node.Node
Cond []node.Node
Loop []node.Node
Stmt node.Node
FreeFloating freefloating.Collection
Position *position.Position
Init []node.Node
Cond []node.Node
Loop []node.Node
Stmt node.Node
}
// NewFor node constructor
func NewFor(Init []node.Node, Cond []node.Node, Loop []node.Node, Stmt node.Node) *For {
return &For{
Init: Init,
Cond: Cond,
Loop: Loop,
Stmt: Stmt,
FreeFloating: nil,
Init: Init,
Cond: Cond,
Loop: Loop,
Stmt: Stmt,
}
}
@@ -37,8 +38,8 @@ func (n *For) GetPosition() *position.Position {
return n.Position
}
func (n *For) GetMeta() *meta.Collection {
return &n.Meta
func (n *For) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,21 +9,22 @@ import (
// Foreach node
type Foreach struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
Key node.Node
Variable node.Node
Stmt node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
Key node.Node
Variable node.Node
Stmt node.Node
}
// NewForeach node constructor
func NewForeach(Expr node.Node, Key node.Node, Variable node.Node, Stmt node.Node) *Foreach {
return &Foreach{
Expr: Expr,
Key: Key,
Variable: Variable,
Stmt: Stmt,
FreeFloating: nil,
Expr: Expr,
Key: Key,
Variable: Variable,
Stmt: Stmt,
}
}
@@ -37,8 +38,8 @@ func (n *Foreach) GetPosition() *position.Position {
return n.Position
}
func (n *Foreach) GetMeta() *meta.Collection {
return &n.Meta
func (n *Foreach) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,7 +9,7 @@ import (
// Function node
type Function struct {
Meta meta.Collection
FreeFloating freefloating.Collection
Position *position.Position
ReturnsRef bool
PhpDocComment string
@@ -22,6 +22,7 @@ type Function struct {
// NewFunction node constructor
func NewFunction(FunctionName node.Node, ReturnsRef bool, Params []node.Node, ReturnType node.Node, Stmts []node.Node, PhpDocComment string) *Function {
return &Function{
FreeFloating: nil,
ReturnsRef: ReturnsRef,
PhpDocComment: PhpDocComment,
FunctionName: FunctionName,
@@ -41,8 +42,8 @@ func (n *Function) GetPosition() *position.Position {
return n.Position
}
func (n *Function) GetMeta() *meta.Collection {
return &n.Meta
func (n *Function) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Global node
type Global struct {
Meta meta.Collection
Position *position.Position
Vars []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Vars []node.Node
}
// NewGlobal node constructor
func NewGlobal(Vars []node.Node) *Global {
return &Global{
Vars: Vars,
FreeFloating: nil,
Vars: Vars,
}
}
@@ -31,8 +32,8 @@ func (n *Global) GetPosition() *position.Position {
return n.Position
}
func (n *Global) GetMeta() *meta.Collection {
return &n.Meta
func (n *Global) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Goto node
type Goto struct {
Meta meta.Collection
Position *position.Position
Label node.Node
FreeFloating freefloating.Collection
Position *position.Position
Label node.Node
}
// NewGoto node constructor
func NewGoto(Label node.Node) *Goto {
return &Goto{
Label: Label,
FreeFloating: nil,
Label: Label,
}
}
@@ -31,8 +32,8 @@ func (n *Goto) GetPosition() *position.Position {
return n.Position
}
func (n *Goto) GetMeta() *meta.Collection {
return &n.Meta
func (n *Goto) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,19 +9,20 @@ import (
// GroupUse node
type GroupUse struct {
Meta meta.Collection
Position *position.Position
UseType node.Node
Prefix node.Node
UseList []node.Node
FreeFloating freefloating.Collection
Position *position.Position
UseType node.Node
Prefix node.Node
UseList []node.Node
}
// NewGroupUse node constructor
func NewGroupUse(UseType node.Node, Prefix node.Node, UseList []node.Node) *GroupUse {
return &GroupUse{
UseType: UseType,
Prefix: Prefix,
UseList: UseList,
FreeFloating: nil,
UseType: UseType,
Prefix: Prefix,
UseList: UseList,
}
}
@@ -35,8 +36,8 @@ func (n *GroupUse) GetPosition() *position.Position {
return n.Position
}
func (n *GroupUse) GetMeta() *meta.Collection {
return &n.Meta
func (n *GroupUse) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,15 +1,15 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
)
// HaltCompiler node
type HaltCompiler struct {
Meta meta.Collection
Position *position.Position
FreeFloating freefloating.Collection
Position *position.Position
}
// NewHaltCompiler node constructor
@@ -27,8 +27,8 @@ func (n *HaltCompiler) GetPosition() *position.Position {
return n.Position
}
func (n *HaltCompiler) GetMeta() *meta.Collection {
return &n.Meta
func (n *HaltCompiler) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,21 +9,22 @@ import (
// If node
type If struct {
Meta meta.Collection
Position *position.Position
Cond node.Node
Stmt node.Node
ElseIf []node.Node
Else node.Node
FreeFloating freefloating.Collection
Position *position.Position
Cond node.Node
Stmt node.Node
ElseIf []node.Node
Else node.Node
}
// NewIf node constructor
func NewIf(Cond node.Node, Stmt node.Node, ElseIf []node.Node, Else node.Node) *If {
return &If{
Cond: Cond,
Stmt: Stmt,
ElseIf: ElseIf,
Else: Else,
FreeFloating: nil,
Cond: Cond,
Stmt: Stmt,
ElseIf: ElseIf,
Else: Else,
}
}
@@ -37,8 +38,8 @@ func (n *If) GetPosition() *position.Position {
return n.Position
}
func (n *If) GetMeta() *meta.Collection {
return &n.Meta
func (n *If) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,22 +1,23 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
)
// InlineHtml node
type InlineHtml struct {
Meta meta.Collection
Position *position.Position
Value string
FreeFloating freefloating.Collection
Position *position.Position
Value string
}
// NewInlineHtml node constructor
func NewInlineHtml(Value string) *InlineHtml {
return &InlineHtml{
Value: Value,
FreeFloating: nil,
Value: Value,
}
}
@@ -30,8 +31,8 @@ func (n *InlineHtml) GetPosition() *position.Position {
return n.Position
}
func (n *InlineHtml) GetMeta() *meta.Collection {
return &n.Meta
func (n *InlineHtml) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,7 +9,7 @@ import (
// Interface node
type Interface struct {
Meta meta.Collection
FreeFloating freefloating.Collection
Position *position.Position
PhpDocComment string
InterfaceName node.Node
@@ -20,6 +20,7 @@ type Interface struct {
// NewInterface node constructor
func NewInterface(InterfaceName node.Node, Extends *InterfaceExtends, Stmts []node.Node, PhpDocComment string) *Interface {
return &Interface{
FreeFloating: nil,
PhpDocComment: PhpDocComment,
InterfaceName: InterfaceName,
Extends: Extends,
@@ -37,8 +38,8 @@ func (n *Interface) GetPosition() *position.Position {
return n.Position
}
func (n *Interface) GetMeta() *meta.Collection {
return &n.Meta
func (n *Interface) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,7 +9,7 @@ import (
// InterfaceExtends node
type InterfaceExtends struct {
Meta meta.Collection
FreeFloating freefloating.Collection
Position *position.Position
InterfaceNames []node.Node
}
@@ -17,6 +17,7 @@ type InterfaceExtends struct {
// NewInterfaceExtends node constructor
func NewInterfaceExtends(InterfaceNames []node.Node) *InterfaceExtends {
return &InterfaceExtends{
FreeFloating: nil,
InterfaceNames: InterfaceNames,
}
}
@@ -31,8 +32,8 @@ func (n *InterfaceExtends) GetPosition() *position.Position {
return n.Position
}
func (n *InterfaceExtends) GetMeta() *meta.Collection {
return &n.Meta
func (n *InterfaceExtends) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Label node
type Label struct {
Meta meta.Collection
Position *position.Position
LabelName node.Node
FreeFloating freefloating.Collection
Position *position.Position
LabelName node.Node
}
// NewLabel node constructor
func NewLabel(LabelName node.Node) *Label {
return &Label{
LabelName: LabelName,
FreeFloating: nil,
LabelName: LabelName,
}
}
@@ -31,8 +32,8 @@ func (n *Label) GetPosition() *position.Position {
return n.Position
}
func (n *Label) GetMeta() *meta.Collection {
return &n.Meta
func (n *Label) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,7 +9,7 @@ import (
// Namespace node
type Namespace struct {
Meta meta.Collection
FreeFloating freefloating.Collection
Position *position.Position
NamespaceName node.Node
Stmts []node.Node
@@ -18,6 +18,7 @@ type Namespace struct {
// NewNamespace node constructor
func NewNamespace(NamespaceName node.Node, Stmts []node.Node) *Namespace {
return &Namespace{
FreeFloating: nil,
NamespaceName: NamespaceName,
Stmts: Stmts,
}
@@ -33,8 +34,8 @@ func (n *Namespace) GetPosition() *position.Position {
return n.Position
}
func (n *Namespace) GetMeta() *meta.Collection {
return &n.Meta
func (n *Namespace) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,15 +1,15 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
)
// Nop node
type Nop struct {
Meta meta.Collection
Position *position.Position
FreeFloating freefloating.Collection
Position *position.Position
}
// NewNop node constructor
@@ -27,8 +27,8 @@ func (n *Nop) GetPosition() *position.Position {
return n.Position
}
func (n *Nop) GetMeta() *meta.Collection {
return &n.Meta
func (n *Nop) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,7 +9,7 @@ import (
// Property node
type Property struct {
Meta meta.Collection
FreeFloating freefloating.Collection
Position *position.Position
PhpDocComment string
Variable node.Node
@@ -19,6 +19,7 @@ type Property struct {
// NewProperty node constructor
func NewProperty(Variable node.Node, Expr node.Node, PhpDocComment string) *Property {
return &Property{
FreeFloating: nil,
PhpDocComment: PhpDocComment,
Variable: Variable,
Expr: Expr,
@@ -35,8 +36,8 @@ func (n *Property) GetPosition() *position.Position {
return n.Position
}
func (n *Property) GetMeta() *meta.Collection {
return &n.Meta
func (n *Property) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// PropertyList node
type PropertyList struct {
Meta meta.Collection
Position *position.Position
Modifiers []node.Node
Properties []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Modifiers []node.Node
Properties []node.Node
}
// NewPropertyList node constructor
func NewPropertyList(Modifiers []node.Node, Properties []node.Node) *PropertyList {
return &PropertyList{
Modifiers: Modifiers,
Properties: Properties,
FreeFloating: nil,
Modifiers: Modifiers,
Properties: Properties,
}
}
@@ -33,8 +34,8 @@ func (n *PropertyList) GetPosition() *position.Position {
return n.Position
}
func (n *PropertyList) GetMeta() *meta.Collection {
return &n.Meta
func (n *PropertyList) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Return node
type Return struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewReturn node constructor
func NewReturn(Expr node.Node) *Return {
return &Return{
Expr: Expr,
FreeFloating: nil,
Expr: Expr,
}
}
@@ -31,8 +32,8 @@ func (n *Return) GetPosition() *position.Position {
return n.Position
}
func (n *Return) GetMeta() *meta.Collection {
return &n.Meta
func (n *Return) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Static node
type Static struct {
Meta meta.Collection
Position *position.Position
Vars []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Vars []node.Node
}
// NewStatic node constructor
func NewStatic(Vars []node.Node) *Static {
return &Static{
Vars: Vars,
FreeFloating: nil,
Vars: Vars,
}
}
@@ -31,8 +32,8 @@ func (n *Static) GetPosition() *position.Position {
return n.Position
}
func (n *Static) GetMeta() *meta.Collection {
return &n.Meta
func (n *Static) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// StaticVar node
type StaticVar struct {
Meta meta.Collection
Position *position.Position
Variable node.Node
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Variable node.Node
Expr node.Node
}
// NewStaticVar node constructor
func NewStaticVar(Variable node.Node, Expr node.Node) *StaticVar {
return &StaticVar{
Variable: Variable,
Expr: Expr,
FreeFloating: nil,
Variable: Variable,
Expr: Expr,
}
}
@@ -33,8 +34,8 @@ func (n *StaticVar) GetPosition() *position.Position {
return n.Position
}
func (n *StaticVar) GetMeta() *meta.Collection {
return &n.Meta
func (n *StaticVar) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// StmtList node
type StmtList struct {
Meta meta.Collection
Position *position.Position
Stmts []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Stmts []node.Node
}
// NewStmtList node constructor
func NewStmtList(Stmts []node.Node) *StmtList {
return &StmtList{
Stmts: Stmts,
FreeFloating: nil,
Stmts: Stmts,
}
}
@@ -31,8 +32,8 @@ func (n *StmtList) GetPosition() *position.Position {
return n.Position
}
func (n *StmtList) GetMeta() *meta.Collection {
return &n.Meta
func (n *StmtList) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Switch node
type Switch struct {
Meta meta.Collection
Position *position.Position
Cond node.Node
CaseList *CaseList
FreeFloating freefloating.Collection
Position *position.Position
Cond node.Node
CaseList *CaseList
}
// NewSwitch node constructor
func NewSwitch(Cond node.Node, CaseList *CaseList) *Switch {
return &Switch{
Cond: Cond,
CaseList: CaseList,
FreeFloating: nil,
Cond: Cond,
CaseList: CaseList,
}
}
@@ -33,8 +34,8 @@ func (n *Switch) GetPosition() *position.Position {
return n.Position
}
func (n *Switch) GetMeta() *meta.Collection {
return &n.Meta
func (n *Switch) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Throw node
type Throw struct {
Meta meta.Collection
Position *position.Position
Expr node.Node
FreeFloating freefloating.Collection
Position *position.Position
Expr node.Node
}
// NewThrow node constructor
func NewThrow(Expr node.Node) *Throw {
return &Throw{
Expr: Expr,
FreeFloating: nil,
Expr: Expr,
}
}
@@ -31,8 +32,8 @@ func (n *Throw) GetPosition() *position.Position {
return n.Position
}
func (n *Throw) GetMeta() *meta.Collection {
return &n.Meta
func (n *Throw) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,7 +9,7 @@ import (
// Trait node
type Trait struct {
Meta meta.Collection
FreeFloating freefloating.Collection
Position *position.Position
PhpDocComment string
TraitName node.Node
@@ -19,6 +19,7 @@ type Trait struct {
// NewTrait node constructor
func NewTrait(TraitName node.Node, Stmts []node.Node, PhpDocComment string) *Trait {
return &Trait{
FreeFloating: nil,
PhpDocComment: PhpDocComment,
TraitName: TraitName,
Stmts: Stmts,
@@ -35,8 +36,8 @@ func (n *Trait) GetPosition() *position.Position {
return n.Position
}
func (n *Trait) GetMeta() *meta.Collection {
return &n.Meta
func (n *Trait) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// TraitAdaptationList node
type TraitAdaptationList struct {
Meta meta.Collection
Position *position.Position
Adaptations []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Adaptations []node.Node
}
// NewTraitAdaptationList node constructor
func NewTraitAdaptationList(Adaptations []node.Node) *TraitAdaptationList {
return &TraitAdaptationList{
Adaptations: Adaptations,
FreeFloating: nil,
Adaptations: Adaptations,
}
}
@@ -31,8 +32,8 @@ func (n *TraitAdaptationList) GetPosition() *position.Position {
return n.Position
}
func (n *TraitAdaptationList) GetMeta() *meta.Collection {
return &n.Meta
func (n *TraitAdaptationList) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// TraitMethodRef node
type TraitMethodRef struct {
Meta meta.Collection
Position *position.Position
Trait node.Node
Method node.Node
FreeFloating freefloating.Collection
Position *position.Position
Trait node.Node
Method node.Node
}
// NewTraitMethodRef node constructor
func NewTraitMethodRef(Trait node.Node, Method node.Node) *TraitMethodRef {
return &TraitMethodRef{
Trait: Trait,
Method: Method,
FreeFloating: nil,
Trait: Trait,
Method: Method,
}
}
@@ -33,8 +34,8 @@ func (n *TraitMethodRef) GetPosition() *position.Position {
return n.Position
}
func (n *TraitMethodRef) GetMeta() *meta.Collection {
return &n.Meta
func (n *TraitMethodRef) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,7 +9,7 @@ import (
// TraitUse node
type TraitUse struct {
Meta meta.Collection
FreeFloating freefloating.Collection
Position *position.Position
Traits []node.Node
TraitAdaptationList node.Node
@@ -18,6 +18,7 @@ type TraitUse struct {
// NewTraitUse node constructor
func NewTraitUse(Traits []node.Node, InnerAdaptationList node.Node) *TraitUse {
return &TraitUse{
FreeFloating: nil,
Traits: Traits,
TraitAdaptationList: InnerAdaptationList,
}
@@ -33,8 +34,8 @@ func (n *TraitUse) GetPosition() *position.Position {
return n.Position
}
func (n *TraitUse) GetMeta() *meta.Collection {
return &n.Meta
func (n *TraitUse) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,19 +9,20 @@ import (
// TraitUseAlias node
type TraitUseAlias struct {
Meta meta.Collection
Position *position.Position
Ref node.Node
Modifier node.Node
Alias node.Node
FreeFloating freefloating.Collection
Position *position.Position
Ref node.Node
Modifier node.Node
Alias node.Node
}
// NewTraitUseAlias node constructor
func NewTraitUseAlias(Ref node.Node, Modifier node.Node, Alias node.Node) *TraitUseAlias {
return &TraitUseAlias{
Ref: Ref,
Modifier: Modifier,
Alias: Alias,
FreeFloating: nil,
Ref: Ref,
Modifier: Modifier,
Alias: Alias,
}
}
@@ -35,8 +36,8 @@ func (n *TraitUseAlias) GetPosition() *position.Position {
return n.Position
}
func (n *TraitUseAlias) GetMeta() *meta.Collection {
return &n.Meta
func (n *TraitUseAlias) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// TraitUsePrecedence node
type TraitUsePrecedence struct {
Meta meta.Collection
Position *position.Position
Ref node.Node
Insteadof []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Ref node.Node
Insteadof []node.Node
}
// NewTraitUsePrecedence node constructor
func NewTraitUsePrecedence(Ref node.Node, Insteadof []node.Node) *TraitUsePrecedence {
return &TraitUsePrecedence{
Ref: Ref,
Insteadof: Insteadof,
FreeFloating: nil,
Ref: Ref,
Insteadof: Insteadof,
}
}
@@ -33,8 +34,8 @@ func (n *TraitUsePrecedence) GetPosition() *position.Position {
return n.Position
}
func (n *TraitUsePrecedence) GetMeta() *meta.Collection {
return &n.Meta
func (n *TraitUsePrecedence) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,19 +9,20 @@ import (
// Try node
type Try struct {
Meta meta.Collection
Position *position.Position
Stmts []node.Node
Catches []node.Node
Finally node.Node
FreeFloating freefloating.Collection
Position *position.Position
Stmts []node.Node
Catches []node.Node
Finally node.Node
}
// NewTry node constructor
func NewTry(Stmts []node.Node, Catches []node.Node, Finally node.Node) *Try {
return &Try{
Stmts: Stmts,
Catches: Catches,
Finally: Finally,
FreeFloating: nil,
Stmts: Stmts,
Catches: Catches,
Finally: Finally,
}
}
@@ -35,8 +36,8 @@ func (n *Try) GetPosition() *position.Position {
return n.Position
}
func (n *Try) GetMeta() *meta.Collection {
return &n.Meta
func (n *Try) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,15 +9,16 @@ import (
// Unset node
type Unset struct {
Meta meta.Collection
Position *position.Position
Vars []node.Node
FreeFloating freefloating.Collection
Position *position.Position
Vars []node.Node
}
// NewUnset node constructor
func NewUnset(Vars []node.Node) *Unset {
return &Unset{
Vars: Vars,
FreeFloating: nil,
Vars: Vars,
}
}
@@ -31,8 +32,8 @@ func (n *Unset) GetPosition() *position.Position {
return n.Position
}
func (n *Unset) GetMeta() *meta.Collection {
return &n.Meta
func (n *Unset) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,19 +9,20 @@ import (
// Use node
type Use struct {
Meta meta.Collection
Position *position.Position
UseType node.Node
Use node.Node
Alias node.Node
FreeFloating freefloating.Collection
Position *position.Position
UseType node.Node
Use node.Node
Alias node.Node
}
// NewUse node constructor
func NewUse(UseType node.Node, use node.Node, Alias node.Node) *Use {
return &Use{
UseType: UseType,
Use: use,
Alias: Alias,
FreeFloating: nil,
UseType: UseType,
Use: use,
Alias: Alias,
}
}
@@ -35,8 +36,8 @@ func (n *Use) GetPosition() *position.Position {
return n.Position
}
func (n *Use) GetMeta() *meta.Collection {
return &n.Meta
func (n *Use) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// UseList node
type UseList struct {
Meta meta.Collection
Position *position.Position
UseType node.Node
Uses []node.Node
FreeFloating freefloating.Collection
Position *position.Position
UseType node.Node
Uses []node.Node
}
// NewUseList node constructor
func NewUseList(UseType node.Node, Uses []node.Node) *UseList {
return &UseList{
UseType: UseType,
Uses: Uses,
FreeFloating: nil,
UseType: UseType,
Uses: Uses,
}
}
@@ -33,8 +34,8 @@ func (n *UseList) GetPosition() *position.Position {
return n.Position
}
func (n *UseList) GetMeta() *meta.Collection {
return &n.Meta
func (n *UseList) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package stmt
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// While node
type While struct {
Meta meta.Collection
Position *position.Position
Cond node.Node
Stmt node.Node
FreeFloating freefloating.Collection
Position *position.Position
Cond node.Node
Stmt node.Node
}
// NewWhile node constructor
func NewWhile(Cond node.Node, Stmt node.Node) *While {
return &While{
Cond: Cond,
Stmt: Stmt,
FreeFloating: nil,
Cond: Cond,
Stmt: Stmt,
}
}
@@ -33,8 +34,8 @@ func (n *While) GetPosition() *position.Position {
return n.Position
}
func (n *While) GetMeta() *meta.Collection {
return &n.Meta
func (n *While) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -2,35 +2,18 @@ package stmt_test
import (
"bytes"
"reflect"
"testing"
"github.com/davecgh/go-spew/spew"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/position"
"github.com/kylelemons/godebug/pretty"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/stmt"
"github.com/z7zmey/php-parser/php5"
"github.com/z7zmey/php-parser/php7"
"github.com/z7zmey/php-parser/position"
)
func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
if !reflect.DeepEqual(expected, actual) {
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("diff: (-expected +actual)\n%s", diff)
} else {
t.Errorf("expected and actual are not equal\nexpectd: %+v\nactual: %+v\n", expected, actual)
t.Log(spew.Sdump(expected, actual))
}
}
}
func TestAltIf(t *testing.T) {
src := `<?
if ($a) :
@@ -85,12 +68,12 @@ func TestAltIf(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestAltElseIf(t *testing.T) {
@@ -184,12 +167,12 @@ func TestAltElseIf(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestAltElse(t *testing.T) {
@@ -264,12 +247,12 @@ func TestAltElse(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestAltElseElseIf(t *testing.T) {
@@ -416,10 +399,10 @@ func TestAltElseElseIf(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/scalar"
"github.com/z7zmey/php-parser/position"
@@ -125,7 +127,7 @@ func TestClassConstList(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestClassConstListWithoutModifiers(t *testing.T) {
@@ -229,10 +231,10 @@ func TestClassConstListWithoutModifiers(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/name"
"github.com/z7zmey/php-parser/position"
@@ -78,12 +80,12 @@ func TestSimpleClassMethod(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestPrivateProtectedClassMethod(t *testing.T) {
@@ -210,12 +212,12 @@ func TestPrivateProtectedClassMethod(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestPhp5ClassMethod(t *testing.T) {
@@ -303,7 +305,7 @@ func TestPhp5ClassMethod(t *testing.T) {
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual := php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestPhp7ClassMethod(t *testing.T) {
@@ -410,7 +412,7 @@ func TestPhp7ClassMethod(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestAbstractClassMethod(t *testing.T) {
@@ -508,12 +510,12 @@ func TestAbstractClassMethod(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestPhp7AbstractClassMethod(t *testing.T) {
@@ -621,5 +623,5 @@ func TestPhp7AbstractClassMethod(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/name"
"github.com/z7zmey/php-parser/position"
@@ -50,12 +52,12 @@ func TestSimpleClass(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestAbstractClass(t *testing.T) {
@@ -105,12 +107,12 @@ func TestAbstractClass(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestClassExtends(t *testing.T) {
@@ -187,12 +189,12 @@ func TestClassExtends(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestClassImplement(t *testing.T) {
@@ -271,12 +273,12 @@ func TestClassImplement(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestClassImplements(t *testing.T) {
@@ -374,12 +376,12 @@ func TestClassImplements(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestAnonimousClass(t *testing.T) {
@@ -508,5 +510,5 @@ func TestAnonimousClass(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/scalar"
"github.com/z7zmey/php-parser/position"
@@ -94,10 +96,10 @@ func TestConstList(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/scalar"
"github.com/z7zmey/php-parser/position"
@@ -65,12 +67,12 @@ func TestContinueEmpty(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestContinueLight(t *testing.T) {
@@ -134,12 +136,12 @@ func TestContinueLight(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestContinue(t *testing.T) {
@@ -203,10 +205,10 @@ func TestContinue(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/scalar"
"github.com/z7zmey/php-parser/position"
@@ -75,12 +77,12 @@ func TestDeclare(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestDeclareStmts(t *testing.T) {
@@ -173,12 +175,12 @@ func TestDeclareStmts(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestAltDeclare(t *testing.T) {
@@ -245,10 +247,10 @@ func TestAltDeclare(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/scalar"
"github.com/z7zmey/php-parser/position"
@@ -56,10 +58,10 @@ func TestDo(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/position"
@@ -68,12 +70,12 @@ func TestSimpleEcho(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestEcho(t *testing.T) {
@@ -120,10 +122,10 @@ func TestEcho(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/scalar"
"github.com/z7zmey/php-parser/position"
@@ -47,10 +49,10 @@ func TestExpression(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/expr/binary"
"github.com/z7zmey/php-parser/position"
@@ -176,12 +178,12 @@ func TestFor(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestAltFor(t *testing.T) {
@@ -281,10 +283,10 @@ func TestAltFor(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/position"
@@ -81,12 +83,12 @@ func TestForeach(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestForeachExpr(t *testing.T) {
@@ -149,12 +151,12 @@ func TestForeachExpr(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestAltForeach(t *testing.T) {
@@ -225,12 +227,12 @@ func TestAltForeach(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestForeachWithKey(t *testing.T) {
@@ -318,12 +320,12 @@ func TestForeachWithKey(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestForeachExprWithKey(t *testing.T) {
@@ -403,12 +405,12 @@ func TestForeachExprWithKey(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestForeachWithRef(t *testing.T) {
@@ -504,12 +506,12 @@ func TestForeachWithRef(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestForeachWithList(t *testing.T) {
@@ -615,10 +617,10 @@ func TestForeachWithList(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -0,0 +1,216 @@
package stmt_test
import (
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/stmt"
)
var expected freefloating.Collection = freefloating.Collection{
freefloating.Start: []freefloating.String{
{
StringType: freefloating.WhiteSpaceType,
Value: " ",
Position: nil,
},
{
StringType: freefloating.CommentType,
Value: "//comment\n",
Position: nil,
},
},
}
var nodes = []node.Node{
&stmt.AltElseIf{
FreeFloating: expected,
},
&stmt.AltElse{
FreeFloating: expected,
},
&stmt.AltFor{
FreeFloating: expected,
},
&stmt.AltForeach{
FreeFloating: expected,
},
&stmt.AltIf{
FreeFloating: expected,
},
&stmt.AltSwitch{
FreeFloating: expected,
},
&stmt.AltWhile{
FreeFloating: expected,
},
&stmt.Break{
FreeFloating: expected,
},
&stmt.CaseList{
FreeFloating: expected,
},
&stmt.Case{
FreeFloating: expected,
},
&stmt.Catch{
FreeFloating: expected,
},
&stmt.ClassConstList{
FreeFloating: expected,
},
&stmt.ClassExtends{
FreeFloating: expected,
},
&stmt.ClassImplements{
FreeFloating: expected,
},
&stmt.ClassMethod{
FreeFloating: expected,
},
&stmt.Class{
FreeFloating: expected,
},
&stmt.ConstList{
FreeFloating: expected,
},
&stmt.Constant{
FreeFloating: expected,
},
&stmt.Continue{
FreeFloating: expected,
},
&stmt.Declare{
FreeFloating: expected,
},
&stmt.Default{
FreeFloating: expected,
},
&stmt.Do{
FreeFloating: expected,
},
&stmt.Echo{
FreeFloating: expected,
},
&stmt.ElseIf{
FreeFloating: expected,
},
&stmt.Else{
FreeFloating: expected,
},
&stmt.Expression{
FreeFloating: expected,
},
&stmt.Finally{
FreeFloating: expected,
},
&stmt.For{
FreeFloating: expected,
},
&stmt.Foreach{
FreeFloating: expected,
},
&stmt.Function{
FreeFloating: expected,
},
&stmt.Global{
FreeFloating: expected,
},
&stmt.Goto{
FreeFloating: expected,
},
&stmt.GroupUse{
FreeFloating: expected,
},
&stmt.HaltCompiler{
FreeFloating: expected,
},
&stmt.If{
FreeFloating: expected,
},
&stmt.InlineHtml{
FreeFloating: expected,
},
&stmt.InterfaceExtends{
FreeFloating: expected,
},
&stmt.Interface{
FreeFloating: expected,
},
&stmt.Label{
FreeFloating: expected,
},
&stmt.Namespace{
FreeFloating: expected,
},
&stmt.Nop{
FreeFloating: expected,
},
&stmt.PropertyList{
FreeFloating: expected,
},
&stmt.Property{
FreeFloating: expected,
},
&stmt.Return{
FreeFloating: expected,
},
&stmt.StaticVar{
FreeFloating: expected,
},
&stmt.Static{
FreeFloating: expected,
},
&stmt.StmtList{
FreeFloating: expected,
},
&stmt.Switch{
FreeFloating: expected,
},
&stmt.Throw{
FreeFloating: expected,
},
&stmt.TraitAdaptationList{
FreeFloating: expected,
},
&stmt.TraitMethodRef{
FreeFloating: expected,
},
&stmt.TraitUseAlias{
FreeFloating: expected,
},
&stmt.TraitUsePrecedence{
FreeFloating: expected,
},
&stmt.TraitUse{
FreeFloating: expected,
},
&stmt.Trait{
FreeFloating: expected,
},
&stmt.Try{
FreeFloating: expected,
},
&stmt.Unset{
FreeFloating: expected,
},
&stmt.UseList{
FreeFloating: expected,
},
&stmt.Use{
FreeFloating: expected,
},
&stmt.While{
FreeFloating: expected,
},
}
func TestMeta(t *testing.T) {
for _, n := range nodes {
actual := *n.GetFreeFloating()
assert.DeepEqual(t, expected, actual)
}
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/name"
"github.com/z7zmey/php-parser/node/scalar"
"github.com/z7zmey/php-parser/position"
@@ -52,12 +54,12 @@ func TestSimpleFunction(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestFunctionReturn(t *testing.T) {
@@ -106,12 +108,12 @@ func TestFunctionReturn(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestFunctionReturnVar(t *testing.T) {
@@ -251,12 +253,12 @@ func TestFunctionReturnVar(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestRefFunction(t *testing.T) {
@@ -314,12 +316,12 @@ func TestRefFunction(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestReturnTypeFunction(t *testing.T) {
@@ -378,5 +380,5 @@ func TestReturnTypeFunction(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/name"
@@ -57,12 +59,12 @@ func TestGlobal(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestGlobalVars(t *testing.T) {
@@ -194,10 +196,10 @@ func TestGlobalVars(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/stmt"
"github.com/z7zmey/php-parser/php5"
@@ -62,10 +64,10 @@ func TestGotoLabel(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/stmt"
"github.com/z7zmey/php-parser/php5"
@@ -36,10 +38,10 @@ func TestHaltCompiler(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/position"
@@ -64,12 +66,12 @@ func TestIf(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestElseIf(t *testing.T) {
@@ -159,12 +161,12 @@ func TestElseIf(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestElse(t *testing.T) {
@@ -235,12 +237,12 @@ func TestElse(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestElseElseIf(t *testing.T) {
@@ -381,12 +383,12 @@ func TestElseElseIf(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestElseIfElseIfElse(t *testing.T) {
@@ -535,10 +537,10 @@ func TestElseIfElseIfElse(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/stmt"
"github.com/z7zmey/php-parser/php5"
@@ -45,10 +47,10 @@ func TestInlineHtml(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/name"
"github.com/z7zmey/php-parser/position"
@@ -49,12 +51,12 @@ func TestInterface(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestInterfaceExtend(t *testing.T) {
@@ -122,12 +124,12 @@ func TestInterfaceExtend(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestInterfaceExtends(t *testing.T) {
@@ -214,10 +216,10 @@ func TestInterfaceExtends(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -1,94 +0,0 @@
package stmt_test
import (
"testing"
"github.com/z7zmey/php-parser/node/stmt"
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/node"
)
var nodes = []node.Node{
&stmt.AltElseIf{},
&stmt.AltElse{},
&stmt.AltFor{},
&stmt.AltForeach{},
&stmt.AltIf{},
&stmt.AltSwitch{},
&stmt.AltWhile{},
&stmt.Break{},
&stmt.CaseList{},
&stmt.Case{},
&stmt.Catch{},
&stmt.ClassConstList{},
&stmt.ClassExtends{},
&stmt.ClassImplements{},
&stmt.ClassMethod{},
&stmt.Class{},
&stmt.ConstList{},
&stmt.Constant{},
&stmt.Continue{},
&stmt.Declare{},
&stmt.Default{},
&stmt.Do{},
&stmt.Echo{},
&stmt.ElseIf{},
&stmt.Else{},
&stmt.Expression{},
&stmt.Finally{},
&stmt.For{},
&stmt.Foreach{},
&stmt.Function{},
&stmt.Global{},
&stmt.Goto{},
&stmt.GroupUse{},
&stmt.HaltCompiler{},
&stmt.If{},
&stmt.InlineHtml{},
&stmt.InterfaceExtends{},
&stmt.Interface{},
&stmt.Label{},
&stmt.Namespace{},
&stmt.Nop{},
&stmt.PropertyList{},
&stmt.Property{},
&stmt.Return{},
&stmt.StaticVar{},
&stmt.Static{},
&stmt.StmtList{},
&stmt.Switch{},
&stmt.Throw{},
&stmt.TraitAdaptationList{},
&stmt.TraitMethodRef{},
&stmt.TraitUseAlias{},
&stmt.TraitUsePrecedence{},
&stmt.TraitUse{},
&stmt.Trait{},
&stmt.Try{},
&stmt.Unset{},
&stmt.UseList{},
&stmt.Use{},
&stmt.While{},
}
func TestMeta(t *testing.T) {
expected := &meta.Collection{
&meta.Data{
Value: "//comment\n",
Type: meta.CommentType,
Position: nil,
},
&meta.Data{
Value: " ",
Type: meta.WhiteSpaceType,
Position: nil,
},
}
for _, n := range nodes {
n.GetMeta().Push(*expected...)
actual := n.GetMeta()
assertEqual(t, expected, actual)
}
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/name"
"github.com/z7zmey/php-parser/position"
@@ -57,12 +59,12 @@ func TestNamespace(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestNamespaceStmts(t *testing.T) {
@@ -110,12 +112,12 @@ func TestNamespaceStmts(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestAnonymousNamespace(t *testing.T) {
@@ -144,10 +146,10 @@ func TestAnonymousNamespace(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -3,6 +3,8 @@ package stmt_test
import (
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/position"
)
@@ -11,6 +13,6 @@ func TestPosition(t *testing.T) {
for _, n := range nodes {
n.SetPosition(expected)
actual := n.GetPosition()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/scalar"
"github.com/z7zmey/php-parser/position"
@@ -98,12 +100,12 @@ func TestProperty(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestProperties(t *testing.T) {
@@ -234,12 +236,12 @@ func TestProperties(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestProperties2(t *testing.T) {
@@ -370,10 +372,10 @@ func TestProperties2(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/scalar"
@@ -65,12 +67,12 @@ func TestStaticVar(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestStaticVars(t *testing.T) {
@@ -159,12 +161,12 @@ func TestStaticVars(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestStaticVars2(t *testing.T) {
@@ -253,10 +255,10 @@ func TestStaticVars2(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/scalar"
"github.com/z7zmey/php-parser/position"
@@ -108,12 +110,12 @@ func TestAltSwitch(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestAltSwitchSemicolon(t *testing.T) {
@@ -201,12 +203,12 @@ func TestAltSwitchSemicolon(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestSwitch(t *testing.T) {
@@ -312,12 +314,12 @@ func TestSwitch(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestSwitchSemicolon(t *testing.T) {
@@ -423,10 +425,10 @@ func TestSwitchSemicolon(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/stmt"
@@ -54,10 +56,10 @@ func TestThrow(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/stmt"
"github.com/z7zmey/php-parser/php5"
@@ -47,10 +49,10 @@ func TestTrait(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/name"
"github.com/z7zmey/php-parser/position"
@@ -87,12 +89,12 @@ func TestTraitUse(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestTraitsUse(t *testing.T) {
@@ -188,12 +190,12 @@ func TestTraitsUse(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestTraitsUseEmptyAdaptations(t *testing.T) {
@@ -289,12 +291,12 @@ func TestTraitsUseEmptyAdaptations(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestTraitsUseModifier(t *testing.T) {
@@ -426,12 +428,12 @@ func TestTraitsUseModifier(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestTraitsUseAliasModifier(t *testing.T) {
@@ -572,12 +574,12 @@ func TestTraitsUseAliasModifier(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestTraitsUseAdaptions(t *testing.T) {
@@ -812,10 +814,10 @@ func TestTraitsUseAdaptions(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/name"
"github.com/z7zmey/php-parser/position"
@@ -43,12 +45,12 @@ func TestTry(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestTryCatch(t *testing.T) {
@@ -128,12 +130,12 @@ func TestTryCatch(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestPhp7TryCatch(t *testing.T) {
@@ -232,7 +234,7 @@ func TestPhp7TryCatch(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestTryCatchCatch(t *testing.T) {
@@ -359,12 +361,12 @@ func TestTryCatchCatch(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestTryCatchFinally(t *testing.T) {
@@ -453,12 +455,12 @@ func TestTryCatchFinally(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestTryCatchCatchCatch(t *testing.T) {
@@ -630,10 +632,10 @@ func TestTryCatchCatchCatch(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/stmt"
@@ -56,12 +58,12 @@ func TestUnset(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestUnsetVars(t *testing.T) {
@@ -125,12 +127,12 @@ func TestUnsetVars(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestUnsetTrailingComma(t *testing.T) {
@@ -194,5 +196,5 @@ func TestUnsetTrailingComma(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/name"
"github.com/z7zmey/php-parser/position"
@@ -67,12 +69,12 @@ func TestSimpleUse(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestUseFullyQualified(t *testing.T) {
@@ -129,12 +131,12 @@ func TestUseFullyQualified(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestUseFullyQualifiedAlias(t *testing.T) {
@@ -200,12 +202,12 @@ func TestUseFullyQualifiedAlias(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestUseList(t *testing.T) {
@@ -289,12 +291,12 @@ func TestUseList(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestUseListAlias(t *testing.T) {
@@ -387,12 +389,12 @@ func TestUseListAlias(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestUseListFunctionType(t *testing.T) {
@@ -485,12 +487,12 @@ func TestUseListFunctionType(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestUseListFunctionTypeAliases(t *testing.T) {
@@ -601,12 +603,12 @@ func TestUseListFunctionTypeAliases(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestUseListConstType(t *testing.T) {
@@ -699,12 +701,12 @@ func TestUseListConstType(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestUseListConstTypeAliases(t *testing.T) {
@@ -815,12 +817,12 @@ func TestUseListConstTypeAliases(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestGroupUse(t *testing.T) {
@@ -923,7 +925,7 @@ func TestGroupUse(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestGroupUseAlias(t *testing.T) {
@@ -1035,7 +1037,7 @@ func TestGroupUseAlias(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestFunctionGroupUse(t *testing.T) {
@@ -1147,7 +1149,7 @@ func TestFunctionGroupUse(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestConstGroupUse(t *testing.T) {
@@ -1259,7 +1261,7 @@ func TestConstGroupUse(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestMixedGroupUse(t *testing.T) {
@@ -1380,5 +1382,5 @@ func TestMixedGroupUse(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -1,15 +1,15 @@
package stmt_test
import (
"reflect"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/name"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/stmt"
"github.com/kylelemons/godebug/pretty"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/walker"
)
@@ -27,14 +27,14 @@ var nodesToTest = []struct {
Else: &stmt.Else{},
},
[]string{"Cond", "Stmt", "ElseIf", "Else"},
map[string]interface{}{},
nil,
},
{
&stmt.AltElse{
Stmt: &stmt.StmtList{},
},
[]string{"Stmt"},
map[string]interface{}{},
nil,
},
{
&stmt.AltElseIf{
@@ -42,14 +42,14 @@ var nodesToTest = []struct {
Stmt: &stmt.StmtList{},
},
[]string{"Cond", "Stmt"},
map[string]interface{}{},
nil,
},
{
&stmt.Break{
Expr: &stmt.Expression{},
},
[]string{"Expr"},
map[string]interface{}{},
nil,
},
{
&stmt.Case{
@@ -57,7 +57,7 @@ var nodesToTest = []struct {
Stmts: []node.Node{&stmt.Expression{}},
},
[]string{"Cond", "Stmts"},
map[string]interface{}{},
nil,
},
{
&stmt.Catch{
@@ -66,7 +66,7 @@ var nodesToTest = []struct {
Stmts: []node.Node{&stmt.Expression{}},
},
[]string{"Types", "Variable", "Stmts"},
map[string]interface{}{},
nil,
},
{
&stmt.ClassConstList{
@@ -74,7 +74,7 @@ var nodesToTest = []struct {
Consts: []node.Node{&stmt.Expression{}},
},
[]string{"Modifiers", "Consts"},
map[string]interface{}{},
nil,
},
{
&stmt.ClassMethod{
@@ -107,7 +107,7 @@ var nodesToTest = []struct {
Consts: []node.Node{&stmt.Expression{}},
},
[]string{"Consts"},
map[string]interface{}{},
nil,
},
{
&stmt.Constant{
@@ -123,7 +123,7 @@ var nodesToTest = []struct {
Expr: &stmt.Expression{},
},
[]string{"Expr"},
map[string]interface{}{},
nil,
},
{
&stmt.Declare{
@@ -131,14 +131,14 @@ var nodesToTest = []struct {
Stmt: &stmt.StmtList{},
},
[]string{"Consts", "Stmt"},
map[string]interface{}{},
nil,
},
{
&stmt.Default{
Stmts: []node.Node{&stmt.Expression{}},
},
[]string{"Stmts"},
map[string]interface{}{},
nil,
},
{
&stmt.Do{
@@ -146,7 +146,7 @@ var nodesToTest = []struct {
Cond: &expr.Variable{},
},
[]string{"Stmt", "Cond"},
map[string]interface{}{},
nil,
},
{
&stmt.Do{
@@ -154,14 +154,14 @@ var nodesToTest = []struct {
Cond: &expr.Variable{},
},
[]string{"Stmt", "Cond"},
map[string]interface{}{},
nil,
},
{
&stmt.Echo{
Exprs: []node.Node{&stmt.Expression{}},
},
[]string{"Exprs"},
map[string]interface{}{},
nil,
},
{
&stmt.If{
@@ -171,14 +171,14 @@ var nodesToTest = []struct {
Else: &stmt.Else{},
},
[]string{"Cond", "Stmt", "ElseIf", "Else"},
map[string]interface{}{},
nil,
},
{
&stmt.Else{
Stmt: &stmt.StmtList{},
},
[]string{"Stmt"},
map[string]interface{}{},
nil,
},
{
&stmt.ElseIf{
@@ -186,21 +186,21 @@ var nodesToTest = []struct {
Stmt: &stmt.StmtList{},
},
[]string{"Cond", "Stmt"},
map[string]interface{}{},
nil,
},
{
&stmt.Expression{
Expr: &stmt.Expression{},
},
[]string{"Expr"},
map[string]interface{}{},
nil,
},
{
&stmt.Finally{
Stmts: []node.Node{&stmt.Expression{}},
},
[]string{"Stmts"},
map[string]interface{}{},
nil,
},
{
&stmt.For{
@@ -210,7 +210,7 @@ var nodesToTest = []struct {
Stmt: &stmt.StmtList{},
},
[]string{"Init", "Cond", "Loop", "Stmt"},
map[string]interface{}{},
nil,
},
{
&stmt.AltFor{
@@ -220,7 +220,7 @@ var nodesToTest = []struct {
Stmt: &stmt.StmtList{},
},
[]string{"Init", "Cond", "Loop", "Stmt"},
map[string]interface{}{},
nil,
},
{
&stmt.Foreach{
@@ -230,7 +230,7 @@ var nodesToTest = []struct {
Stmt: &stmt.StmtList{},
},
[]string{"Expr", "Key", "Variable", "Stmt"},
map[string]interface{}{},
nil,
},
{
&stmt.AltForeach{
@@ -240,7 +240,7 @@ var nodesToTest = []struct {
Stmt: &stmt.StmtList{},
},
[]string{"Expr", "Key", "Variable", "Stmt"},
map[string]interface{}{},
nil,
},
{
&stmt.Function{
@@ -259,14 +259,14 @@ var nodesToTest = []struct {
Vars: []node.Node{&stmt.Expression{}},
},
[]string{"Vars"},
map[string]interface{}{},
nil,
},
{
&stmt.Goto{
Label: &node.Identifier{},
},
[]string{"Label"},
map[string]interface{}{},
nil,
},
{
&stmt.GroupUse{
@@ -275,12 +275,12 @@ var nodesToTest = []struct {
UseList: []node.Node{&stmt.Expression{}},
},
[]string{"UseType", "Prefix", "UseList"},
map[string]interface{}{},
nil,
},
{
&stmt.HaltCompiler{},
[]string{},
map[string]interface{}{},
nil,
},
{
&stmt.InlineHtml{
@@ -304,7 +304,7 @@ var nodesToTest = []struct {
LabelName: &node.Identifier{},
},
[]string{"LabelName"},
map[string]interface{}{},
nil,
},
{
&stmt.Namespace{
@@ -312,12 +312,12 @@ var nodesToTest = []struct {
Stmts: []node.Node{&stmt.Expression{}},
},
[]string{"NamespaceName", "Stmts"},
map[string]interface{}{},
nil,
},
{
&stmt.Nop{},
[]string{},
map[string]interface{}{},
nil,
},
{
&stmt.PropertyList{
@@ -325,7 +325,7 @@ var nodesToTest = []struct {
Properties: []node.Node{&stmt.Expression{}},
},
[]string{"Modifiers", "Properties"},
map[string]interface{}{},
nil,
},
{
&stmt.Property{
@@ -341,7 +341,7 @@ var nodesToTest = []struct {
Expr: &stmt.Expression{},
},
[]string{"Expr"},
map[string]interface{}{},
nil,
},
{
&stmt.StaticVar{
@@ -349,14 +349,14 @@ var nodesToTest = []struct {
Expr: &stmt.Expression{},
},
[]string{"Variable", "Expr"},
map[string]interface{}{},
nil,
},
{
&stmt.Static{
Vars: []node.Node{&stmt.Expression{}},
},
[]string{"Vars"},
map[string]interface{}{},
nil,
},
{
&stmt.Switch{
@@ -364,7 +364,7 @@ var nodesToTest = []struct {
CaseList: &stmt.CaseList{},
},
[]string{"Cond", "CaseList"},
map[string]interface{}{},
nil,
},
{
&stmt.AltSwitch{
@@ -372,14 +372,14 @@ var nodesToTest = []struct {
CaseList: &stmt.CaseList{},
},
[]string{"Cond", "CaseList"},
map[string]interface{}{},
nil,
},
{
&stmt.Throw{
Expr: &stmt.Expression{},
},
[]string{"Expr"},
map[string]interface{}{},
nil,
},
{
&stmt.TraitMethodRef{
@@ -387,7 +387,7 @@ var nodesToTest = []struct {
Method: &node.Identifier{},
},
[]string{"Trait", "Method"},
map[string]interface{}{},
nil,
},
{
&stmt.TraitUseAlias{
@@ -396,7 +396,7 @@ var nodesToTest = []struct {
Alias: &node.Identifier{},
},
[]string{"Ref", "Modifier", "Alias"},
map[string]interface{}{},
nil,
},
{
&stmt.TraitUsePrecedence{
@@ -404,7 +404,7 @@ var nodesToTest = []struct {
Insteadof: []node.Node{&node.Identifier{}},
},
[]string{"Ref", "Insteadof"},
map[string]interface{}{},
nil,
},
{
&stmt.TraitUse{
@@ -412,7 +412,7 @@ var nodesToTest = []struct {
TraitAdaptationList: &stmt.TraitAdaptationList{},
},
[]string{"Traits", "TraitAdaptationList"},
map[string]interface{}{},
nil,
},
{
&stmt.Trait{
@@ -430,14 +430,14 @@ var nodesToTest = []struct {
Finally: &stmt.Finally{},
},
[]string{"Stmts", "Catches", "Finally"},
map[string]interface{}{},
nil,
},
{
&stmt.Unset{
Vars: []node.Node{&stmt.Expression{}},
},
[]string{"Vars"},
map[string]interface{}{},
nil,
},
{
&stmt.UseList{
@@ -445,7 +445,7 @@ var nodesToTest = []struct {
Uses: []node.Node{&stmt.Expression{}},
},
[]string{"UseType", "Uses"},
map[string]interface{}{},
nil,
},
{
&stmt.Use{
@@ -454,7 +454,7 @@ var nodesToTest = []struct {
Alias: &node.Identifier{},
},
[]string{"UseType", "Use", "Alias"},
map[string]interface{}{},
nil,
},
{
&stmt.While{
@@ -462,7 +462,7 @@ var nodesToTest = []struct {
Stmt: &stmt.StmtList{},
},
[]string{"Cond", "Stmt"},
map[string]interface{}{},
nil,
},
{
&stmt.AltWhile{
@@ -470,35 +470,35 @@ var nodesToTest = []struct {
Stmt: &stmt.StmtList{},
},
[]string{"Cond", "Stmt"},
map[string]interface{}{},
nil,
},
{
&stmt.StmtList{
Stmts: []node.Node{&stmt.Expression{}},
},
[]string{"Stmts"},
map[string]interface{}{},
nil,
},
{
&stmt.CaseList{
Cases: []node.Node{&stmt.Expression{}},
},
[]string{"Cases"},
map[string]interface{}{},
nil,
},
{
&stmt.TraitAdaptationList{
Adaptations: []node.Node{&stmt.TraitUsePrecedence{}},
},
[]string{"Adaptations"},
map[string]interface{}{},
nil,
},
{
&stmt.ClassExtends{
ClassName: &name.Name{},
},
[]string{"ClassName"},
map[string]interface{}{},
nil,
},
{
&stmt.ClassImplements{
@@ -507,7 +507,7 @@ var nodesToTest = []struct {
},
},
[]string{"InterfaceNames"},
map[string]interface{}{},
nil,
},
{
&stmt.InterfaceExtends{
@@ -516,7 +516,7 @@ var nodesToTest = []struct {
},
},
[]string{"InterfaceNames"},
map[string]interface{}{},
nil,
},
}
@@ -538,31 +538,25 @@ func (v *visitorMock) LeaveChildList(key string, w walker.Walkable) {}
func TestVisitorDisableChildren(t *testing.T) {
for _, tt := range nodesToTest {
v := &visitorMock{false, nil}
v := &visitorMock{false, []string{}}
tt.node.Walk(v)
expected := []string{}
actual := v.visitedKeys
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
}
assert.DeepEqual(t, expected, actual)
}
}
func TestVisitor(t *testing.T) {
for _, tt := range nodesToTest {
v := &visitorMock{true, nil}
v := &visitorMock{true, []string{}}
tt.node.Walk(v)
expected := tt.expectedVisitedKeys
actual := v.visitedKeys
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
}
assert.DeepEqual(t, expected, actual)
}
}
@@ -573,9 +567,6 @@ func TestNameAttributes(t *testing.T) {
expected := tt.expectedAttributes
actual := tt.node.Attributes()
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
}
assert.DeepEqual(t, expected, actual)
}
}

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node/scalar"
"github.com/z7zmey/php-parser/position"
@@ -65,12 +67,12 @@ func TestBreakEmpty(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestBreakLight(t *testing.T) {
@@ -134,12 +136,12 @@ func TestBreakLight(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestBreak(t *testing.T) {
@@ -203,10 +205,10 @@ func TestBreak(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}