php-parser/node/parameter.go

52 lines
883 B
Go
Raw Normal View History

2017-12-27 14:26:36 +00:00
package node
type Parameter struct {
2017-12-27 17:55:58 +00:00
name string
2017-12-27 14:26:36 +00:00
variableType Node
variable Node
defaultValue Node
byRef bool
variadic bool
}
2017-12-27 17:55:58 +00:00
func (n Parameter) Name() string {
return "Parameter"
}
2017-12-27 14:26:36 +00:00
func NewParameter(variableType Node, variable Node, defaultValue Node, byRef bool, variadic bool) Node {
return Parameter{
2017-12-27 17:55:58 +00:00
"Parameter",
2017-12-27 14:26:36 +00:00
variableType,
variable,
defaultValue,
byRef,
variadic,
}
}
2017-12-27 23:23:32 +00:00
func (n Parameter) Walk(v Visitor) {
2017-12-28 11:36:27 +00:00
if v.EnterNode(n) == false {
2017-12-27 23:23:32 +00:00
return
}
v.Scalar("byRef", n.byRef)
v.Scalar("variadic", n.variadic)
2017-12-27 14:26:36 +00:00
if n.variableType != nil {
2017-12-28 11:36:27 +00:00
vv := v.GetChildrenVisitor("variableType")
2017-12-27 23:23:32 +00:00
n.variableType.Walk(vv)
2017-12-27 14:26:36 +00:00
}
if n.variable != nil {
2017-12-28 11:36:27 +00:00
vv := v.GetChildrenVisitor("variable")
2017-12-27 23:23:32 +00:00
n.variable.Walk(vv)
2017-12-27 14:26:36 +00:00
}
if n.defaultValue != nil {
2017-12-28 11:36:27 +00:00
vv := v.GetChildrenVisitor("defaultValue")
2017-12-27 23:23:32 +00:00
n.defaultValue.Walk(vv)
2017-12-27 14:26:36 +00:00
}
2017-12-28 11:36:27 +00:00
v.LeaveNode(n)
2017-12-27 14:26:36 +00:00
}