diff --git a/node/stmt/n_property_list.go b/node/stmt/n_property_list.go index fd76373..b542c12 100644 --- a/node/stmt/n_property_list.go +++ b/node/stmt/n_property_list.go @@ -12,14 +12,16 @@ type PropertyList struct { FreeFloating freefloating.Collection Position *position.Position Modifiers []node.Node + Type node.Node Properties []node.Node } // NewPropertyList node constructor -func NewPropertyList(Modifiers []node.Node, Properties []node.Node) *PropertyList { +func NewPropertyList(Modifiers []node.Node, Type node.Node, Properties []node.Node) *PropertyList { return &PropertyList{ FreeFloating: nil, Modifiers: Modifiers, + Type: Type, Properties: Properties, } } @@ -60,6 +62,12 @@ func (n *PropertyList) Walk(v walker.Visitor) { v.LeaveChildList("Modifiers", n) } + if n.Type != nil { + v.EnterChildNode("Type", n) + n.Type.Walk(v) + v.LeaveChildNode("Type", n) + } + if n.Properties != nil { v.EnterChildList("Properties", n) for _, nn := range n.Properties { diff --git a/node/stmt/t_property_list_test.go b/node/stmt/t_property_list_test.go index 8e28817..2072d7a 100644 --- a/node/stmt/t_property_list_test.go +++ b/node/stmt/t_property_list_test.go @@ -6,6 +6,7 @@ import ( "gotest.tools/assert" "github.com/z7zmey/php-parser/node/expr" + "github.com/z7zmey/php-parser/node/name" "github.com/z7zmey/php-parser/node/scalar" "github.com/z7zmey/php-parser/position" @@ -378,3 +379,109 @@ func TestProperties2(t *testing.T) { actual = php5parser.GetRootNode() assert.DeepEqual(t, expected, actual) } + +func TestPropertyType(t *testing.T) { + src := `