trait_use_precedence node

This commit is contained in:
vadim 2017-12-09 13:05:12 +02:00
parent f4a0a56b14
commit 20232dd30c
3 changed files with 276 additions and 236 deletions

View File

@ -0,0 +1,36 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
type TraitUsePrecedence struct {
node.SimpleNode
ref node.Node
insteadof node.Node
}
func NewTraitUsePrecedence(ref node.Node, insteadof node.Node) node.Node {
return TraitUsePrecedence{
node.SimpleNode{Name: "TraitUsePrecedence", Attributes: make(map[string]string)},
ref,
insteadof,
}
}
func (n TraitUsePrecedence) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
if n.ref != nil {
fmt.Fprintf(out, "\n%vmethod", indent+" ")
n.ref.Print(out, indent+" ")
}
if n.insteadof != nil {
fmt.Fprintf(out, "\n%vinsteadof:", indent+" ")
n.insteadof.Print(out, indent+" ")
}
}

File diff suppressed because it is too large Load Diff

View File

@ -701,7 +701,10 @@ trait_adaptation:
trait_precedence: trait_precedence:
absolute_trait_method_reference T_INSTEADOF name_list absolute_trait_method_reference T_INSTEADOF name_list
{ $$ = node.NewSimpleNode("TraitPrecedence").Append($1).Append($3) } {
name := name.NewName($3.(node.SimpleNode).Children)
$$ = stmt.NewTraitUsePrecedence($1, name)
}
; ;
trait_alias: trait_alias: