remove Cast prefix from node names

This commit is contained in:
z7zmey 2018-04-05 11:59:29 +03:00
parent 37ebee14a6
commit d19b16e161
17 changed files with 172 additions and 172 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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"}},
},
},

View File

@ -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"},

View File

@ -4720,7 +4720,7 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1]
//line php5/php5.y:2213
{
yyVAL.node = cast.NewCastInt(yyDollar[2].node)
yyVAL.node = cast.NewInt(yyDollar[2].node)
positions.AddPosition(yyVAL.node, positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node))
comments.AddComments(yyVAL.node, yyDollar[1].token.Comments())
}
@ -4728,7 +4728,7 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1]
//line php5/php5.y:2219
{
yyVAL.node = cast.NewCastDouble(yyDollar[2].node)
yyVAL.node = cast.NewDouble(yyDollar[2].node)
positions.AddPosition(yyVAL.node, positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node))
comments.AddComments(yyVAL.node, yyDollar[1].token.Comments())
}
@ -4736,7 +4736,7 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1]
//line php5/php5.y:2225
{
yyVAL.node = cast.NewCastString(yyDollar[2].node)
yyVAL.node = cast.NewString(yyDollar[2].node)
positions.AddPosition(yyVAL.node, positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node))
comments.AddComments(yyVAL.node, yyDollar[1].token.Comments())
}
@ -4744,7 +4744,7 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1]
//line php5/php5.y:2231
{
yyVAL.node = cast.NewCastArray(yyDollar[2].node)
yyVAL.node = cast.NewArray(yyDollar[2].node)
positions.AddPosition(yyVAL.node, positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node))
comments.AddComments(yyVAL.node, yyDollar[1].token.Comments())
}
@ -4752,7 +4752,7 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1]
//line php5/php5.y:2237
{
yyVAL.node = cast.NewCastObject(yyDollar[2].node)
yyVAL.node = cast.NewObject(yyDollar[2].node)
positions.AddPosition(yyVAL.node, positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node))
comments.AddComments(yyVAL.node, yyDollar[1].token.Comments())
}
@ -4760,7 +4760,7 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1]
//line php5/php5.y:2243
{
yyVAL.node = cast.NewCastBool(yyDollar[2].node)
yyVAL.node = cast.NewBool(yyDollar[2].node)
positions.AddPosition(yyVAL.node, positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node))
comments.AddComments(yyVAL.node, yyDollar[1].token.Comments())
}
@ -4768,7 +4768,7 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1]
//line php5/php5.y:2249
{
yyVAL.node = cast.NewCastUnset(yyDollar[2].node)
yyVAL.node = cast.NewUnset(yyDollar[2].node)
positions.AddPosition(yyVAL.node, positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node))
comments.AddComments(yyVAL.node, yyDollar[1].token.Comments())
}

View File

@ -2211,43 +2211,43 @@ expr_without_variable:
{ $$ = $1 }
| T_INT_CAST expr
{
$$ = cast.NewCastInt($2)
$$ = cast.NewInt($2)
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
comments.AddComments($$, $1.Comments())
}
| T_DOUBLE_CAST expr
{
$$ = cast.NewCastDouble($2)
$$ = cast.NewDouble($2)
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
comments.AddComments($$, $1.Comments())
}
| T_STRING_CAST expr
{
$$ = cast.NewCastString($2)
$$ = cast.NewString($2)
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
comments.AddComments($$, $1.Comments())
}
| T_ARRAY_CAST expr
{
$$ = cast.NewCastArray($2)
$$ = cast.NewArray($2)
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
comments.AddComments($$, $1.Comments())
}
| T_OBJECT_CAST expr
{
$$ = cast.NewCastObject($2)
$$ = cast.NewObject($2)
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
comments.AddComments($$, $1.Comments())
}
| T_BOOL_CAST expr
{
$$ = cast.NewCastBool($2)
$$ = cast.NewBool($2)
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
comments.AddComments($$, $1.Comments())
}
| T_UNSET_CAST expr
{
$$ = cast.NewCastUnset($2)
$$ = cast.NewUnset($2)
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
comments.AddComments($$, $1.Comments())
}

View File

