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,6 +99,7 @@ func TestReferenceArgs(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{ &node.Argument{
Variadic: false, Variadic: false,
@ -110,6 +111,7 @@ func TestReferenceArgs(t *testing.T) {
}, },
}, },
}, },
},
} }
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")

View File

@ -8,14 +8,14 @@ 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

@ -9,15 +9,15 @@ import (
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

@ -8,14 +8,14 @@ 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

@ -9,15 +9,15 @@ import (
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,6 +87,7 @@ func TestFunctionFullyQualified(t *testing.T) {
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},
}, },
}, },
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{ &node.Argument{
Variadic: false, Variadic: false,
@ -99,6 +100,7 @@ func TestFunctionFullyQualified(t *testing.T) {
}, },
}, },
}, },
},
} }
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
@ -120,6 +122,7 @@ 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"}},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{ &node.Argument{
Variadic: false, Variadic: false,
@ -132,6 +135,7 @@ func TestFunctionCallVar(t *testing.T) {
}, },
}, },
}, },
},
} }
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
@ -157,6 +161,7 @@ func TestFunctionCallExprArg(t *testing.T) {
&name.NamePart{Value: "ceil"}, &name.NamePart{Value: "ceil"},
}, },
}, },
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{ &node.Argument{
Variadic: false, Variadic: false,
@ -170,6 +175,7 @@ func TestFunctionCallExprArg(t *testing.T) {
}, },
}, },
}, },
},
} }
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php") php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")

View File

@ -21,7 +21,7 @@ func TestMethodCall(t *testing.T) {
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,10 +109,12 @@ 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{
Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
},
Stmts: []node.Node{}, Stmts: []node.Node{},
}, },
}, },

View File

@ -27,7 +27,7 @@ func TestStaticCall(t *testing.T) {
}, },
}, },
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
@ -57,7 +57,7 @@ func TestStaticCallRelative(t *testing.T) {
}, },
}, },
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
@ -87,7 +87,7 @@ func TestStaticCallFullyQualified(t *testing.T) {
}, },
}, },
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
@ -117,7 +117,7 @@ func TestStaticCallVar(t *testing.T) {
}, },
}, },
Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },
@ -143,7 +143,7 @@ func TestStaticCallVarVar(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: &expr.Variable{VarName: &node.Identifier{Value: "bar"}}, Call: &expr.Variable{VarName: &node.Identifier{Value: "bar"}},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
}, },

View File

