rename AssignRef to Reference

This commit is contained in:
z7zmey
2018-04-05 12:03:32 +03:00
parent d19b16e161
commit 47c51ea022
11 changed files with 30 additions and 30 deletions

View File

@@ -5,28 +5,28 @@ import (
"github.com/z7zmey/php-parser/walker"
)
// AssignRef node
type AssignRef struct {
// Reference node
type Reference struct {
Variable node.Node
Expression node.Node
}
// NewAssignRef node constuctor
func NewAssignRef(Variable node.Node, Expression node.Node) *AssignRef {
return &AssignRef{
// NewReference node constuctor
func NewReference(Variable node.Node, Expression node.Node) *Reference {
return &Reference{
Variable,
Expression,
}
}
// Attributes returns node attributes as map
func (n *AssignRef) Attributes() map[string]interface{} {
func (n *Reference) Attributes() map[string]interface{} {
return nil
}
// Walk traverses nodes
// Walk is invoked recursively until v.EnterNode returns true
func (n *AssignRef) Walk(v walker.Visitor) {
func (n *Reference) Walk(v walker.Visitor) {
if v.EnterNode(n) == false {
return
}

View File

@@ -29,13 +29,13 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
}
}
func TestAssignRef(t *testing.T) {
func TestReference(t *testing.T) {
src := `<? $a =& $b;`
expected := &stmt.StmtList{
Stmts: []node.Node{
&stmt.Expression{
Expr: &assign.AssignRef{
Expr: &assign.Reference{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}},
},
@@ -50,13 +50,13 @@ func TestAssignRef(t *testing.T) {
assertEqual(t, expected, actual)
}
func TestAssignRefNew(t *testing.T) {
func TestReferenceNew(t *testing.T) {
src := `<? $a =& new Foo;`
expected := &stmt.StmtList{
Stmts: []node.Node{
&stmt.Expression{
Expr: &assign.AssignRef{
Expr: &assign.Reference{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
Expression: &expr.New{
Class: &name.Name{
@@ -77,13 +77,13 @@ func TestAssignRefNew(t *testing.T) {
assertEqual(t, expected, actual)
}
func TestAssignRefArgs(t *testing.T) {
func TestReferenceArgs(t *testing.T) {
src := `<? $a =& new Foo($b);`
expected := &stmt.StmtList{
Stmts: []node.Node{
&stmt.Expression{
Expr: &assign.AssignRef{
Expr: &assign.Reference{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
Expression: &expr.New{
Class: &name.Name{

View File

@@ -19,7 +19,7 @@ var nodesToTest = []struct {
expectedAttributes map[string]interface{}
}{
{
&assign.AssignRef{
&assign.Reference{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}},
},