@ -2649,52 +2649,52 @@ CAD;
},
},
&stmt.Expression{
Expr: &cast.CastArray{
Expr: &cast.Array{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},
&stmt.Expression{
Expr: &cast.CastBool{
Expr: &cast.Bool{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},
&stmt.Expression{
Expr: &cast.CastBool{
Expr: &cast.Bool{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},
&stmt.Expression{
Expr: &cast.CastDouble{
Expr: &cast.Double{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},
&stmt.Expression{
Expr: &cast.CastDouble{
Expr: &cast.Double{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},
&stmt.Expression{
Expr: &cast.CastInt{
Expr: &cast.Int{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},
&stmt.Expression{
Expr: &cast.CastInt{
Expr: &cast.Int{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},
&stmt.Expression{
Expr: &cast.CastObject{
Expr: &cast.Object{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},
&stmt.Expression{
Expr: &cast.CastString{
Expr: &cast.String{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},
&stmt.Expression{
Expr: &cast.CastUnset{
Expr: &cast.Unset{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},

View File

@ -4657,7 +4657,7 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1]
//line php7/php7.y:1827
{
yyVAL.node = cast.NewCastInt(yyDollar[2].node)
yyVAL.node = cast.NewInt(yyDollar[2].node)
positions.AddPosition(yyVAL.node, positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node))
comments.AddComments(yyVAL.node, yyDollar[1].token.Comments())
}
@ -4665,7 +4665,7 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1]
//line php7/php7.y:1833
{
yyVAL.node = cast.NewCastDouble(yyDollar[2].node)
yyVAL.node = cast.NewDouble(yyDollar[2].node)
positions.AddPosition(yyVAL.node, positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node))
comments.AddComments(yyVAL.node, yyDollar[1].token.Comments())
}
@ -4673,7 +4673,7 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1]
//line php7/php7.y:1839
{
yyVAL.node = cast.NewCastString(yyDollar[2].node)
yyVAL.node = cast.NewString(yyDollar[2].node)
positions.AddPosition(yyVAL.node, positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node))
comments.AddComments(yyVAL.node, yyDollar[1].token.Comments())
}
@ -4681,7 +4681,7 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1]
//line php7/php7.y:1845
{
yyVAL.node = cast.NewCastArray(yyDollar[2].node)
yyVAL.node = cast.NewArray(yyDollar[2].node)
positions.AddPosition(yyVAL.node, positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node))
comments.AddComments(yyVAL.node, yyDollar[1].token.Comments())
}
@ -4689,7 +4689,7 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1]
//line php7/php7.y:1851
{
yyVAL.node = cast.NewCastObject(yyDollar[2].node)
yyVAL.node = cast.NewObject(yyDollar[2].node)
positions.AddPosition(yyVAL.node, positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node))
comments.AddComments(yyVAL.node, yyDollar[1].token.Comments())
}
@ -4697,7 +4697,7 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1]
//line php7/php7.y:1857
{
yyVAL.node = cast.NewCastBool(yyDollar[2].node)
yyVAL.node = cast.NewBool(yyDollar[2].node)
positions.AddPosition(yyVAL.node, positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node))
comments.AddComments(yyVAL.node, yyDollar[1].token.Comments())
}
@ -4705,7 +4705,7 @@ yydefault:
yyDollar = yyS[yypt-2 : yypt+1]
//line php7/php7.y:1863
{
yyVAL.node = cast.NewCastUnset(yyDollar[2].node)
yyVAL.node = cast.NewUnset(yyDollar[2].node)
positions.AddPosition(yyVAL.node, positionBuilder.NewTokenNodePosition(yyDollar[1].token, yyDollar[2].node))
comments.AddComments(yyVAL.node, yyDollar[1].token.Comments())
}

View File

@ -1825,43 +1825,43 @@ expr_without_variable:
| internal_functions_in_yacc { $$ = $1}
| T_INT_CAST expr
{
$$ = cast.NewCastInt($2)
$$ = cast.NewInt($2)
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
comments.AddComments($$, $1.Comments())
}
| T_DOUBLE_CAST expr
{
$$ = cast.NewCastDouble($2)
$$ = cast.NewDouble($2)
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
comments.AddComments($$, $1.Comments())
}
| T_STRING_CAST expr
{
$$ = cast.NewCastString($2)
$$ = cast.NewString($2)
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
comments.AddComments($$, $1.Comments())
}
| T_ARRAY_CAST expr
{
$$ = cast.NewCastArray($2)
$$ = cast.NewArray($2)
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
comments.AddComments($$, $1.Comments())
}
| T_OBJECT_CAST expr
{
$$ = cast.NewCastObject($2)
$$ = cast.NewObject($2)
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
comments.AddComments($$, $1.Comments())
}
| T_BOOL_CAST expr
{
$$ = cast.NewCastBool($2)
$$ = cast.NewBool($2)
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
comments.AddComments($$, $1.Comments())
}
| T_UNSET_CAST expr
{
$$ = cast.NewCastUnset($2)
$$ = cast.NewUnset($2)
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
comments.AddComments($$, $1.Comments())
}

View File

@ -2678,52 +2678,52 @@ CAD;
},
},
&stmt.Expression{
Expr: &cast.CastArray{
Expr: &cast.Array{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},
&stmt.Expression{
Expr: &cast.CastBool{
Expr: &cast.Bool{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},
&stmt.Expression{
Expr: &cast.CastBool{
Expr: &cast.Bool{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},
&stmt.Expression{
Expr: &cast.CastDouble{
Expr: &cast.Double{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},
&stmt.Expression{
Expr: &cast.CastDouble{
Expr: &cast.Double{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},
&stmt.Expression{
Expr: &cast.CastInt{
Expr: &cast.Int{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},
&stmt.Expression{
Expr: &cast.CastInt{
Expr: &cast.Int{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},
&stmt.Expression{
Expr: &cast.CastObject{
Expr: &cast.Object{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},
&stmt.Expression{
Expr: &cast.CastString{
Expr: &cast.String{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},
&stmt.Expression{
Expr: &cast.CastUnset{
Expr: &cast.Unset{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
},
},

View File

@ -76,7 +76,7 @@ func (p *Printer) printNode(n node.Node) {
case *node.Argument:
p.printNodeArgument(n)
// name
// name
case *name.NamePart:
p.printNameNamePart(n)
@ -87,7 +87,7 @@ func (p *Printer) printNode(n node.Node) {
case *name.Relative:
p.printNameRelative(n)
// scalar
// scalar
case *scalar.Lnumber:
p.printScalarLNumber(n)
@ -102,7 +102,7 @@ func (p *Printer) printNode(n node.Node) {
case *scalar.MagicConstant:
p.printScalarMagicConstant(n)
// assign
// assign
case *assign.Assign:
p.printAssign(n)
@ -133,7 +133,7 @@ func (p *Printer) printNode(n node.Node) {
case *assign.ShiftRight:
p.printAssignShiftRight(n)
// binary
// binary
case *binary.BitwiseAnd:
p.printBinaryBitwiseAnd(n)
@ -190,24 +190,24 @@ func (p *Printer) printNode(n node.Node) {
case *binary.Spaceship:
p.printBinarySpaceship(n)
// cast
// cast
case *cast.CastArray:
p.printCastArray(n)
case *cast.CastBool:
p.printCastBool(n)
case *cast.CastDouble:
p.printCastDouble(n)
case *cast.CastInt:
p.printCastInt(n)
case *cast.CastObject:
p.printCastObject(n)
case *cast.CastString:
p.printCastString(n)
case *cast.CastUnset:
p.printCastUnset(n)
case *cast.Array:
p.printArray(n)
case *cast.Bool:
p.printBool(n)
case *cast.Double:
p.printDouble(n)
case *cast.Int:
p.printInt(n)
case *cast.Object:
p.printObject(n)
case *cast.String:
p.printString(n)
case *cast.Unset:
p.printUnset(n)
// expr
// expr
case *expr.ArrayDimFetch:
p.printExprArrayDimFetch(n)
@ -294,7 +294,7 @@ func (p *Printer) printNode(n node.Node) {
case *expr.Yield:
p.printExprYield(n)
// stmt
// stmt
case *stmt.AltElseIf:
p.printStmtAltElseIf(n)
@ -855,50 +855,50 @@ func (p *Printer) printBinarySpaceship(n node.Node) {
// cast
func (p *Printer) printCastArray(n node.Node) {
nn := n.(*cast.CastArray)
func (p *Printer) printArray(n node.Node) {
nn := n.(*cast.Array)
io.WriteString(p.w, "(array)")
p.Print(nn.Expr)
}
func (p *Printer) printCastBool(n node.Node) {
nn := n.(*cast.CastBool)
func (p *Printer) printBool(n node.Node) {
nn := n.(*cast.Bool)
io.WriteString(p.w, "(bool)")
p.Print(nn.Expr)
}
func (p *Printer) printCastDouble(n node.Node) {
nn := n.(*cast.CastDouble)
func (p *Printer) printDouble(n node.Node) {
nn := n.(*cast.Double)
io.WriteString(p.w, "(float)")
p.Print(nn.Expr)
}
func (p *Printer) printCastInt(n node.Node) {
nn := n.(*cast.CastInt)
func (p *Printer) printInt(n node.Node) {
nn := n.(*cast.Int)
io.WriteString(p.w, "(int)")
p.Print(nn.Expr)
}
func (p *Printer) printCastObject(n node.Node) {
nn := n.(*cast.CastObject)
func (p *Printer) printObject(n node.Node) {
nn := n.(*cast.Object)
io.WriteString(p.w, "(object)")
p.Print(nn.Expr)
}
func (p *Printer) printCastString(n node.Node) {
nn := n.(*cast.CastString)
func (p *Printer) printString(n node.Node) {
nn := n.(*cast.String)
io.WriteString(p.w, "(string)")
p.Print(nn.Expr)
}
func (p *Printer) printCastUnset(n node.Node) {
nn := n.(*cast.CastUnset)
func (p *Printer) printUnset(n node.Node) {
nn := n.(*cast.Unset)
io.WriteString(p.w, "(unset)")
p.Print(nn.Expr)

View File

@ -972,11 +972,11 @@ func TestPrintBinarySpaceship(t *testing.T) {
// cast
func TestPrintCastArray(t *testing.T) {
func TestPrintArray(t *testing.T) {
o := bytes.NewBufferString("")
p := printer.NewPrinter(o, " ")
p.Print(&cast.CastArray{
p.Print(&cast.Array{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}},
})
@ -988,11 +988,11 @@ func TestPrintCastArray(t *testing.T) {
}
}
func TestPrintCastBool(t *testing.T) {
func TestPrintBool(t *testing.T) {
o := bytes.NewBufferString("")
p := printer.NewPrinter(o, " ")
p.Print(&cast.CastBool{
p.Print(&cast.Bool{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}},
})
@ -1004,11 +1004,11 @@ func TestPrintCastBool(t *testing.T) {
}
}
func TestPrintCastDouble(t *testing.T) {
func TestPrintDouble(t *testing.T) {
o := bytes.NewBufferString("")
p := printer.NewPrinter(o, " ")
p.Print(&cast.CastDouble{
p.Print(&cast.Double{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}},
})
@ -1020,11 +1020,11 @@ func TestPrintCastDouble(t *testing.T) {
}
}
func TestPrintCastInt(t *testing.T) {
func TestPrintInt(t *testing.T) {
o := bytes.NewBufferString("")
p := printer.NewPrinter(o, " ")
p.Print(&cast.CastInt{
p.Print(&cast.Int{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}},
})
@ -1036,11 +1036,11 @@ func TestPrintCastInt(t *testing.T) {
}
}
func TestPrintCastObject(t *testing.T) {
func TestPrintObject(t *testing.T) {
o := bytes.NewBufferString("")
p := printer.NewPrinter(o, " ")
p.Print(&cast.CastObject{
p.Print(&cast.Object{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}},
})
@ -1052,11 +1052,11 @@ func TestPrintCastObject(t *testing.T) {
}
}
func TestPrintCastString(t *testing.T) {
func TestPrintString(t *testing.T) {
o := bytes.NewBufferString("")
p := printer.NewPrinter(o, " ")
p.Print(&cast.CastString{
p.Print(&cast.String{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}},
})
@ -1068,11 +1068,11 @@ func TestPrintCastString(t *testing.T) {
}
}
func TestPrintCastUnset(t *testing.T) {
func TestPrintUnset(t *testing.T) {
o := bytes.NewBufferString("")
p := printer.NewPrinter(o, " ")
p.Print(&cast.CastUnset{
p.Print(&cast.Unset{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "var"}},
})