create ArgumentList node

This commit is contained in:
z7zmey 2018-04-29 19:58:49 +03:00
parent be3bdbfdc0
commit 8fc4c60bfe
28 changed files with 2010 additions and 1832 deletions

View File

@ -99,11 +99,13 @@ func TestReferenceArgs(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{ Arguments: []node.Node{
Variadic: false, &node.Argument{
IsReference: false, Variadic: false,
Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, IsReference: false,
Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}},
},
}, },
}, },
}, },

View File

@ -7,15 +7,15 @@ import (
// FunctionCall node // FunctionCall node
type FunctionCall struct { type FunctionCall struct {
Function node.Node Function node.Node
Arguments []node.Node ArgumentList *node.ArgumentList
} }
// NewFunctionCall node constructor // NewFunctionCall node constructor
func NewFunctionCall(Function node.Node, Arguments []node.Node) *FunctionCall { func NewFunctionCall(Function node.Node, ArgumentList *node.ArgumentList) *FunctionCall {
return &FunctionCall{ return &FunctionCall{
Function, Function,
Arguments, ArgumentList,
} }
} }
@ -36,13 +36,9 @@ func (n *FunctionCall) Walk(v walker.Visitor) {
n.Function.Walk(vv) n.Function.Walk(vv)
} }
if n.Arguments != nil { if n.ArgumentList != nil {
vv := v.GetChildrenVisitor("Arguments") vv := v.GetChildrenVisitor("ArgumentList")
for _, nn := range n.Arguments { n.ArgumentList.Walk(vv)
if nn != nil {
nn.Walk(vv)
}
}
} }
v.LeaveNode(n) v.LeaveNode(n)

View File

@ -7,17 +7,17 @@ import (
// MethodCall node // MethodCall node
type MethodCall struct { type MethodCall struct {
Variable node.Node Variable node.Node
Method node.Node Method node.Node
Arguments []node.Node ArgumentList *node.ArgumentList
} }
// NewMethodCall node constructor // NewMethodCall node constructor
func NewMethodCall(Variable node.Node, Method node.Node, Arguments []node.Node) *MethodCall { func NewMethodCall(Variable node.Node, Method node.Node, ArgumentList *node.ArgumentList) *MethodCall {
return &MethodCall{ return &MethodCall{
Variable, Variable,
Method, Method,
Arguments, ArgumentList,
} }
} }
@ -43,13 +43,9 @@ func (n *MethodCall) Walk(v walker.Visitor) {
n.Method.Walk(vv) n.Method.Walk(vv)
} }
if n.Arguments != nil { if n.ArgumentList != nil {
vv := v.GetChildrenVisitor("Arguments") vv := v.GetChildrenVisitor("ArgumentList")
for _, nn := range n.Arguments { n.ArgumentList.Walk(vv)
if nn != nil {
nn.Walk(vv)
}
}
} }
v.LeaveNode(n) v.LeaveNode(n)

View File

@ -7,15 +7,15 @@ import (
// New node // New node
type New struct { type New struct {
Class node.Node Class node.Node
Arguments []node.Node ArgumentList *node.ArgumentList
} }
// NewNew node constructor // NewNew node constructor
func NewNew(Class node.Node, Arguments []node.Node) *New { func NewNew(Class node.Node, ArgumentList *node.ArgumentList) *New {
return &New{ return &New{
Class, Class,
Arguments, ArgumentList,
} }
} }
@ -36,13 +36,9 @@ func (n *New) Walk(v walker.Visitor) {
n.Class.Walk(vv) n.Class.Walk(vv)
} }
if n.Arguments != nil { if n.ArgumentList != nil {
vv := v.GetChildrenVisitor("Arguments") vv := v.GetChildrenVisitor("ArgumentList")
for _, nn := range n.Arguments { n.ArgumentList.Walk(vv)
if nn != nil {
nn.Walk(vv)
}
}
} }
v.LeaveNode(n) v.LeaveNode(n)

View File

@ -7,17 +7,17 @@ import (
// StaticCall node // StaticCall node
type StaticCall struct { type StaticCall struct {
Class node.Node Class node.Node
Call node.Node Call node.Node
Arguments []node.Node ArgumentList *node.ArgumentList
} }
// NewStaticCall node constructor // NewStaticCall node constructor
func NewStaticCall(Class node.Node, Call node.Node, Arguments []node.Node) *StaticCall { func NewStaticCall(Class node.Node, Call node.Node, ArgumentList *node.ArgumentList) *StaticCall {
return &StaticCall{ return &StaticCall{
Class, Class,
Call, Call,
Arguments, ArgumentList,
} }
} }
@ -43,13 +43,9 @@ func (n *StaticCall) Walk(v walker.Visitor) {
n.Call.Walk(vv) n.Call.Walk(vv)
} }
if n.Arguments != nil { if n.ArgumentList != nil {
vv := v.GetChildrenVisitor("Arguments") vv := v.GetChildrenVisitor("ArgumentList")
for _, nn := range n.Arguments { n.ArgumentList.Walk(vv)
if nn != nil {
nn.Walk(vv)
}
}
} }
v.LeaveNode(n) v.LeaveNode(n)

View File

@ -29,7 +29,7 @@ func TestFunctionCall(t *testing.T) {
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},
}, },
}, },
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
@ -58,7 +58,7 @@ func TestFunctionCallRelative(t *testing.T) {
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},
}, },
}, },
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
@ -87,12 +87,14 @@ func TestFunctionFullyQualified(t *testing.T) {
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},
}, },
}, },
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{ Arguments: []node.Node{
Variadic: false, &node.Argument{
IsReference: false, Variadic: false,
Expr: &expr.ShortArray{ IsReference: false,
Items: []node.Node{}, Expr: &expr.ShortArray{
Items: []node.Node{},
},
}, },
}, },
}, },
@ -120,12 +122,14 @@ func TestFunctionCallVar(t *testing.T) {
&stmt.Expression{ &stmt.Expression{
Expr: &expr.FunctionCall{ Expr: &expr.FunctionCall{
Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{ Arguments: []node.Node{
Variadic: false, &node.Argument{
IsReference: false, Variadic: false,
Expr: &expr.Yield{ IsReference: false,
Value: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, Expr: &expr.Yield{
Value: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
}, },
}, },
}, },
@ -157,13 +161,15 @@ func TestFunctionCallExprArg(t *testing.T) {
&name.NamePart{Value: "ceil"}, &name.NamePart{Value: "ceil"},
}, },
}, },
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{ Arguments: []node.Node{
Variadic: false, &node.Argument{
IsReference: false, Variadic: false,
Expr: &binary.Div{ IsReference: false,
Left: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Expr: &binary.Div{
Right: &scalar.Lnumber{Value: "3"}, Left: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Right: &scalar.Lnumber{Value: "3"},
},
}, },
}, },
}, },

View File

