2017-12-07 10:34:39 +00:00
|
|
|
package stmt
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/z7zmey/php-parser/node"
|
|
|
|
"github.com/z7zmey/php-parser/token"
|
|
|
|
)
|
|
|
|
|
2017-12-27 23:23:32 +00:00
|
|
|
func (n ClassMethod) Name() string {
|
2017-12-27 17:55:58 +00:00
|
|
|
return "ClassMethod"
|
|
|
|
}
|
|
|
|
|
2017-12-07 10:34:39 +00:00
|
|
|
type ClassMethod struct {
|
2017-12-27 17:55:58 +00:00
|
|
|
name string
|
2017-12-07 10:34:39 +00:00
|
|
|
token token.Token
|
|
|
|
modifiers []node.Node
|
|
|
|
isReturnRef bool
|
|
|
|
params []node.Node
|
|
|
|
returnType node.Node
|
|
|
|
stmts []node.Node
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewClassMethod(token token.Token, modifiers []node.Node, isReturnRef bool, params []node.Node, returnType node.Node, stmts []node.Node) node.Node {
|
|
|
|
return ClassMethod{
|
2017-12-27 17:55:58 +00:00
|
|
|
"ClassMethod",
|
2017-12-07 10:34:39 +00:00
|
|
|
token,
|
|
|
|
modifiers,
|
|
|
|
isReturnRef,
|
|
|
|
params,
|
|
|
|
returnType,
|
|
|
|
stmts,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-27 23:23:32 +00:00
|
|
|
func (n ClassMethod) Walk(v node.Visitor) {
|
|
|
|
if v.Visit(n) == false {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
v.Scalar("token", n.token.Value)
|
|
|
|
v.Scalar("isReturnRef", n.isReturnRef)
|
2017-12-07 10:34:39 +00:00
|
|
|
|
|
|
|
if n.modifiers != nil {
|
2017-12-27 23:23:32 +00:00
|
|
|
vv := v.Children("modifiers")
|
2017-12-07 10:34:39 +00:00
|
|
|
for _, nn := range n.modifiers {
|
2017-12-27 23:23:32 +00:00
|
|
|
nn.Walk(vv)
|
2017-12-07 10:34:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if n.params != nil {
|
2017-12-27 23:23:32 +00:00
|
|
|
vv := v.Children("params")
|
2017-12-07 10:34:39 +00:00
|
|
|
for _, nn := range n.params {
|
2017-12-27 23:23:32 +00:00
|
|
|
nn.Walk(vv)
|
2017-12-07 10:34:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if n.returnType != nil {
|
2017-12-27 23:23:32 +00:00
|
|
|
vv := v.Children("returnType")
|
|
|
|
n.returnType.Walk(vv)
|
2017-12-07 10:34:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if n.stmts != nil {
|
2017-12-27 23:23:32 +00:00
|
|
|
vv := v.Children("stmts")
|
2017-12-07 10:34:39 +00:00
|
|
|
for _, nn := range n.stmts {
|
2017-12-27 23:23:32 +00:00
|
|
|
nn.Walk(vv)
|
2017-12-07 10:34:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|