@ -147,9 +147,9 @@ 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{}{},
}, },
{ {
@ -196,17 +196,17 @@ 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{}{},
}, },
{ {
@ -297,9 +297,9 @@ 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

@ -223,7 +223,7 @@ func TestCurlyOpenMethodCall(t *testing.T) {
&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,68 +70,82 @@ 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"}}},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &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"}},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
}, },
}, },
},
&stmt.Expression{ &stmt.Expression{
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"},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
}, },
}, },
},
&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: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
}, },
}, },
},
&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: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &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"}}},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
}, },
}, },
},
&stmt.Expression{ &stmt.Expression{
Expr: &expr.New{ Expr: &expr.New{
Class: &stmt.Class{ Class: &stmt.Class{
PhpDocComment: "/** anonymous class */", PhpDocComment: "/** anonymous class */",
Args: []node.Node{ ArgumentList: &node.ArgumentList{
Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
},
Stmts: []node.Node{}, Stmts: []node.Node{},
}, },
}, },
@ -160,54 +174,65 @@ 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"}}},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &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"}},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
}, },
}, },
},
&stmt.Expression{ &stmt.Expression{
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"},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
}, },
}, },
},
&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: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
}, },
}, },
},
&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: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &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"}}},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
@ -215,6 +240,7 @@ func TestPhp5ArgumentNode(t *testing.T) {
}, },
}, },
}, },
},
} }
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php") php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")

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,60 +434,72 @@ 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"}}},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &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"}},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
}, },
}, },
},
&stmt.Expression{ &stmt.Expression{
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"},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
}, },
}, },
},
&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: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
}, },
}, },
},
&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: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &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"}}},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
}, },
}, },
},
&stmt.Function{ &stmt.Function{
ReturnsRef: false, ReturnsRef: false,
PhpDocComment: "", PhpDocComment: "",
@ -667,7 +679,7 @@ func TestPhp5(t *testing.T) {
&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,6 +2103,7 @@ func TestPhp5(t *testing.T) {
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},
}, },
}, },
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{ &node.Argument{
Variadic: false, Variadic: false,
@ -2100,6 +2113,7 @@ func TestPhp5(t *testing.T) {
}, },
}, },
}, },
},
&stmt.Expression{ &stmt.Expression{
Expr: &expr.FunctionCall{ Expr: &expr.FunctionCall{
Function: &name.FullyQualified{ Function: &name.FullyQualified{
@ -2107,6 +2121,7 @@ func TestPhp5(t *testing.T) {
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},
}, },
}, },
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{ &node.Argument{
Variadic: false, Variadic: false,
@ -2118,9 +2133,11 @@ 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"}},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{ &node.Argument{
Variadic: false, Variadic: false,
@ -2132,6 +2149,7 @@ func TestPhp5(t *testing.T) {
}, },
}, },
}, },
},
&stmt.Expression{ &stmt.Expression{
Expr: &expr.PostDec{ Expr: &expr.PostDec{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
@ -2283,7 +2301,7 @@ func TestPhp5(t *testing.T) {
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{
@ -2347,7 +2365,7 @@ 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"},
}, },
@ -2360,7 +2378,7 @@ func TestPhp5(t *testing.T) {
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"},
}, },
@ -2425,7 +2443,7 @@ func TestPhp5(t *testing.T) {
}, },
}, },
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2436,7 +2454,7 @@ func TestPhp5(t *testing.T) {
}, },
}, },
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2447,7 +2465,7 @@ func TestPhp5(t *testing.T) {
}, },
}, },
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2458,14 +2476,14 @@ func TestPhp5(t *testing.T) {
}, },
}, },
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,6 +2833,7 @@ func TestPhp5(t *testing.T) {
&name.NamePart{Value: "Foo"}, &name.NamePart{Value: "Foo"},
}, },
}, },
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{ &node.Argument{
Variadic: false, Variadic: false,
@ -2825,6 +2844,7 @@ func TestPhp5(t *testing.T) {
}, },
}, },
}, },
},
&stmt.Expression{ &stmt.Expression{
Expr: &assign.Assign{ Expr: &assign.Assign{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
@ -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{
@ -3575,7 +3595,7 @@ 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{
@ -3583,7 +3603,7 @@ func TestPhp5(t *testing.T) {
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"},
}, },
@ -3603,7 +3623,7 @@ 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: &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

View File

@ -263,12 +263,13 @@ import (
%type <node> array_pair possible_array_pair %type <node> array_pair possible_array_pair
%type <node> isset_variable type return_type type_expr %type <node> isset_variable type return_type type_expr
%type <node> class_modifier %type <node> class_modifier
%type <node> argument_list ctor_arguments
%type <node> member_modifier %type <node> member_modifier
%type <node> use_type %type <node> use_type
%type <foreachVariable> foreach_variable %type <foreachVariable> foreach_variable
%type <nodesWithEndToken> method_body switch_case_list trait_adaptations argument_list ctor_arguments %type <nodesWithEndToken> method_body switch_case_list trait_adaptations
%type <list> encaps_list backticks_expr namespace_name catch_name_list catch_list class_const_list %type <list> encaps_list backticks_expr namespace_name catch_name_list catch_list class_const_list
%type <list> const_list echo_expr_list for_exprs non_empty_for_exprs global_var_list %type <list> const_list echo_expr_list for_exprs non_empty_for_exprs global_var_list
@ -1724,9 +1725,19 @@ return_type:
argument_list: argument_list:
'(' ')' '(' ')'
{ $$ = &nodesWithEndToken{[]node.Node{}, $2} } {
$$ = node.NewArgumentList(nil)
// save position
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2))
}
| '(' non_empty_argument_list possible_comma ')' | '(' non_empty_argument_list possible_comma ')'
{ $$ = &nodesWithEndToken{$2, $4} } {
$$ = node.NewArgumentList($2)
// save position
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4))
}
; ;
non_empty_argument_list: non_empty_argument_list:
@ -2250,7 +2261,7 @@ anonymous_class:
T_CLASS ctor_arguments extends_from implements_list backup_doc_comment '{' class_statement_list '}' T_CLASS ctor_arguments extends_from implements_list backup_doc_comment '{' class_statement_list '}'
{ {
if $2 != nil { if $2 != nil {
$$ = stmt.NewClass(nil, nil, $2.nodes, $3, $4, $7, $5) $$ = stmt.NewClass(nil, nil, $2.(*node.ArgumentList), $3, $4, $7, $5)
} else { } else {
$$ = stmt.NewClass(nil, nil, nil, $3, $4, $7, $5) $$ = stmt.NewClass(nil, nil, nil, $3, $4, $7, $5)
} }
@ -2275,8 +2286,8 @@ 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))
@ -3136,37 +3147,37 @@ lexical_var:
function_call: function_call:
name argument_list name argument_list
{ {
$$ = expr.NewFunctionCall($1, $2.nodes) $$ = expr.NewFunctionCall($1, $2.(*node.ArgumentList))
// save position // save position
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2.endToken)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $2))
} }
| class_name T_PAAMAYIM_NEKUDOTAYIM member_name argument_list | class_name T_PAAMAYIM_NEKUDOTAYIM member_name argument_list
{ {
$$ = expr.NewStaticCall($1, $3, $4.nodes) $$ = expr.NewStaticCall($1, $3, $4.(*node.ArgumentList))
// save position // save position
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4.endToken)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4))
// save comments // save comments
yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken)
} }
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM member_name argument_list | variable_class_name T_PAAMAYIM_NEKUDOTAYIM member_name argument_list
{ {
$$ = expr.NewStaticCall($1, $3, $4.nodes) $$ = expr.NewStaticCall($1, $3, $4.(*node.ArgumentList))
// save position // save position
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4.endToken)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4))
// save comments // save comments
yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken) yylex.(*Parser).comments.AddFromToken($$, $2, comment.PaamayimNekudotayimToken)
} }
| callable_expr argument_list | callable_expr argument_list
{ {
$$ = expr.NewFunctionCall($1, $2.nodes) $$ = expr.NewFunctionCall($1, $2.(*node.ArgumentList))
// save position // save position
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $2.endToken)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $2))
} }
; ;
@ -3523,10 +3534,10 @@ callable_variable:
} }
| dereferencable T_OBJECT_OPERATOR property_name argument_list | dereferencable T_OBJECT_OPERATOR property_name argument_list
{ {
$$ = expr.NewMethodCall($1, $3, $4.nodes) $$ = expr.NewMethodCall($1, $3, $4.(*node.ArgumentList))
// save position // save position
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodeTokenPosition($1, $4.endToken)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewNodesPosition($1, $4))
// save comments // save comments
yylex.(*Parser).comments.AddFromToken($$, $2, comment.ObjectOperatorToken) yylex.(*Parser).comments.AddFromToken($$, $2, comment.ObjectOperatorToken)

View File

@ -402,68 +402,82 @@ 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"}}},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &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"}},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
}, },
}, },
},
&stmt.Expression{ &stmt.Expression{
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"},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
}, },
}, },
},
&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: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
}, },
}, },
},
&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: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &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"}}},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
}, },
}, },
},
&stmt.Expression{ &stmt.Expression{
Expr: &expr.New{ Expr: &expr.New{
Class: &stmt.Class{ Class: &stmt.Class{
PhpDocComment: "/** anonymous class */", PhpDocComment: "/** anonymous class */",
Args: []node.Node{ ArgumentList: &node.ArgumentList{
Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
},
Stmts: []node.Node{}, Stmts: []node.Node{},
}, },
}, },
@ -732,7 +746,8 @@ func TestPhp7(t *testing.T) {
&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{
@ -2327,7 +2347,8 @@ func TestPhp7(t *testing.T) {
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,17 +2380,21 @@ 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{
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{
&node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, &node.Argument{Variadic: false, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
&node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, &node.Argument{Variadic: true, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}},
}, },
},
Stmts: []node.Node{}, Stmts: []node.Node{},
}, },
}, },
@ -2489,7 +2516,8 @@ func TestPhp7(t *testing.T) {
}, },
}, },
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2500,7 +2528,8 @@ func TestPhp7(t *testing.T) {
}, },
}, },
Call: &node.Identifier{Value: "bar"}, Call: &node.Identifier{Value: "bar"},
Arguments: []node.Node{},
ArgumentList: &node.ArgumentList{},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -2511,7 +2540,8 @@ func TestPhp7(t *testing.T) {
}, },
}, },
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,14 +3132,16 @@ 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{},
}, },
}, },
}, },
@ -3112,7 +3149,8 @@ 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: &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,6 +1522,7 @@ 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"}},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{ &node.Argument{
IsReference: true, IsReference: true,
@ -1535,6 +1536,7 @@ func TestPrintFunctionCall(t *testing.T) {
Expr: &expr.Variable{VarName: &node.Identifier{Value: "c"}}, Expr: &expr.Variable{VarName: &node.Identifier{Value: "c"}},
}, },
}, },
},
}) })
expected := `$var(&$a, ...$b, $c)` expected := `$var(&$a, ...$b, $c)`
@ -1648,6 +1650,7 @@ 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"},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{ &node.Argument{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
@ -1656,6 +1659,7 @@ func TestPrintMethodCall(t *testing.T) {
Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}},
}, },
}, },
},
}) })
expected := `$foo->bar($a, $b)` expected := `$foo->bar($a, $b)`
@ -1672,6 +1676,7 @@ 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"}}},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{ &node.Argument{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
@ -1680,6 +1685,7 @@ func TestPrintNew(t *testing.T) {
Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}},
}, },
}, },
},
}) })
expected := `new Foo($a, $b)` expected := `new Foo($a, $b)`
@ -1901,6 +1907,7 @@ 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"},
ArgumentList: &node.ArgumentList{
Arguments: []node.Node{ Arguments: []node.Node{
&node.Argument{ &node.Argument{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
@ -1909,6 +1916,7 @@ func TestPrintStaticCall(t *testing.T) {
Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}},
}, },
}, },
},
}) })
expected := `Foo::bar($a, $b)` expected := `Foo::bar($a, $b)`
@ -2509,7 +2517,8 @@ 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{
Arguments: []node.Node{
&node.Argument{ &node.Argument{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
}, },
@ -2517,6 +2526,7 @@ func TestPrintStmtAnonymousClass(t *testing.T) {
Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}}, 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"}}},
Implements: []node.Node{ Implements: []node.Node{
&name.Name{Parts: []node.Node{&name.NamePart{Value: "Baz"}}}, &name.Name{Parts: []node.Node{&name.NamePart{Value: "Baz"}}},

View File

@ -45,7 +45,7 @@ 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{},
}, },
}, },
} }
@ -135,7 +135,7 @@ func TestResolveNew(t *testing.T) {
}, },
&expr.New{ &expr.New{
Class: nameBC, Class: nameBC,
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
} }
@ -243,7 +243,7 @@ func TestResolveFunctionCall(t *testing.T) {
}, },
&expr.FunctionCall{ &expr.FunctionCall{
Function: nameB, Function: nameB,
Arguments: []node.Node{}, ArgumentList: &node.ArgumentList{},
}, },
}, },
} }
@ -324,11 +324,11 @@ func TestResolveGroupUse(t *testing.T) {
}, },
&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{},
}, },
}, },
} }
@ -660,7 +660,7 @@ 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{},
}, },
}, },
}, },
@ -710,7 +710,7 @@ func TestResolveStaticCallDinamicClassName(t *testing.T) {
&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{},
}, },
}, },
} }