@ -19,9 +19,9 @@ func TestMethodCall(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &expr.MethodCall{ Expr: &expr.MethodCall{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
Method: &node.Identifier{Value: "foo"}, Method: &node.Identifier{Value: "foo"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },

View File

@ -54,7 +54,7 @@ func TestNewRelative(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
@ -83,7 +83,7 @@ func TestNewFullyQualified(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
@ -109,9 +109,11 @@ func TestNewAnonymous(t *testing.T) {
Expr: &expr.New{ Expr: &expr.New{
Class: &stmt.Class{ Class: &stmt.Class{
PhpDocComment: "", PhpDocComment: "",
Args: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
Stmts: []node.Node{}, Stmts: []node.Node{},
}, },

View File

@ -26,8 +26,8 @@ func TestStaticCall(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
@ -56,8 +56,8 @@ func TestStaticCallRelative(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
@ -86,8 +86,8 @@ func TestStaticCallFullyQualified(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
@ -116,8 +116,8 @@ func TestStaticCallVar(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
@ -141,9 +141,9 @@ func TestStaticCallVarVar(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &expr.StaticCall{ Expr: &expr.StaticCall{
Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },

View File

@ -146,10 +146,10 @@ var nodesToTest = []struct {
}, },
{ {
&expr.FunctionCall{ &expr.FunctionCall{
Function: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, Function: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
Arguments: []node.Node{&node.Argument{}}, ArgumentList: &node.ArgumentList{},
}, },
[]string{"Function", "Arguments"}, []string{"Function", "ArgumentList"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
@ -194,19 +194,19 @@ var nodesToTest = []struct {
}, },
{ {
&expr.MethodCall{ &expr.MethodCall{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
Method: &node.Identifier{Value: "foo"}, Method: &node.Identifier{Value: "foo"},
Arguments: []node.Node{&node.Argument{}}, ArgumentList: &node.ArgumentList{},
}, },
[]string{"Variable", "Method", "Arguments"}, []string{"Variable", "Method", "ArgumentList"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&expr.New{ &expr.New{
Class: &name.Name{}, Class: &name.Name{},
Arguments: []node.Node{&node.Argument{}}, ArgumentList: &node.ArgumentList{},
}, },
[]string{"Class", "Arguments"}, []string{"Class", "ArgumentList"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
@ -295,11 +295,11 @@ var nodesToTest = []struct {
}, },
{ {
&expr.StaticCall{ &expr.StaticCall{
Class: &name.Name{}, Class: &name.Name{},
Call: &node.Identifier{Value: "foo"}, Call: &node.Identifier{Value: "foo"},
Arguments: []node.Node{&node.Argument{}}, ArgumentList: &node.ArgumentList{},
}, },
[]string{"Class", "Call", "Arguments"}, []string{"Class", "Call", "ArgumentList"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {

41
node/n_argument_list.go Normal file
View File

@ -0,0 +1,41 @@
package node
import (
"github.com/z7zmey/php-parser/walker"
)
// ArgumentList node
type ArgumentList struct {
Arguments []Node
}
// NewArgumentList node constructor
func NewArgumentList(Arguments []Node) *ArgumentList {
return &ArgumentList{
Arguments,
}
}
// Attributes returns node attributes as map
func (n *ArgumentList) Attributes() map[string]interface{} {
return nil
}
// Walk traverses nodes
// Walk is invoked recursively until v.EnterNode returns true
func (n *ArgumentList) Walk(v walker.Visitor) {
if v.EnterNode(n) == false {
return
}
if n.Arguments != nil {
vv := v.GetChildrenVisitor("Arguments")
for _, nn := range n.Arguments {
if nn != nil {
nn.Walk(vv)
}
}
}
v.LeaveNode(n)
}

View File

@ -38,7 +38,7 @@ func TestName(t *testing.T) {
Function: &name.Name{ Function: &name.Name{
Parts: []node.Node{&name.NamePart{Value: "foo"}}, Parts: []node.Node{&name.NamePart{Value: "foo"}},
}, },
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
@ -65,7 +65,7 @@ func TestFullyQualified(t *testing.T) {
Function: &name.FullyQualified{ Function: &name.FullyQualified{
Parts: []node.Node{&name.NamePart{Value: "foo"}}, Parts: []node.Node{&name.NamePart{Value: "foo"}},
}, },
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
@ -92,7 +92,7 @@ func TestRelative(t *testing.T) {
Function: &name.Relative{ Function: &name.Relative{
Parts: []node.Node{&name.NamePart{Value: "foo"}}, Parts: []node.Node{&name.NamePart{Value: "foo"}},
}, },
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },

View File

@ -221,9 +221,9 @@ func TestCurlyOpenMethodCall(t *testing.T) {
Parts: []node.Node{ Parts: []node.Node{
&scalar.EncapsedStringPart{Value: "test "}, &scalar.EncapsedStringPart{Value: "test "},
&expr.MethodCall{ &expr.MethodCall{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Method: &node.Identifier{Value: "bar"}, Method: &node.Identifier{Value: "bar"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },

View File

@ -10,19 +10,19 @@ type Class struct {
PhpDocComment string PhpDocComment string
ClassName node.Node ClassName node.Node
Modifiers []node.Node Modifiers []node.Node
Args []node.Node ArgumentList *node.ArgumentList
Extends node.Node Extends node.Node
Implements []node.Node Implements []node.Node
Stmts []node.Node Stmts []node.Node
} }
// NewClass node constructor // NewClass node constructor
func NewClass(ClassName node.Node, Modifiers []node.Node, Args []node.Node, Extends node.Node, Implements []node.Node, Stmts []node.Node, PhpDocComment string) *Class { func NewClass(ClassName node.Node, Modifiers []node.Node, ArgumentList *node.ArgumentList, Extends node.Node, Implements []node.Node, Stmts []node.Node, PhpDocComment string) *Class {
return &Class{ return &Class{
PhpDocComment, PhpDocComment,
ClassName, ClassName,
Modifiers, Modifiers,
Args, ArgumentList,
Extends, Extends,
Implements, Implements,
Stmts, Stmts,
@ -57,13 +57,9 @@ func (n *Class) Walk(v walker.Visitor) {
} }
} }
if n.Args != nil { if n.ArgumentList != nil {
vv := v.GetChildrenVisitor("Args") vv := v.GetChildrenVisitor("ArgumentList")
for _, nn := range n.Args { n.ArgumentList.Walk(vv)
if nn != nil {
nn.Walk(vv)
}
}
} }
if n.Extends != nil { if n.Extends != nil {

View File

@ -2,9 +2,10 @@ package stmt_test
import ( import (
"bytes" "bytes"
"testing"
"github.com/z7zmey/php-parser/node/expr" "github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/name" "github.com/z7zmey/php-parser/node/name"
"testing"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/stmt" "github.com/z7zmey/php-parser/node/stmt"
@ -171,7 +172,7 @@ func TestAnonimousClass(t *testing.T) {
&stmt.Expression{ &stmt.Expression{
Expr: &expr.New{ Expr: &expr.New{
Class: &stmt.Class{ Class: &stmt.Class{
Args: []node.Node{}, ArgumentList: &node.ArgumentList{},
Extends: &name.Name{ Extends: &name.Name{
Parts: []node.Node{ Parts: []node.Node{
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},

View File

@ -53,7 +53,7 @@ func TestGlobalVars(t *testing.T) {
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},
}, },
}, },
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },

View File

@ -92,12 +92,12 @@ var nodesToTest = []struct {
PhpDocComment: "/** */", PhpDocComment: "/** */",
ClassName: &node.Identifier{}, ClassName: &node.Identifier{},
Modifiers: []node.Node{&stmt.Expression{}}, Modifiers: []node.Node{&stmt.Expression{}},
Args: []node.Node{&stmt.Expression{}}, ArgumentList: &node.ArgumentList{},
Extends: &node.Identifier{}, Extends: &node.Identifier{},
Implements: []node.Node{&stmt.Expression{}}, Implements: []node.Node{&stmt.Expression{}},
Stmts: []node.Node{&stmt.Expression{}}, Stmts: []node.Node{&stmt.Expression{}},
}, },
[]string{"ClassName", "Modifiers", "Args", "Extends", "Implements", "Stmts"}, []string{"ClassName", "Modifiers", "ArgumentList", "Extends", "Implements", "Stmts"},
map[string]interface{}{"PhpDocComment": "/** */"}, map[string]interface{}{"PhpDocComment": "/** */"},
}, },
{ {

View File

@ -70,18 +70,22 @@ func TestPhp7ArgumentNode(t *testing.T) {
&stmt.Expression{ &stmt.Expression{
Expr: &expr.FunctionCall{ Expr: &expr.FunctionCall{
Function: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, Function: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.FunctionCall{ Expr: &expr.FunctionCall{
Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
@ -89,9 +93,11 @@ func TestPhp7ArgumentNode(t *testing.T) {
Expr: &expr.MethodCall{ Expr: &expr.MethodCall{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Method: &node.Identifier{Value: "bar"}, Method: &node.Identifier{Value: "bar"},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
@ -99,9 +105,11 @@ func TestPhp7ArgumentNode(t *testing.T) {
Expr: &expr.StaticCall{ Expr: &expr.StaticCall{
Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}},
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
@ -109,18 +117,22 @@ func TestPhp7ArgumentNode(t *testing.T) {
Expr: &expr.StaticCall{ Expr: &expr.StaticCall{
Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.New{ Expr: &expr.New{
Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
@ -128,9 +140,11 @@ func TestPhp7ArgumentNode(t *testing.T) {
Expr: &expr.New{ Expr: &expr.New{
Class: &stmt.Class{ Class: &stmt.Class{
PhpDocComment: "/** anonymous class */", PhpDocComment: "/** anonymous class */",
Args: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
Stmts: []node.Node{}, Stmts: []node.Node{},
}, },
@ -160,18 +174,22 @@ func TestPhp5ArgumentNode(t *testing.T) {
&stmt.Expression{ &stmt.Expression{
Expr: &expr.FunctionCall{ Expr: &expr.FunctionCall{
Function: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, Function: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.FunctionCall{ Expr: &expr.FunctionCall{
Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
@ -179,9 +197,11 @@ func TestPhp5ArgumentNode(t *testing.T) {
Expr: &expr.MethodCall{ Expr: &expr.MethodCall{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Method: &node.Identifier{Value: "bar"}, Method: &node.Identifier{Value: "bar"},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
@ -189,9 +209,11 @@ func TestPhp5ArgumentNode(t *testing.T) {
Expr: &expr.StaticCall{ Expr: &expr.StaticCall{
Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}},
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
@ -199,18 +221,22 @@ func TestPhp5ArgumentNode(t *testing.T) {
Expr: &expr.StaticCall{ Expr: &expr.StaticCall{
Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.New{ Expr: &expr.New{
Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },

View File

@ -44,6 +44,15 @@ var nodesToTest = []struct {
[]string{"VariableType", "Variable", "DefaultValue"}, []string{"VariableType", "Variable", "DefaultValue"},
map[string]interface{}{"ByRef": false, "Variadic": true}, map[string]interface{}{"ByRef": false, "Variadic": true},
}, },
{
&node.ArgumentList{
Arguments: []node.Node{
&node.Argument{},
},
},
[]string{"Arguments"},
map[string]interface{}{},
},
} }
type visitorMock struct { type visitorMock struct {

File diff suppressed because it is too large Load Diff

View File

@ -242,6 +242,7 @@ import (
%type <node> trait_use_statement function_call_parameter trait_adaptation_statement trait_precedence trait_alias %type <node> trait_use_statement function_call_parameter trait_adaptation_statement trait_precedence trait_alias
%type <node> trait_method_reference_fully_qualified trait_method_reference trait_modifiers member_modifier method %type <node> trait_method_reference_fully_qualified trait_method_reference trait_modifiers member_modifier method
%type <node> static_scalar_value static_operation %type <node> static_scalar_value static_operation
%type <node> ctor_arguments function_call_parameter_list
%type <list> top_statement_list namespace_name use_declarations use_function_declarations use_const_declarations %type <list> top_statement_list namespace_name use_declarations use_function_declarations use_const_declarations
%type <list> inner_statement_list global_var_list static_var_list encaps_list isset_variables non_empty_array_pair_list %type <list> inner_statement_list global_var_list static_var_list encaps_list isset_variables non_empty_array_pair_list
@ -258,7 +259,7 @@ import (
%type <simpleIndirectReference> simple_indirect_reference %type <simpleIndirectReference> simple_indirect_reference
%type <foreachVariable> foreach_variable foreach_optional_arg %type <foreachVariable> foreach_variable foreach_optional_arg
%type <nodesWithEndToken> ctor_arguments function_call_parameter_list switch_case_list method_body trait_adaptations %type <nodesWithEndToken> switch_case_list method_body trait_adaptations
%type <boolWithToken> is_reference is_variadic %type <boolWithToken> is_reference is_variadic
%type <altSyntaxNode> while_statement for_statement foreach_statement %type <altSyntaxNode> while_statement for_statement foreach_statement
@ -1349,16 +1350,27 @@ optional_class_type:
function_call_parameter_list: function_call_parameter_list:
'(' ')' '(' ')'
{ $$ = &nodesWithEndToken{[]node.Node{}, $2} } {
$$ = node.NewArgumentList(nil)
// save position
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2))
}
| '(' non_empty_function_call_parameter_list ')' | '(' non_empty_function_call_parameter_list ')'
{ $$ = &nodesWithEndToken{$2, $3} } {
$$ = node.NewArgumentList($2)
// save position
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3))
}
| '(' yield_expr ')' | '(' yield_expr ')'
{ {
arg := node.NewArgument($2, false, false) arg := node.NewArgument($2, false, false)
yylex.(*Parser).positions.AddPosition(arg, yylex.(*Parser).positionBuilder.NewNodePosition($2)) $$ = node.NewArgumentList([]node.Node{arg})
yylex.(*Parser).comments.AddComments(arg, yylex.(*Parser).comments[$2])
$$ = &nodesWithEndToken{[]node.Node{arg}, $3} // save position
yylex.(*Parser).positions.AddPosition(arg, yylex.(*Parser).positionBuilder.NewNodePosition($2))
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3))
} }
; ;
@ -1886,9 +1898,10 @@ instance_call:
new_expr: new_expr:
T_NEW class_name_reference ctor_arguments T_NEW class_name_reference ctor_arguments
{ {
if $3 != nil { if $3 != nil {
$$ = expr.NewNew($2, $3.nodes) $$ = expr.NewNew($2, $3.(*node.ArgumentList))
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3.endToken)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3))
} else { } else {
$$ = expr.NewNew($2, nil) $$ = expr.NewNew($2, nil)
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $2))
@ -1923,12 +1936,14 @@ expr_without_variable:
} }
| variable '=' '&' T_NEW class_name_reference ctor_arguments | variable '=' '&' T_NEW class_name_reference ctor_arguments
{ {
_new := expr.NewNew($5, nil) var _new *expr.New
yylex.(*Parser).positions.AddPosition(_new, yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $5))
if $6 != nil { if $6 != nil {
_new = expr.NewNew($5, $6.nodes) _new = expr.NewNew($5, $6.(*node.ArgumentList))
yylex.(*Parser).positions.AddPosition(_new, yylex.(*Parser).positionBuilder.NewTokensPosition($4, $6.endToken)) yylex.(*Parser).positions.AddPosition(_new, yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $6))
} else {
_new = expr.NewNew($5, nil)
yylex.(*Parser).positions.AddPosition(_new, yylex.(*Parser).positionBuilder.NewTokenNodePosition($4, $5))
} }
yylex.(*Parser).comments.AddComments(_new, yylex.(*Parser).comments[$1]) yylex.(*Parser).comments.AddComments(_new, yylex.(*Parser).comments[$1])
@ -2519,8 +2534,8 @@ function_call:
yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewNodeListPosition($1))
yylex.(*Parser).comments.AddComments(name, yylex.(*Parser).listGetFirstNodeComments($1)) yylex.(*Parser).comments.AddComments(name, yylex.(*Parser).listGetFirstNodeComments($1))
$$ = expr.NewFunctionCall(name, $2.nodes) $$ = expr.NewFunctionCall(name, $2.(*node.ArgumentList))
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(name, $2.endToken)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition(name, $2))
yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[name]) yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[name])
} }
| T_NAMESPACE T_NS_SEPARATOR namespace_name function_call_parameter_list | T_NAMESPACE T_NS_SEPARATOR namespace_name function_call_parameter_list
@ -2529,8 +2544,8 @@ function_call:
yylex.(*Parser).positions.AddPosition(funcName, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3)) yylex.(*Parser).positions.AddPosition(funcName, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $3))
yylex.(*Parser).comments.AddComments(funcName, $1.Comments()) yylex.(*Parser).comments.AddComments(funcName, $1.Comments())
$$ = expr.NewFunctionCall(funcName, $4.nodes) $$ = expr.NewFunctionCall(funcName, $4.(*node.ArgumentList))
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(funcName, $4.endToken)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition(funcName, $4))
yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[funcName]) yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[funcName])
} }
| T_NS_SEPARATOR namespace_name function_call_parameter_list | T_NS_SEPARATOR namespace_name function_call_parameter_list
@ -2539,38 +2554,38 @@ function_call:
yylex.(*Parser).positions.AddPosition(funcName, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2)) yylex.(*Parser).positions.AddPosition(funcName, yylex.(*Parser).positionBuilder.NewTokenNodeListPosition($1, $2))
yylex.(*Parser).comments.AddComments(funcName, $1.Comments()) yylex.(*Parser).comments.AddComments(funcName, $1.Comments())
$$ = expr.NewFunctionCall(funcName, $3.nodes) $$ = expr.NewFunctionCall(funcName, $3.(*node.ArgumentList))
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition(funcName, $3.endToken)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition(funcName, $3))
yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[funcName]) yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[funcName])
} }
| class_name T_PAAMAYIM_NEKUDOTAYIM variable_name function_call_parameter_list | class_name T_PAAMAYIM_NEKUDOTAYIM variable_name function_call_parameter_list
{ {
$$ = expr.NewStaticCall($1, $3, $4.nodes) $$ = expr.NewStaticCall($1, $3, $4.(*node.ArgumentList))
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4.endToken)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4))
yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[$1]) yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[$1])
} }
| class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects function_call_parameter_list | class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects function_call_parameter_list
{ {
$$ = expr.NewStaticCall($1, $3, $4.nodes) $$ = expr.NewStaticCall($1, $3, $4.(*node.ArgumentList))
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4.endToken)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4))
yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[$1]) yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[$1])
} }
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_name function_call_parameter_list | variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_name function_call_parameter_list
{ {
$$ = expr.NewStaticCall($1, $3, $4.nodes) $$ = expr.NewStaticCall($1, $3, $4.(*node.ArgumentList))
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4.endToken)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4))
yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[$1]) yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[$1])
} }
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects function_call_parameter_list | variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects function_call_parameter_list
{ {
$$ = expr.NewStaticCall($1, $3, $4.nodes) $$ = expr.NewStaticCall($1, $3, $4.(*node.ArgumentList))
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4.endToken)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4))
yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[$1]) yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[$1])
} }
| variable_without_objects function_call_parameter_list | variable_without_objects function_call_parameter_list
{ {
$$ = expr.NewFunctionCall($1, $2.nodes) $$ = expr.NewFunctionCall($1, $2.(*node.ArgumentList))
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2.endToken)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $2))
yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[$1]) yylex.(*Parser).comments.AddComments($$, yylex.(*Parser).comments[$1])
} }
; ;
@ -3311,8 +3326,8 @@ array_method_dereference:
method: method:
function_call_parameter_list function_call_parameter_list
{ {
$$ = expr.NewMethodCall(nil, nil, $1.nodes) $$ = expr.NewMethodCall(nil, nil, $1.(*node.ArgumentList))
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeListTokenPosition($1.nodes, $1.endToken)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodePosition($1))
} }
; ;

View File

@ -434,18 +434,22 @@ func TestPhp5(t *testing.T) {
&stmt.Expression{ &stmt.Expression{
Expr: &expr.FunctionCall{ Expr: &expr.FunctionCall{
Function: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, Function: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.FunctionCall{ Expr: &expr.FunctionCall{
Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
@ -453,9 +457,11 @@ func TestPhp5(t *testing.T) {
Expr: &expr.MethodCall{ Expr: &expr.MethodCall{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Method: &node.Identifier{Value: "bar"}, Method: &node.Identifier{Value: "bar"},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
@ -463,9 +469,11 @@ func TestPhp5(t *testing.T) {
Expr: &expr.StaticCall{ Expr: &expr.StaticCall{
Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}},
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
@ -473,18 +481,22 @@ func TestPhp5(t *testing.T) {
Expr: &expr.StaticCall{ Expr: &expr.StaticCall{
Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.New{ Expr: &expr.New{
Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
@ -665,9 +677,9 @@ func TestPhp5(t *testing.T) {
Parts: []node.Node{ Parts: []node.Node{
&scalar.EncapsedStringPart{Value: "test "}, &scalar.EncapsedStringPart{Value: "test "},
&expr.MethodCall{ &expr.MethodCall{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Method: &node.Identifier{Value: "bar"}, Method: &node.Identifier{Value: "bar"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
@ -1134,7 +1146,7 @@ func TestPhp5(t *testing.T) {
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},
}, },
}, },
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
@ -2081,7 +2093,7 @@ func TestPhp5(t *testing.T) {
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},
}, },
}, },
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2091,11 +2103,13 @@ func TestPhp5(t *testing.T) {
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},
}, },
}, },
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{ Arguments: []node.Node{
Variadic: false, &node.Argument{
IsReference: true, Variadic: false,
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, IsReference: true,
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
}, },
}, },
}, },
@ -2107,12 +2121,14 @@ func TestPhp5(t *testing.T) {
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},
}, },
}, },
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{ Arguments: []node.Node{
Variadic: false, &node.Argument{
IsReference: false, Variadic: false,
Expr: &expr.ShortArray{ IsReference: false,
Items: []node.Node{}, Expr: &expr.ShortArray{
Items: []node.Node{},
},
}, },
}, },
}, },
@ -2121,12 +2137,14 @@ func TestPhp5(t *testing.T) {
&stmt.Expression{ &stmt.Expression{
Expr: &expr.FunctionCall{ Expr: &expr.FunctionCall{
Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{ Arguments: []node.Node{
Variadic: false, &node.Argument{
IsReference: false, Variadic: false,
Expr: &expr.Yield{ IsReference: false,
Value: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, Expr: &expr.Yield{
Value: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
}, },
}, },
}, },
@ -2281,9 +2299,9 @@ func TestPhp5(t *testing.T) {
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.MethodCall{ Expr: &expr.MethodCall{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
Method: &node.Identifier{Value: "foo"}, Method: &node.Identifier{Value: "foo"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2302,7 +2320,7 @@ func TestPhp5(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2312,7 +2330,7 @@ func TestPhp5(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2346,8 +2364,8 @@ func TestPhp5(t *testing.T) {
}, },
Property: &node.Identifier{Value: "bar"}, Property: &node.Identifier{Value: "bar"},
}, },
Method: &node.Identifier{Value: "baz"}, Method: &node.Identifier{Value: "baz"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
Property: &node.Identifier{Value: "quux"}, Property: &node.Identifier{Value: "quux"},
}, },
@ -2358,9 +2376,9 @@ func TestPhp5(t *testing.T) {
Expr: &expr.ArrayDimFetch{ Expr: &expr.ArrayDimFetch{
Variable: &expr.ArrayDimFetch{ Variable: &expr.ArrayDimFetch{
Variable: &expr.MethodCall{ Variable: &expr.MethodCall{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
Method: &node.Identifier{Value: "foo"}, Method: &node.Identifier{Value: "foo"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
Dim: &scalar.Lnumber{Value: "1"}, Dim: &scalar.Lnumber{Value: "1"},
}, },
@ -2424,8 +2442,8 @@ func TestPhp5(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2435,8 +2453,8 @@ func TestPhp5(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2446,8 +2464,8 @@ func TestPhp5(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2457,15 +2475,15 @@ func TestPhp5(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.StaticCall{ Expr: &expr.StaticCall{
Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2815,11 +2833,13 @@ func TestPhp5(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{ Arguments: []node.Node{
Variadic: false, &node.Argument{
IsReference: false, Variadic: false,
Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, IsReference: false,
Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}},
},
}, },
}, },
}, },
@ -2910,7 +2930,7 @@ func TestPhp5(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2922,10 +2942,10 @@ func TestPhp5(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
Method: &node.Identifier{Value: "bar"}, Method: &node.Identifier{Value: "bar"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
Property: &node.Identifier{Value: "baz"}, Property: &node.Identifier{Value: "baz"},
}, },
@ -2939,7 +2959,7 @@ func TestPhp5(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
Dim: &scalar.Lnumber{Value: "0"}, Dim: &scalar.Lnumber{Value: "0"},
}, },
@ -2955,12 +2975,12 @@ func TestPhp5(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
Dim: &scalar.Lnumber{Value: "0"}, Dim: &scalar.Lnumber{Value: "0"},
}, },
Method: &node.Identifier{Value: "bar"}, Method: &node.Identifier{Value: "bar"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -3574,16 +3594,16 @@ func TestPhp5(t *testing.T) {
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.FunctionCall{ Expr: &expr.FunctionCall{
Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.ArrayDimFetch{ Expr: &expr.ArrayDimFetch{
Variable: &expr.ArrayDimFetch{ Variable: &expr.ArrayDimFetch{
Variable: &expr.FunctionCall{ Variable: &expr.FunctionCall{
Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
Dim: &scalar.Lnumber{Value: "0"}, Dim: &scalar.Lnumber{Value: "0"},
}, },
@ -3601,9 +3621,9 @@ func TestPhp5(t *testing.T) {
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.StaticCall{ Expr: &expr.StaticCall{
Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -402,18 +402,22 @@ func TestPhp7(t *testing.T) {
&stmt.Expression{ &stmt.Expression{
Expr: &expr.FunctionCall{ Expr: &expr.FunctionCall{
Function: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, Function: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.FunctionCall{ Expr: &expr.FunctionCall{
Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
@ -421,9 +425,11 @@ func TestPhp7(t *testing.T) {
Expr: &expr.MethodCall{ Expr: &expr.MethodCall{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Method: &node.Identifier{Value: "bar"}, Method: &node.Identifier{Value: "bar"},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
@ -431,9 +437,11 @@ func TestPhp7(t *testing.T) {
Expr: &expr.StaticCall{ Expr: &expr.StaticCall{
Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}},
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
@ -441,18 +449,22 @@ func TestPhp7(t *testing.T) {
Expr: &expr.StaticCall{ Expr: &expr.StaticCall{
Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.New{ Expr: &expr.New{
Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
}, },
}, },
@ -460,9 +472,11 @@ func TestPhp7(t *testing.T) {
Expr: &expr.New{ Expr: &expr.New{
Class: &stmt.Class{ Class: &stmt.Class{
PhpDocComment: "/** anonymous class */", PhpDocComment: "/** anonymous class */",
Args: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, Arguments: []node.Node{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
Stmts: []node.Node{}, Stmts: []node.Node{},
}, },
@ -730,9 +744,10 @@ func TestPhp7(t *testing.T) {
Parts: []node.Node{ Parts: []node.Node{
&scalar.EncapsedStringPart{Value: "test "}, &scalar.EncapsedStringPart{Value: "test "},
&expr.MethodCall{ &expr.MethodCall{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Method: &node.Identifier{Value: "bar"}, Method: &node.Identifier{Value: "bar"},
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
@ -945,7 +960,8 @@ func TestPhp7(t *testing.T) {
&stmt.Expression{ &stmt.Expression{
Expr: &expr.New{ Expr: &expr.New{
Class: &stmt.Class{ Class: &stmt.Class{
Args: []node.Node{},
ArgumentList: &node.ArgumentList{},
Extends: &name.Name{ Extends: &name.Name{
Parts: []node.Node{ Parts: []node.Node{
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},
@ -2168,7 +2184,8 @@ func TestPhp7(t *testing.T) {
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},
}, },
}, },
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2178,7 +2195,8 @@ func TestPhp7(t *testing.T) {
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},
}, },
}, },
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2188,13 +2206,15 @@ func TestPhp7(t *testing.T) {
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},
}, },
}, },
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.FunctionCall{ Expr: &expr.FunctionCall{
Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Function: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2325,9 +2345,10 @@ func TestPhp7(t *testing.T) {
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.MethodCall{ Expr: &expr.MethodCall{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
Method: &node.Identifier{Value: "foo"}, Method: &node.Identifier{Value: "foo"},
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2337,7 +2358,8 @@ func TestPhp7(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2347,7 +2369,8 @@ func TestPhp7(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2357,16 +2380,20 @@ func TestPhp7(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.New{ Expr: &expr.New{
Class: &stmt.Class{ Class: &stmt.Class{
PhpDocComment: "", PhpDocComment: "",
Args: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, ArgumentList: &node.ArgumentList{
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
},
}, },
Stmts: []node.Node{}, Stmts: []node.Node{},
}, },
@ -2488,8 +2515,9 @@ func TestPhp7(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2499,8 +2527,9 @@ func TestPhp7(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2510,8 +2539,9 @@ func TestPhp7(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2931,7 +2961,8 @@ func TestPhp7(t *testing.T) {
&name.NamePart{Value: "bar"}, &name.NamePart{Value: "bar"},
}, },
}, },
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Function{ &stmt.Function{
@ -3048,7 +3079,8 @@ func TestPhp7(t *testing.T) {
Function: &expr.New{ Function: &expr.New{
Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}},
}, },
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -3064,7 +3096,8 @@ func TestPhp7(t *testing.T) {
}, },
Dim: &scalar.Lnumber{Value: "0"}, Dim: &scalar.Lnumber{Value: "0"},
}, },
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -3075,13 +3108,15 @@ func TestPhp7(t *testing.T) {
}, },
Dim: &scalar.Lnumber{Value: "1"}, Dim: &scalar.Lnumber{Value: "1"},
}, },
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.FunctionCall{ Expr: &expr.FunctionCall{
Function: &scalar.String{Value: "\"foo\""}, Function: &scalar.String{Value: "\"foo\""},
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -3097,22 +3132,25 @@ func TestPhp7(t *testing.T) {
}, },
Dim: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Dim: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
}, },
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.Variable{ Expr: &expr.Variable{
VarName: &expr.FunctionCall{ VarName: &expr.FunctionCall{
Function: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}}, Function: &name.Name{Parts: []node.Node{&name.NamePart{Value: "foo"}}},
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.StaticCall{ Expr: &expr.StaticCall{
Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}},
Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}},
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -3122,7 +3160,8 @@ func TestPhp7(t *testing.T) {
Variable: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "bar"}},
Dim: &scalar.Lnumber{Value: "0"}, Dim: &scalar.Lnumber{Value: "0"},
}, },
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{

View File

@ -1097,7 +1097,7 @@ func (p *Printer) printExprFunctionCall(n node.Node) {
p.Print(nn.Function) p.Print(nn.Function)
io.WriteString(p.w, "(") io.WriteString(p.w, "(")
p.joinPrint(", ", nn.Arguments) p.joinPrint(", ", nn.ArgumentList.Arguments)
io.WriteString(p.w, ")") io.WriteString(p.w, ")")
} }
@ -1146,7 +1146,7 @@ func (p *Printer) printExprMethodCall(n node.Node) {
io.WriteString(p.w, "->") io.WriteString(p.w, "->")
p.Print(nn.Method) p.Print(nn.Method)
io.WriteString(p.w, "(") io.WriteString(p.w, "(")
p.joinPrint(", ", nn.Arguments) p.joinPrint(", ", nn.ArgumentList.Arguments)
io.WriteString(p.w, ")") io.WriteString(p.w, ")")
} }
@ -1156,9 +1156,9 @@ func (p *Printer) printExprNew(n node.Node) {
io.WriteString(p.w, "new ") io.WriteString(p.w, "new ")
p.Print(nn.Class) p.Print(nn.Class)
if nn.Arguments != nil { if nn.ArgumentList != nil {
io.WriteString(p.w, "(") io.WriteString(p.w, "(")
p.joinPrint(", ", nn.Arguments) p.joinPrint(", ", nn.ArgumentList.Arguments)
io.WriteString(p.w, ")") io.WriteString(p.w, ")")
} }
} }
@ -1254,7 +1254,7 @@ func (p *Printer) printExprStaticCall(n node.Node) {
io.WriteString(p.w, "::") io.WriteString(p.w, "::")
p.Print(nn.Call) p.Print(nn.Call)
io.WriteString(p.w, "(") io.WriteString(p.w, "(")
p.joinPrint(", ", nn.Arguments) p.joinPrint(", ", nn.ArgumentList.Arguments)
io.WriteString(p.w, ")") io.WriteString(p.w, ")")
} }
@ -1536,9 +1536,9 @@ func (p *Printer) printStmtClass(n node.Node) {
p.Print(nn.ClassName) p.Print(nn.ClassName)
} }
if nn.Args != nil { if nn.ArgumentList != nil {
io.WriteString(p.w, "(") io.WriteString(p.w, "(")
p.joinPrint(", ", nn.Args) p.joinPrint(", ", nn.ArgumentList.Arguments)
io.WriteString(p.w, ")") io.WriteString(p.w, ")")
} }

View File

@ -1522,17 +1522,19 @@ func TestPrintFunctionCall(t *testing.T) {
p := printer.NewPrinter(o, " ") p := printer.NewPrinter(o, " ")
p.Print(&expr.FunctionCall{ p.Print(&expr.FunctionCall{
Function: &expr.Variable{VarName: &node.Identifier{Value: "var"}}, Function: &expr.Variable{VarName: &node.Identifier{Value: "var"}},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{ Arguments: []node.Node{
IsReference: true, &node.Argument{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, IsReference: true,
}, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
&node.Argument{ },
Variadic: true, &node.Argument{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, Variadic: true,
}, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}},
&node.Argument{ },
Expr: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, &node.Argument{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "c"}},
},
}, },
}, },
}) })
@ -1648,12 +1650,14 @@ func TestPrintMethodCall(t *testing.T) {
p.Print(&expr.MethodCall{ p.Print(&expr.MethodCall{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Method: &node.Identifier{Value: "bar"}, Method: &node.Identifier{Value: "bar"},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{ Arguments: []node.Node{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, &node.Argument{
}, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
&node.Argument{ },
Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, &node.Argument{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}},
},
}, },
}, },
}) })
@ -1672,12 +1676,14 @@ func TestPrintNew(t *testing.T) {
p := printer.NewPrinter(o, " ") p := printer.NewPrinter(o, " ")
p.Print(&expr.New{ p.Print(&expr.New{
Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}}, Class: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{ Arguments: []node.Node{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, &node.Argument{
}, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
&node.Argument{ },
Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, &node.Argument{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}},
},
}, },
}, },
}) })
@ -1901,12 +1907,14 @@ func TestPrintStaticCall(t *testing.T) {
p.Print(&expr.StaticCall{ p.Print(&expr.StaticCall{
Class: &node.Identifier{Value: "Foo"}, Class: &node.Identifier{Value: "Foo"},
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{ Arguments: []node.Node{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, &node.Argument{
}, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
&node.Argument{ },
Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, &node.Argument{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}},
},
}, },
}, },
}) })
@ -2509,12 +2517,14 @@ func TestPrintStmtAnonymousClass(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Class{ &stmt.Class{
Modifiers: []node.Node{&node.Identifier{Value: "abstract"}}, Modifiers: []node.Node{&node.Identifier{Value: "abstract"}},
Args: []node.Node{ ArgumentList: &node.ArgumentList{
&node.Argument{ Arguments: []node.Node{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, &node.Argument{
}, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
&node.Argument{ },
Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, &node.Argument{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}},
},
}, },
}, },
Extends: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}}, Extends: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}},

View File

@ -43,9 +43,9 @@ func TestResolveStaticCall(t *testing.T) {
}, },
}, },
&expr.StaticCall{ &expr.StaticCall{
Class: nameBC, Class: nameBC,
Call: &node.Identifier{Value: "foo"}, Call: &node.Identifier{Value: "foo"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
} }
@ -134,8 +134,8 @@ func TestResolveNew(t *testing.T) {
}, },
}, },
&expr.New{ &expr.New{
Class: nameBC, Class: nameBC,
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
} }
@ -242,8 +242,8 @@ func TestResolveFunctionCall(t *testing.T) {
}, },
}, },
&expr.FunctionCall{ &expr.FunctionCall{
Function: nameB, Function: nameB,
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
} }
@ -323,12 +323,12 @@ func TestResolveGroupUse(t *testing.T) {
Constant: nameC, Constant: nameC,
}, },
&expr.FunctionCall{ &expr.FunctionCall{
Function: nameF, Function: nameF,
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
&expr.FunctionCall{ &expr.FunctionCall{
Function: nameE, Function: nameE,
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
} }
@ -658,9 +658,9 @@ func TestResolveNamespaces(t *testing.T) {
}, },
}, },
&expr.StaticCall{ &expr.StaticCall{
Class: nameFG, Class: nameFG,
Call: &node.Identifier{Value: "foo"}, Call: &node.Identifier{Value: "foo"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
&stmt.Namespace{ &stmt.Namespace{
Stmts: []node.Node{}, Stmts: []node.Node{},
@ -678,12 +678,12 @@ func TestResolveNamespaces(t *testing.T) {
&expr.StaticCall{ &expr.StaticCall{
Class: relativeNameCE, Class: relativeNameCE,
Call: &node.Identifier{Value: "foo"}, Call: &node.Identifier{Value: "foo"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
&expr.StaticCall{ &expr.StaticCall{
Class: nameCF, Class: nameCF,
Call: &node.Identifier{Value: "foo"}, Call: &node.Identifier{Value: "foo"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
@ -708,9 +708,9 @@ func TestResolveStaticCallDinamicClassName(t *testing.T) {
ast := &stmt.StmtList{ ast := &stmt.StmtList{
Stmts: []node.Node{ Stmts: []node.Node{
&expr.StaticCall{ &expr.StaticCall{
Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}}, Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Call: &node.Identifier{Value: "foo"}, Call: &node.Identifier{Value: "foo"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
} }