From dc7aa7302d8e06828baf00eed2bc794571ef3736 Mon Sep 17 00:00:00 2001 From: z7zmey Date: Sun, 29 Dec 2019 16:36:56 +0200 Subject: [PATCH] [#82] property type --- node/stmt/n_property_list.go | 10 +- node/stmt/t_property_list_test.go | 107 +++ node/stmt/t_visitor_test.go | 3 +- php5/php5.go | 2 +- php5/php5.y | 2 +- php7/php7.go | 1138 ++++++++++++++------------- php7/php7.y | 10 +- printer/printer.go | 6 + printer/printer_parsed_php7_test.go | 2 +- printer/printer_test.go | 9 +- 10 files changed, 715 insertions(+), 574 deletions(-) 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 := `