remove Cast prefix from node names
This commit is contained in:
@@ -5,26 +5,26 @@ import (
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
)
|
||||
|
||||
// CastArray node
|
||||
type CastArray struct {
|
||||
// Array node
|
||||
type Array struct {
|
||||
Expr node.Node
|
||||
}
|
||||
|
||||
// NewCastArray node constuctor
|
||||
func NewCastArray(Expr node.Node) *CastArray {
|
||||
return &CastArray{
|
||||
// NewArray node constructor
|
||||
func NewArray(Expr node.Node) *Array {
|
||||
return &Array{
|
||||
Expr,
|
||||
}
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
func (n *CastArray) Attributes() map[string]interface{} {
|
||||
func (n *Array) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Walk traverses nodes
|
||||
// Walk is invoked recursively until v.EnterNode returns true
|
||||
func (n *CastArray) Walk(v walker.Visitor) {
|
||||
func (n *Array) Walk(v walker.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -5,26 +5,26 @@ import (
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
)
|
||||
|
||||
// CastBool node
|
||||
type CastBool struct {
|
||||
// Bool node
|
||||
type Bool struct {
|
||||
Expr node.Node
|
||||
}
|
||||
|
||||
// NewCastBool node constuctor
|
||||
func NewCastBool(Expr node.Node) *CastBool {
|
||||
return &CastBool{
|
||||
// NewBool node constructor
|
||||
func NewBool(Expr node.Node) *Bool {
|
||||
return &Bool{
|
||||
Expr,
|
||||
}
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
func (n *CastBool) Attributes() map[string]interface{} {
|
||||
func (n *Bool) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Walk traverses nodes
|
||||
// Walk is invoked recursively until v.EnterNode returns true
|
||||
func (n *CastBool) Walk(v walker.Visitor) {
|
||||
func (n *Bool) Walk(v walker.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -5,26 +5,26 @@ import (
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
)
|
||||
|
||||
// CastDouble node
|
||||
type CastDouble struct {
|
||||
// Double node
|
||||
type Double struct {
|
||||
Expr node.Node
|
||||
}
|
||||
|
||||
// NewCastDouble node constuctor
|
||||
func NewCastDouble(Expr node.Node) *CastDouble {
|
||||
return &CastDouble{
|
||||
// NewDouble node constructor
|
||||
func NewDouble(Expr node.Node) *Double {
|
||||
return &Double{
|
||||
Expr,
|
||||
}
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
func (n *CastDouble) Attributes() map[string]interface{} {
|
||||
func (n *Double) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Walk traverses nodes
|
||||
// Walk is invoked recursively until v.EnterNode returns true
|
||||
func (n *CastDouble) Walk(v walker.Visitor) {
|
||||
func (n *Double) Walk(v walker.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -5,26 +5,26 @@ import (
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
)
|
||||
|
||||
// CastInt node
|
||||
type CastInt struct {
|
||||
// Int node
|
||||
type Int struct {
|
||||
Expr node.Node
|
||||
}
|
||||
|
||||
// NewCastInt node constuctor
|
||||
func NewCastInt(Expr node.Node) *CastInt {
|
||||
return &CastInt{
|
||||
// NewInt node constructor
|
||||
func NewInt(Expr node.Node) *Int {
|
||||
return &Int{
|
||||
Expr,
|
||||
}
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
func (n *CastInt) Attributes() map[string]interface{} {
|
||||
func (n *Int) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Walk traverses nodes
|
||||
// Walk is invoked recursively until v.EnterNode returns true
|
||||
func (n *CastInt) Walk(v walker.Visitor) {
|
||||
func (n *Int) Walk(v walker.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -5,26 +5,26 @@ import (
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
)
|
||||
|
||||
// CastObject node
|
||||
type CastObject struct {
|
||||
// Object node
|
||||
type Object struct {
|
||||
Expr node.Node
|
||||
}
|
||||
|
||||
// NewCastObject node constuctor
|
||||
func NewCastObject(Expr node.Node) *CastObject {
|
||||
return &CastObject{
|
||||
// NewObject node constructor
|
||||
func NewObject(Expr node.Node) *Object {
|
||||
return &Object{
|
||||
Expr,
|
||||
}
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
func (n *CastObject) Attributes() map[string]interface{} {
|
||||
func (n *Object) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Walk traverses nodes
|
||||
// Walk is invoked recursively until v.EnterNode returns true
|
||||
func (n *CastObject) Walk(v walker.Visitor) {
|
||||
func (n *Object) Walk(v walker.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -5,26 +5,26 @@ import (
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
)
|
||||
|
||||
// CastString node
|
||||
type CastString struct {
|
||||
// String node
|
||||
type String struct {
|
||||
Expr node.Node
|
||||
}
|
||||
|
||||
// NewCastString node constuctor
|
||||
func NewCastString(Expr node.Node) *CastString {
|
||||
return &CastString{
|
||||
// NewString node constructor
|
||||
func NewString(Expr node.Node) *String {
|
||||
return &String{
|
||||
Expr,
|
||||
}
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
func (n *CastString) Attributes() map[string]interface{} {
|
||||
func (n *String) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Walk traverses nodes
|
||||
// Walk is invoked recursively until v.EnterNode returns true
|
||||
func (n *CastString) Walk(v walker.Visitor) {
|
||||
func (n *String) Walk(v walker.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -5,26 +5,26 @@ import (
|
||||
"github.com/z7zmey/php-parser/walker"
|
||||
)
|
||||
|
||||
// CastUnset node
|
||||
type CastUnset struct {
|
||||
// Unset node
|
||||
type Unset struct {
|
||||
Expr node.Node
|
||||
}
|
||||
|
||||
// NewCastUnset node constuctor
|
||||
func NewCastUnset(Expr node.Node) *CastUnset {
|
||||
return &CastUnset{
|
||||
// NewUnset node constructor
|
||||
func NewUnset(Expr node.Node) *Unset {
|
||||
return &Unset{
|
||||
Expr,
|
||||
}
|
||||
}
|
||||
|
||||
// Attributes returns node attributes as map
|
||||
func (n *CastUnset) Attributes() map[string]interface{} {
|
||||
func (n *Unset) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Walk traverses nodes
|
||||
// Walk is invoked recursively until v.EnterNode returns true
|
||||
func (n *CastUnset) Walk(v walker.Visitor) {
|
||||
func (n *Unset) Walk(v walker.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCastArray(t *testing.T) {
|
||||
func TestArray(t *testing.T) {
|
||||
src := `<? (array)$a;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastArray{
|
||||
Expr: &cast.Array{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
},
|
||||
},
|
||||
@@ -47,13 +47,13 @@ func TestCastArray(t *testing.T) {
|
||||
assertEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestCastBool(t *testing.T) {
|
||||
func TestBool(t *testing.T) {
|
||||
src := `<? (boolean)$a;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastBool{
|
||||
Expr: &cast.Bool{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
},
|
||||
},
|
||||
@@ -67,13 +67,13 @@ func TestCastBool(t *testing.T) {
|
||||
assertEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestCastBoolShort(t *testing.T) {
|
||||
func TestBoolShort(t *testing.T) {
|
||||
src := `<? (bool)$a;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastBool{
|
||||
Expr: &cast.Bool{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
},
|
||||
},
|
||||
@@ -87,13 +87,13 @@ func TestCastBoolShort(t *testing.T) {
|
||||
assertEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestCastDouble(t *testing.T) {
|
||||
func TestDouble(t *testing.T) {
|
||||
src := `<? (double)$a;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastDouble{
|
||||
Expr: &cast.Double{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
},
|
||||
},
|
||||
@@ -113,7 +113,7 @@ func TestCastFloat(t *testing.T) {
|
||||
expected := &stmt.StmtList{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastDouble{
|
||||
Expr: &cast.Double{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
},
|
||||
},
|
||||
@@ -127,13 +127,13 @@ func TestCastFloat(t *testing.T) {
|
||||
assertEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestCastInt(t *testing.T) {
|
||||
func TestInt(t *testing.T) {
|
||||
src := `<? (integer)$a;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastInt{
|
||||
Expr: &cast.Int{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
},
|
||||
},
|
||||
@@ -147,13 +147,13 @@ func TestCastInt(t *testing.T) {
|
||||
assertEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestCastIntShort(t *testing.T) {
|
||||
func TestIntShort(t *testing.T) {
|
||||
src := `<? (int)$a;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastInt{
|
||||
Expr: &cast.Int{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
},
|
||||
},
|
||||
@@ -167,13 +167,13 @@ func TestCastIntShort(t *testing.T) {
|
||||
assertEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestCastObject(t *testing.T) {
|
||||
func TestObject(t *testing.T) {
|
||||
src := `<? (object)$a;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastObject{
|
||||
Expr: &cast.Object{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
},
|
||||
},
|
||||
@@ -187,13 +187,13 @@ func TestCastObject(t *testing.T) {
|
||||
assertEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestCastString(t *testing.T) {
|
||||
func TestString(t *testing.T) {
|
||||
src := `<? (string)$a;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastString{
|
||||
Expr: &cast.String{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
},
|
||||
},
|
||||
@@ -207,13 +207,13 @@ func TestCastString(t *testing.T) {
|
||||
assertEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestCastUnset(t *testing.T) {
|
||||
func TestUnset(t *testing.T) {
|
||||
src := `<? (unset)$a;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastUnset{
|
||||
Expr: &cast.Unset{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -18,49 +18,49 @@ var nodesToTest = []struct {
|
||||
expectedAttributes map[string]interface{}
|
||||
}{
|
||||
{
|
||||
&cast.CastArray{
|
||||
&cast.Array{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
},
|
||||
{
|
||||
&cast.CastBool{
|
||||
&cast.Bool{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
},
|
||||
{
|
||||
&cast.CastDouble{
|
||||
&cast.Double{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
},
|
||||
{
|
||||
&cast.CastInt{
|
||||
&cast.Int{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
},
|
||||
{
|
||||
&cast.CastObject{
|
||||
&cast.Object{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
},
|
||||
{
|
||||
&cast.CastString{
|
||||
&cast.String{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
},
|
||||
{
|
||||
&cast.CastUnset{
|
||||
&cast.Unset{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
|
||||
Reference in New Issue
Block a user