create ArgumentList node
This commit is contained in:
@@ -10,19 +10,19 @@ type Class struct {
|
||||
PhpDocComment string
|
||||
ClassName node.Node
|
||||
Modifiers []node.Node
|
||||
Args []node.Node
|
||||
ArgumentList *node.ArgumentList
|
||||
Extends node.Node
|
||||
Implements []node.Node
|
||||
Stmts []node.Node
|
||||
}
|
||||
|
||||
// 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{
|
||||
PhpDocComment,
|
||||
ClassName,
|
||||
Modifiers,
|
||||
Args,
|
||||
ArgumentList,
|
||||
Extends,
|
||||
Implements,
|
||||
Stmts,
|
||||
@@ -57,13 +57,9 @@ func (n *Class) Walk(v walker.Visitor) {
|
||||
}
|
||||
}
|
||||
|
||||
if n.Args != nil {
|
||||
vv := v.GetChildrenVisitor("Args")
|
||||
for _, nn := range n.Args {
|
||||
if nn != nil {
|
||||
nn.Walk(vv)
|
||||
}
|
||||
}
|
||||
if n.ArgumentList != nil {
|
||||
vv := v.GetChildrenVisitor("ArgumentList")
|
||||
n.ArgumentList.Walk(vv)
|
||||
}
|
||||
|
||||
if n.Extends != nil {
|
||||
|
||||
@@ -2,9 +2,10 @@ package stmt_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/z7zmey/php-parser/node/expr"
|
||||
"github.com/z7zmey/php-parser/node/name"
|
||||
"testing"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/node/stmt"
|
||||
@@ -171,7 +172,7 @@ func TestAnonimousClass(t *testing.T) {
|
||||
&stmt.Expression{
|
||||
Expr: &expr.New{
|
||||
Class: &stmt.Class{
|
||||
Args: []node.Node{},
|
||||
ArgumentList: &node.ArgumentList{},
|
||||
Extends: &name.Name{
|
||||
Parts: []node.Node{
|
||||
&name.NamePart{Value: "foo"},
|
||||
|
||||
@@ -53,7 +53,7 @@ func TestGlobalVars(t *testing.T) {
|
||||
&name.NamePart{Value: "foo"},
|
||||
},
|
||||
},
|
||||
Arguments: []node.Node{},
|
||||
ArgumentList: &node.ArgumentList{},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -92,12 +92,12 @@ var nodesToTest = []struct {
|
||||
PhpDocComment: "/** */",
|
||||
ClassName: &node.Identifier{},
|
||||
Modifiers: []node.Node{&stmt.Expression{}},
|
||||
Args: []node.Node{&stmt.Expression{}},
|
||||
Extends: &node.Identifier{},
|
||||
Implements: []node.Node{&stmt.Expression{}},
|
||||
Stmts: []node.Node{&stmt.Expression{}},
|
||||
ArgumentList: &node.ArgumentList{},
|
||||
Extends: &node.Identifier{},
|
||||
Implements: []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": "/** */"},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user