refactor cast package
This commit is contained in:
parent
6fdebcbcb3
commit
7ae4dbb081
@ -1,10 +0,0 @@
|
||||
package cast
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
|
||||
// Cast node
|
||||
type Cast struct {
|
||||
Expr node.Node
|
||||
}
|
@ -7,15 +7,13 @@ import (
|
||||
|
||||
// CastArray node
|
||||
type CastArray struct {
|
||||
Cast
|
||||
Expr node.Node
|
||||
}
|
||||
|
||||
// NewCastArray node constuctor
|
||||
func NewCastArray(Expr node.Node) *CastArray {
|
||||
return &CastArray{
|
||||
Cast{
|
||||
Expr,
|
||||
},
|
||||
Expr,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,15 +7,13 @@ import (
|
||||
|
||||
// CastBool node
|
||||
type CastBool struct {
|
||||
Cast
|
||||
Expr node.Node
|
||||
}
|
||||
|
||||
// NewCastBool node constuctor
|
||||
func NewCastBool(Expr node.Node) *CastBool {
|
||||
return &CastBool{
|
||||
Cast{
|
||||
Expr,
|
||||
},
|
||||
Expr,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,15 +7,13 @@ import (
|
||||
|
||||
// CastDouble node
|
||||
type CastDouble struct {
|
||||
Cast
|
||||
Expr node.Node
|
||||
}
|
||||
|
||||
// NewCastDouble node constuctor
|
||||
func NewCastDouble(Expr node.Node) *CastDouble {
|
||||
return &CastDouble{
|
||||
Cast{
|
||||
Expr,
|
||||
},
|
||||
Expr,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,15 +7,13 @@ import (
|
||||
|
||||
// CastInt node
|
||||
type CastInt struct {
|
||||
Cast
|
||||
Expr node.Node
|
||||
}
|
||||
|
||||
// NewCastInt node constuctor
|
||||
func NewCastInt(Expr node.Node) *CastInt {
|
||||
return &CastInt{
|
||||
Cast{
|
||||
Expr,
|
||||
},
|
||||
Expr,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,15 +7,13 @@ import (
|
||||
|
||||
// CastObject node
|
||||
type CastObject struct {
|
||||
Cast
|
||||
Expr node.Node
|
||||
}
|
||||
|
||||
// NewCastObject node constuctor
|
||||
func NewCastObject(Expr node.Node) *CastObject {
|
||||
return &CastObject{
|
||||
Cast{
|
||||
Expr,
|
||||
},
|
||||
Expr,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,15 +7,13 @@ import (
|
||||
|
||||
// CastString node
|
||||
type CastString struct {
|
||||
Cast
|
||||
Expr node.Node
|
||||
}
|
||||
|
||||
// NewCastString node constuctor
|
||||
func NewCastString(Expr node.Node) *CastString {
|
||||
return &CastString{
|
||||
Cast{
|
||||
Expr,
|
||||
},
|
||||
Expr,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,15 +7,13 @@ import (
|
||||
|
||||
// CastUnset node
|
||||
type CastUnset struct {
|
||||
Cast
|
||||
Expr node.Node
|
||||
}
|
||||
|
||||
// NewCastUnset node constuctor
|
||||
func NewCastUnset(Expr node.Node) *CastUnset {
|
||||
return &CastUnset{
|
||||
Cast{
|
||||
Expr,
|
||||
},
|
||||
Expr,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,9 +34,7 @@ func TestCastArray(t *testing.T) {
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastArray{
|
||||
Cast: cast.Cast{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -56,9 +54,7 @@ func TestCastBool(t *testing.T) {
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastBool{
|
||||
Cast: cast.Cast{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -78,9 +74,7 @@ func TestCastBoolShort(t *testing.T) {
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastBool{
|
||||
Cast: cast.Cast{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -100,9 +94,7 @@ func TestCastDouble(t *testing.T) {
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastDouble{
|
||||
Cast: cast.Cast{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -122,9 +114,7 @@ func TestCastFloat(t *testing.T) {
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastDouble{
|
||||
Cast: cast.Cast{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -144,9 +134,7 @@ func TestCastInt(t *testing.T) {
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastInt{
|
||||
Cast: cast.Cast{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -166,9 +154,7 @@ func TestCastIntShort(t *testing.T) {
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastInt{
|
||||
Cast: cast.Cast{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -188,9 +174,7 @@ func TestCastObject(t *testing.T) {
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastObject{
|
||||
Cast: cast.Cast{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -210,9 +194,7 @@ func TestCastString(t *testing.T) {
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastString{
|
||||
Cast: cast.Cast{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -232,9 +214,7 @@ func TestCastUnset(t *testing.T) {
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &cast.CastUnset{
|
||||
Cast: cast.Cast{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -19,63 +19,49 @@ var nodesToTest = []struct {
|
||||
}{
|
||||
{
|
||||
&cast.CastArray{
|
||||
Cast: cast.Cast{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
},
|
||||
{
|
||||
&cast.CastBool{
|
||||
Cast: cast.Cast{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
},
|
||||
{
|
||||
&cast.CastDouble{
|
||||
Cast: cast.Cast{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
},
|
||||
{
|
||||
&cast.CastInt{
|
||||
Cast: cast.Cast{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
},
|
||||
{
|
||||
&cast.CastObject{
|
||||
Cast: cast.Cast{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
},
|
||||
{
|
||||
&cast.CastString{
|
||||
Cast: cast.Cast{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
},
|
||||
{
|
||||
&cast.CastUnset{
|
||||
Cast: cast.Cast{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
|
||||
},
|
||||
[]string{"Expr"},
|
||||
map[string]interface{}{},
|
||||
|
Loading…
Reference in New Issue
Block a user