property_fetch static_property_fetch nodes

This commit is contained in:
z7zmey
2017-12-18 19:52:41 +02:00
parent a73b9a9478
commit 40a27c6131
5 changed files with 113 additions and 16 deletions

View File

@@ -0,0 +1,36 @@
package expr
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
type PropertyFetch struct {
node.SimpleNode
variable node.Node
name node.Node
}
func NewPropertyFetch(variable node.Node, name node.Node) node.Node {
return PropertyFetch{
node.SimpleNode{Name: "PropertyFetch", Attributes: make(map[string]string)},
variable,
name,
}
}
func (n PropertyFetch) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ")
n.variable.Print(out, indent+" ")
}
if n.name != nil {
fmt.Fprintf(out, "\n%vname:", indent+" ")
n.name.Print(out, indent+" ")
}
}

View File

@@ -0,0 +1,36 @@
package expr
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
type StaticPropertyFetch struct {
node.SimpleNode
class node.Node
name node.Node
}
func NewStaticPropertyFetch(class node.Node, name node.Node) node.Node {
return StaticPropertyFetch{
node.SimpleNode{Name: "StaticPropertyFetch", Attributes: make(map[string]string)},
class,
name,
}
}
func (n StaticPropertyFetch) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
if n.class != nil {
fmt.Fprintf(out, "\n%vclass:", indent+" ")
n.class.Print(out, indent+" ")
}
if n.name != nil {
fmt.Fprintf(out, "\n%vname:", indent+" ")
n.name.Print(out, indent+" ")
}
}