diff --git a/node/expr/assign/t_assign_op_test.go b/node/expr/assign/t_assign_op_test.go index 90e3527..207e891 100644 --- a/node/expr/assign/t_assign_op_test.go +++ b/node/expr/assign/t_assign_op_test.go @@ -32,7 +32,7 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) { func TestReference(t *testing.T) { src := ` $a =& $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.Reference{ @@ -57,7 +57,7 @@ func TestReference(t *testing.T) { func TestReferenceNew(t *testing.T) { src := ` $a =& new Foo;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.Reference{ @@ -88,7 +88,7 @@ func TestReferenceNew(t *testing.T) { func TestReferenceArgs(t *testing.T) { src := ` $a =& new Foo($b);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.Reference{ @@ -128,7 +128,7 @@ func TestReferenceArgs(t *testing.T) { func TestAssign(t *testing.T) { src := ` $a = $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.Assign{ @@ -153,7 +153,7 @@ func TestAssign(t *testing.T) { func TestBitwiseAnd(t *testing.T) { src := ` $a &= $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.BitwiseAnd{ @@ -178,7 +178,7 @@ func TestBitwiseAnd(t *testing.T) { func TestBitwiseOr(t *testing.T) { src := ` $a |= $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.BitwiseOr{ @@ -203,7 +203,7 @@ func TestBitwiseOr(t *testing.T) { func TestBitwiseXor(t *testing.T) { src := ` $a ^= $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.BitwiseXor{ @@ -228,7 +228,7 @@ func TestBitwiseXor(t *testing.T) { func TestConcat(t *testing.T) { src := ` $a .= $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.Concat{ @@ -253,7 +253,7 @@ func TestConcat(t *testing.T) { func TestDiv(t *testing.T) { src := ` $a /= $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.Div{ @@ -278,7 +278,7 @@ func TestDiv(t *testing.T) { func TestMinus(t *testing.T) { src := ` $a -= $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.Minus{ @@ -303,7 +303,7 @@ func TestMinus(t *testing.T) { func TestMod(t *testing.T) { src := ` $a %= $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.Mod{ @@ -328,7 +328,7 @@ func TestMod(t *testing.T) { func TestMul(t *testing.T) { src := ` $a *= $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.Mul{ @@ -353,7 +353,7 @@ func TestMul(t *testing.T) { func TestPlus(t *testing.T) { src := ` $a += $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.Plus{ @@ -378,7 +378,7 @@ func TestPlus(t *testing.T) { func TestPow(t *testing.T) { src := ` $a **= $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.Pow{ @@ -403,7 +403,7 @@ func TestPow(t *testing.T) { func TestShiftLeft(t *testing.T) { src := ` $a <<= $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.ShiftLeft{ @@ -428,7 +428,7 @@ func TestShiftLeft(t *testing.T) { func TestShiftRight(t *testing.T) { src := ` $a >>= $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.ShiftRight{ diff --git a/node/expr/binary/t_binary_op_test.go b/node/expr/binary/t_binary_op_test.go index 414af88..3f316d0 100644 --- a/node/expr/binary/t_binary_op_test.go +++ b/node/expr/binary/t_binary_op_test.go @@ -30,7 +30,7 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) { func TestBitwiseAnd(t *testing.T) { src := ` $a & $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.BitwiseAnd{ @@ -55,7 +55,7 @@ func TestBitwiseAnd(t *testing.T) { func TestBitwiseOr(t *testing.T) { src := ` $a | $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.BitwiseOr{ @@ -80,7 +80,7 @@ func TestBitwiseOr(t *testing.T) { func TestBitwiseXor(t *testing.T) { src := ` $a ^ $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.BitwiseXor{ @@ -105,7 +105,7 @@ func TestBitwiseXor(t *testing.T) { func TestBooleanAnd(t *testing.T) { src := ` $a && $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.BooleanAnd{ @@ -130,7 +130,7 @@ func TestBooleanAnd(t *testing.T) { func TestBooleanOr(t *testing.T) { src := ` $a || $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.BooleanOr{ @@ -155,7 +155,7 @@ func TestBooleanOr(t *testing.T) { func TestCoalesce(t *testing.T) { src := ` $a ?? $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.Coalesce{ @@ -175,7 +175,7 @@ func TestCoalesce(t *testing.T) { func TestConcat(t *testing.T) { src := ` $a . $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.Concat{ @@ -200,7 +200,7 @@ func TestConcat(t *testing.T) { func TestDiv(t *testing.T) { src := ` $a / $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.Div{ @@ -225,7 +225,7 @@ func TestDiv(t *testing.T) { func TestEqual(t *testing.T) { src := ` $a == $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.Equal{ @@ -250,7 +250,7 @@ func TestEqual(t *testing.T) { func TestGreaterOrEqual(t *testing.T) { src := ` $a >= $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.GreaterOrEqual{ @@ -275,7 +275,7 @@ func TestGreaterOrEqual(t *testing.T) { func TestGreater(t *testing.T) { src := ` $a > $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.Greater{ @@ -300,7 +300,7 @@ func TestGreater(t *testing.T) { func TestIdentical(t *testing.T) { src := ` $a === $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.Identical{ @@ -325,7 +325,7 @@ func TestIdentical(t *testing.T) { func TestLogicalAnd(t *testing.T) { src := ` $a and $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.LogicalAnd{ @@ -350,7 +350,7 @@ func TestLogicalAnd(t *testing.T) { func TestLogicalOr(t *testing.T) { src := ` $a or $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.LogicalOr{ @@ -375,7 +375,7 @@ func TestLogicalOr(t *testing.T) { func TestLogicalXor(t *testing.T) { src := ` $a xor $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.LogicalXor{ @@ -400,7 +400,7 @@ func TestLogicalXor(t *testing.T) { func TestMinus(t *testing.T) { src := ` $a - $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.Minus{ @@ -425,7 +425,7 @@ func TestMinus(t *testing.T) { func TestMod(t *testing.T) { src := ` $a % $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.Mod{ @@ -450,7 +450,7 @@ func TestMod(t *testing.T) { func TestMul(t *testing.T) { src := ` $a * $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.Mul{ @@ -475,7 +475,7 @@ func TestMul(t *testing.T) { func TestNotEqual(t *testing.T) { src := ` $a != $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.NotEqual{ @@ -500,7 +500,7 @@ func TestNotEqual(t *testing.T) { func TestNotIdentical(t *testing.T) { src := ` $a !== $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.NotIdentical{ @@ -525,7 +525,7 @@ func TestNotIdentical(t *testing.T) { func TestPlus(t *testing.T) { src := ` $a + $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.Plus{ @@ -550,7 +550,7 @@ func TestPlus(t *testing.T) { func TestPow(t *testing.T) { src := ` $a ** $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.Pow{ @@ -575,7 +575,7 @@ func TestPow(t *testing.T) { func TestShiftLeft(t *testing.T) { src := ` $a << $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.ShiftLeft{ @@ -600,7 +600,7 @@ func TestShiftLeft(t *testing.T) { func TestShiftRight(t *testing.T) { src := ` $a >> $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.ShiftRight{ @@ -625,7 +625,7 @@ func TestShiftRight(t *testing.T) { func TestSmallerOrEqual(t *testing.T) { src := ` $a <= $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.SmallerOrEqual{ @@ -650,7 +650,7 @@ func TestSmallerOrEqual(t *testing.T) { func TestSmaller(t *testing.T) { src := ` $a < $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.Smaller{ @@ -675,7 +675,7 @@ func TestSmaller(t *testing.T) { func TestSpaceship(t *testing.T) { src := ` $a <=> $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &binary.Spaceship{ diff --git a/node/expr/cast/t_cast_test.go b/node/expr/cast/t_cast_test.go index c8a0246..4058f6c 100644 --- a/node/expr/cast/t_cast_test.go +++ b/node/expr/cast/t_cast_test.go @@ -30,7 +30,7 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) { func TestArray(t *testing.T) { src := ` (array)$a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &cast.Array{ @@ -54,7 +54,7 @@ func TestArray(t *testing.T) { func TestBool(t *testing.T) { src := ` (boolean)$a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &cast.Bool{ @@ -78,7 +78,7 @@ func TestBool(t *testing.T) { func TestBoolShort(t *testing.T) { src := ` (bool)$a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &cast.Bool{ @@ -102,7 +102,7 @@ func TestBoolShort(t *testing.T) { func TestDouble(t *testing.T) { src := ` (double)$a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &cast.Double{ @@ -126,7 +126,7 @@ func TestDouble(t *testing.T) { func TestCastFloat(t *testing.T) { src := ` (float)$a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &cast.Double{ @@ -150,7 +150,7 @@ func TestCastFloat(t *testing.T) { func TestInt(t *testing.T) { src := ` (integer)$a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &cast.Int{ @@ -174,7 +174,7 @@ func TestInt(t *testing.T) { func TestIntShort(t *testing.T) { src := ` (int)$a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &cast.Int{ @@ -198,7 +198,7 @@ func TestIntShort(t *testing.T) { func TestObject(t *testing.T) { src := ` (object)$a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &cast.Object{ @@ -222,7 +222,7 @@ func TestObject(t *testing.T) { func TestString(t *testing.T) { src := ` (string)$a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &cast.String{ @@ -246,7 +246,7 @@ func TestString(t *testing.T) { func TestUnset(t *testing.T) { src := ` (unset)$a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &cast.Unset{ diff --git a/node/expr/t_array_dim_fetch_test.go b/node/expr/t_array_dim_fetch_test.go index caab5e6..a7a08d4 100644 --- a/node/expr/t_array_dim_fetch_test.go +++ b/node/expr/t_array_dim_fetch_test.go @@ -31,7 +31,7 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) { func TestArrayDimFetch(t *testing.T) { src := ` $a[1];` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.ArrayDimFetch{ @@ -56,7 +56,7 @@ func TestArrayDimFetch(t *testing.T) { func TestArrayDimFetchNested(t *testing.T) { src := ` $a[1][2];` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.ArrayDimFetch{ diff --git a/node/expr/t_array_test.go b/node/expr/t_array_test.go index caa083a..11923c0 100644 --- a/node/expr/t_array_test.go +++ b/node/expr/t_array_test.go @@ -17,7 +17,7 @@ import ( func TestArray(t *testing.T) { src := ` array();` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Array{ @@ -41,7 +41,7 @@ func TestArray(t *testing.T) { func TestArrayItem(t *testing.T) { src := ` array(1);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Array{ @@ -70,7 +70,7 @@ func TestArrayItem(t *testing.T) { func TestArrayItems(t *testing.T) { src := ` array(1=>1, &$b,);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Array{ diff --git a/node/expr/t_bitwise_not_test.go b/node/expr/t_bitwise_not_test.go index 2cf5f72..a4c6456 100644 --- a/node/expr/t_bitwise_not_test.go +++ b/node/expr/t_bitwise_not_test.go @@ -15,7 +15,7 @@ import ( func TestBitwiseNot(t *testing.T) { src := ` ~$a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.BitwiseNot{ diff --git a/node/expr/t_boolean_not_test.go b/node/expr/t_boolean_not_test.go index 24f59d5..f602fe3 100644 --- a/node/expr/t_boolean_not_test.go +++ b/node/expr/t_boolean_not_test.go @@ -15,7 +15,7 @@ import ( func TestBooleanNot(t *testing.T) { src := ` !$a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.BooleanNot{ diff --git a/node/expr/t_class_const_fetch_test.go b/node/expr/t_class_const_fetch_test.go index cca3753..b03fcbd 100644 --- a/node/expr/t_class_const_fetch_test.go +++ b/node/expr/t_class_const_fetch_test.go @@ -17,7 +17,7 @@ import ( func TestClassConstFetch(t *testing.T) { src := ` Foo::Bar;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.ClassConstFetch{ @@ -46,7 +46,7 @@ func TestClassConstFetch(t *testing.T) { func TestStaticClassConstFetch(t *testing.T) { src := ` static::bar;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.ClassConstFetch{ diff --git a/node/expr/t_clone_test.go b/node/expr/t_clone_test.go index 8a5c1ed..097293e 100644 --- a/node/expr/t_clone_test.go +++ b/node/expr/t_clone_test.go @@ -15,7 +15,7 @@ import ( func TestCloneBrackets(t *testing.T) { src := ` clone($a);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Clone{ @@ -39,7 +39,7 @@ func TestCloneBrackets(t *testing.T) { func TestClone(t *testing.T) { src := ` clone $a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Clone{ diff --git a/node/expr/t_closure_test.go b/node/expr/t_closure_test.go index 7aa923c..882a8c0 100644 --- a/node/expr/t_closure_test.go +++ b/node/expr/t_closure_test.go @@ -17,7 +17,7 @@ import ( func TestClosure(t *testing.T) { src := ` function(){};` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Closure{ @@ -45,7 +45,7 @@ func TestClosure(t *testing.T) { func TestClosureUse(t *testing.T) { src := ` function($a, $b) use ($c, &$d) {};` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Closure{ @@ -94,7 +94,7 @@ func TestClosureUse(t *testing.T) { func TestClosureUse2(t *testing.T) { src := ` function($a, $b) use (&$c, $d) {};` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Closure{ @@ -143,7 +143,7 @@ func TestClosureUse2(t *testing.T) { func TestClosureReturnType(t *testing.T) { src := ` function(): void {};` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Closure{ diff --git a/node/expr/t_const_fetch_test.go b/node/expr/t_const_fetch_test.go index 4300a99..0028ada 100644 --- a/node/expr/t_const_fetch_test.go +++ b/node/expr/t_const_fetch_test.go @@ -17,7 +17,7 @@ import ( func TestConstFetch(t *testing.T) { src := ` foo;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.ConstFetch{ @@ -41,7 +41,7 @@ func TestConstFetch(t *testing.T) { func TestConstFetchRelative(t *testing.T) { src := ` namespace\foo;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.ConstFetch{ @@ -65,7 +65,7 @@ func TestConstFetchRelative(t *testing.T) { func TestConstFetchFullyQualified(t *testing.T) { src := ` \foo;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.ConstFetch{ diff --git a/node/expr/t_empty_test.go b/node/expr/t_empty_test.go index bcd5f28..79795b3 100644 --- a/node/expr/t_empty_test.go +++ b/node/expr/t_empty_test.go @@ -15,7 +15,7 @@ import ( func TestEmpty(t *testing.T) { src := ` empty($a);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Empty{ diff --git a/node/expr/t_error_supress_test.go b/node/expr/t_error_supress_test.go index 4565eaf..bcc073f 100644 --- a/node/expr/t_error_supress_test.go +++ b/node/expr/t_error_supress_test.go @@ -15,7 +15,7 @@ import ( func TestErrorSuppress(t *testing.T) { src := ` @$a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.ErrorSuppress{ diff --git a/node/expr/t_eval_test.go b/node/expr/t_eval_test.go index 4d08099..d1fbea8 100644 --- a/node/expr/t_eval_test.go +++ b/node/expr/t_eval_test.go @@ -15,7 +15,7 @@ import ( func TestEval(t *testing.T) { src := ` eval($a);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Eval{ diff --git a/node/expr/t_exit_test.go b/node/expr/t_exit_test.go index ac3b3bb..3558bf8 100644 --- a/node/expr/t_exit_test.go +++ b/node/expr/t_exit_test.go @@ -15,7 +15,7 @@ import ( func TestExit(t *testing.T) { src := ` exit;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Exit{}, @@ -37,7 +37,7 @@ func TestExit(t *testing.T) { func TestExitExpr(t *testing.T) { src := ` exit($a);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Exit{ @@ -61,7 +61,7 @@ func TestExitExpr(t *testing.T) { func TestDie(t *testing.T) { src := ` die;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Die{}, @@ -83,7 +83,7 @@ func TestDie(t *testing.T) { func TestDieExpr(t *testing.T) { src := ` die($a);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Die{ diff --git a/node/expr/t_function_call_test.go b/node/expr/t_function_call_test.go index 8bb96dc..2ea19e6 100644 --- a/node/expr/t_function_call_test.go +++ b/node/expr/t_function_call_test.go @@ -20,7 +20,7 @@ import ( func TestFunctionCall(t *testing.T) { src := ` foo();` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.FunctionCall{ @@ -49,7 +49,7 @@ func TestFunctionCall(t *testing.T) { func TestFunctionCallRelative(t *testing.T) { src := ` namespace\foo();` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.FunctionCall{ @@ -78,7 +78,7 @@ func TestFunctionCallRelative(t *testing.T) { func TestFunctionFullyQualified(t *testing.T) { src := ` \foo([]);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.FunctionCall{ @@ -117,7 +117,7 @@ func TestFunctionFullyQualified(t *testing.T) { func TestFunctionCallVar(t *testing.T) { src := ` $foo(yield $a);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.FunctionCall{ @@ -152,7 +152,7 @@ func TestFunctionCallVar(t *testing.T) { func TestFunctionCallExprArg(t *testing.T) { src := ` ceil($foo/3);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.FunctionCall{ diff --git a/node/expr/t_inc_dec_test.go b/node/expr/t_inc_dec_test.go index 29d1cb7..429fceb 100644 --- a/node/expr/t_inc_dec_test.go +++ b/node/expr/t_inc_dec_test.go @@ -15,7 +15,7 @@ import ( func TestPostDec(t *testing.T) { src := ` $a--;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.PostDec{ @@ -39,7 +39,7 @@ func TestPostDec(t *testing.T) { func TestPostInc(t *testing.T) { src := ` $a++;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.PostInc{ @@ -63,7 +63,7 @@ func TestPostInc(t *testing.T) { func TestPreDec(t *testing.T) { src := ` --$a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.PreDec{ @@ -87,7 +87,7 @@ func TestPreDec(t *testing.T) { func TestPreInc(t *testing.T) { src := ` ++$a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.PreInc{ diff --git a/node/expr/t_include_test.go b/node/expr/t_include_test.go index 0f7580c..663df93 100644 --- a/node/expr/t_include_test.go +++ b/node/expr/t_include_test.go @@ -15,7 +15,7 @@ import ( func TestInclude(t *testing.T) { src := ` include $a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Include{ @@ -39,7 +39,7 @@ func TestInclude(t *testing.T) { func TestIncludeOnce(t *testing.T) { src := ` include_once $a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.IncludeOnce{ @@ -63,7 +63,7 @@ func TestIncludeOnce(t *testing.T) { func TestRequire(t *testing.T) { src := ` require $a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Require{ @@ -87,7 +87,7 @@ func TestRequire(t *testing.T) { func TestRequireOnce(t *testing.T) { src := ` require_once $a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.RequireOnce{ diff --git a/node/expr/t_instance_of_test.go b/node/expr/t_instance_of_test.go index 59c96cb..6459837 100644 --- a/node/expr/t_instance_of_test.go +++ b/node/expr/t_instance_of_test.go @@ -17,7 +17,7 @@ import ( func TestInstanceOf(t *testing.T) { src := ` $a instanceof Foo;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.InstanceOf{ @@ -46,7 +46,7 @@ func TestInstanceOf(t *testing.T) { func TestInstanceOfRelative(t *testing.T) { src := ` $a instanceof namespace\Foo;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.InstanceOf{ @@ -75,7 +75,7 @@ func TestInstanceOfRelative(t *testing.T) { func TestInstanceOfFullyQualified(t *testing.T) { src := ` $a instanceof \Foo;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.InstanceOf{ diff --git a/node/expr/t_isset_test.go b/node/expr/t_isset_test.go index 06c39de..c69a618 100644 --- a/node/expr/t_isset_test.go +++ b/node/expr/t_isset_test.go @@ -15,7 +15,7 @@ import ( func TestIsset(t *testing.T) { src := ` isset($a);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Isset{ @@ -41,7 +41,7 @@ func TestIsset(t *testing.T) { func TestIssetVariables(t *testing.T) { src := ` isset($a, $b);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Isset{ diff --git a/node/expr/t_list_test.go b/node/expr/t_list_test.go index 4131583..21a26bb 100644 --- a/node/expr/t_list_test.go +++ b/node/expr/t_list_test.go @@ -17,7 +17,7 @@ import ( func TestEmptyList(t *testing.T) { src := ` list() = $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.Assign{ @@ -44,7 +44,7 @@ func TestEmptyList(t *testing.T) { func TestList(t *testing.T) { src := ` list($a) = $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.Assign{ @@ -76,7 +76,7 @@ func TestList(t *testing.T) { func TestListArrayIndex(t *testing.T) { src := ` list($a[]) = $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.Assign{ @@ -110,7 +110,7 @@ func TestListArrayIndex(t *testing.T) { func TestListList(t *testing.T) { src := ` list(list($a)) = $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.Assign{ diff --git a/node/expr/t_method_call_test.go b/node/expr/t_method_call_test.go index 05ae22a..7611e9f 100644 --- a/node/expr/t_method_call_test.go +++ b/node/expr/t_method_call_test.go @@ -15,7 +15,7 @@ import ( func TestMethodCall(t *testing.T) { src := ` $a->foo();` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.MethodCall{ diff --git a/node/expr/t_new_test.go b/node/expr/t_new_test.go index e286459..cba3c88 100644 --- a/node/expr/t_new_test.go +++ b/node/expr/t_new_test.go @@ -17,7 +17,7 @@ import ( func TestNew(t *testing.T) { src := ` new Foo;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.New{ @@ -45,7 +45,7 @@ func TestNew(t *testing.T) { func TestNewRelative(t *testing.T) { src := ` new namespace\Foo();` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.New{ @@ -74,7 +74,7 @@ func TestNewRelative(t *testing.T) { func TestNewFullyQualified(t *testing.T) { src := ` new \Foo();` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.New{ @@ -103,7 +103,7 @@ func TestNewFullyQualified(t *testing.T) { func TestNewAnonymous(t *testing.T) { src := ` new class ($a, ...$b) {};` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.New{ diff --git a/node/expr/t_print_test.go b/node/expr/t_print_test.go index f1bfcc1..42a9870 100644 --- a/node/expr/t_print_test.go +++ b/node/expr/t_print_test.go @@ -15,7 +15,7 @@ import ( func TestPrint(t *testing.T) { src := ` print($a);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Print{ diff --git a/node/expr/t_property_fetch_test.go b/node/expr/t_property_fetch_test.go index 9948ed0..1f778da 100644 --- a/node/expr/t_property_fetch_test.go +++ b/node/expr/t_property_fetch_test.go @@ -15,7 +15,7 @@ import ( func TestPropertyFetch(t *testing.T) { src := ` $a->foo;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.PropertyFetch{ diff --git a/node/expr/t_shell_exec_test.go b/node/expr/t_shell_exec_test.go index 824c453..19f4ee9 100644 --- a/node/expr/t_shell_exec_test.go +++ b/node/expr/t_shell_exec_test.go @@ -17,7 +17,7 @@ import ( func TestShellExec(t *testing.T) { src := " `cmd $a`;" - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.ShellExec{ diff --git a/node/expr/t_short_array_test.go b/node/expr/t_short_array_test.go index 7ea7e02..fe19c6b 100644 --- a/node/expr/t_short_array_test.go +++ b/node/expr/t_short_array_test.go @@ -17,7 +17,7 @@ import ( func TestShortArray(t *testing.T) { src := ` [];` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.ShortArray{ @@ -41,7 +41,7 @@ func TestShortArray(t *testing.T) { func TestShortArrayItem(t *testing.T) { src := ` [1];` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.ShortArray{ @@ -70,7 +70,7 @@ func TestShortArrayItem(t *testing.T) { func TestShortArrayItems(t *testing.T) { src := ` [1=>1, &$b,];` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.ShortArray{ diff --git a/node/expr/t_short_list_test.go b/node/expr/t_short_list_test.go index 98a6a8a..3a1a95e 100644 --- a/node/expr/t_short_list_test.go +++ b/node/expr/t_short_list_test.go @@ -16,7 +16,7 @@ import ( func TestShortList(t *testing.T) { src := ` [$a] = $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.Assign{ @@ -43,7 +43,7 @@ func TestShortList(t *testing.T) { func TestShortListArrayIndex(t *testing.T) { src := ` [$a[]] = $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.Assign{ @@ -72,7 +72,7 @@ func TestShortListArrayIndex(t *testing.T) { func TestShortListList(t *testing.T) { src := ` [list($a)] = $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &assign.Assign{ diff --git a/node/expr/t_static_call_test.go b/node/expr/t_static_call_test.go index 9d3601b..19b8294 100644 --- a/node/expr/t_static_call_test.go +++ b/node/expr/t_static_call_test.go @@ -17,7 +17,7 @@ import ( func TestStaticCall(t *testing.T) { src := ` Foo::bar();` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.StaticCall{ @@ -47,7 +47,7 @@ func TestStaticCall(t *testing.T) { func TestStaticCallRelative(t *testing.T) { src := ` namespace\Foo::bar();` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.StaticCall{ @@ -77,7 +77,7 @@ func TestStaticCallRelative(t *testing.T) { func TestStaticCallFullyQualified(t *testing.T) { src := ` \Foo::bar();` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.StaticCall{ @@ -107,7 +107,7 @@ func TestStaticCallFullyQualified(t *testing.T) { func TestStaticCallVar(t *testing.T) { src := ` Foo::$bar();` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.StaticCall{ @@ -137,7 +137,7 @@ func TestStaticCallVar(t *testing.T) { func TestStaticCallVarVar(t *testing.T) { src := ` $foo::$bar();` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.StaticCall{ diff --git a/node/expr/t_static_property_fetch_test.go b/node/expr/t_static_property_fetch_test.go index 521a09c..34b1861 100644 --- a/node/expr/t_static_property_fetch_test.go +++ b/node/expr/t_static_property_fetch_test.go @@ -16,7 +16,7 @@ import ( func TestStaticPropertyFetch(t *testing.T) { src := ` Foo::$bar;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.StaticPropertyFetch{ @@ -45,7 +45,7 @@ func TestStaticPropertyFetch(t *testing.T) { func TestStaticPropertyFetchRelative(t *testing.T) { src := ` namespace\Foo::$bar;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.StaticPropertyFetch{ @@ -74,7 +74,7 @@ func TestStaticPropertyFetchRelative(t *testing.T) { func TestStaticPropertyFetchFullyQualified(t *testing.T) { src := ` \Foo::$bar;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.StaticPropertyFetch{ diff --git a/node/expr/t_ternary_test.go b/node/expr/t_ternary_test.go index ca6462e..a0dcb74 100644 --- a/node/expr/t_ternary_test.go +++ b/node/expr/t_ternary_test.go @@ -15,7 +15,7 @@ import ( func TestTernary(t *testing.T) { src := ` $a ? $b : $c;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Ternary{ @@ -41,7 +41,7 @@ func TestTernary(t *testing.T) { func TestTernarySimple(t *testing.T) { src := ` $a ? : $c;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Ternary{ @@ -66,7 +66,7 @@ func TestTernarySimple(t *testing.T) { func TestTernaryNestedTrue(t *testing.T) { src := ` $a ? $b ? $c : $d : $e;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Ternary{ @@ -96,7 +96,7 @@ func TestTernaryNestedTrue(t *testing.T) { func TestTernaryNestedCond(t *testing.T) { src := ` $a ? $b : $c ? $d : $e;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Ternary{ diff --git a/node/expr/t_unary_test.go b/node/expr/t_unary_test.go index bac3f10..19b12ce 100644 --- a/node/expr/t_unary_test.go +++ b/node/expr/t_unary_test.go @@ -15,7 +15,7 @@ import ( func TestUnaryMinus(t *testing.T) { src := ` -$a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.UnaryMinus{ @@ -39,7 +39,7 @@ func TestUnaryMinus(t *testing.T) { func TestUnaryPlus(t *testing.T) { src := ` +$a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.UnaryPlus{ diff --git a/node/expr/t_variable_test.go b/node/expr/t_variable_test.go index 8f5a10c..6183770 100644 --- a/node/expr/t_variable_test.go +++ b/node/expr/t_variable_test.go @@ -15,7 +15,7 @@ import ( func TestVariable(t *testing.T) { src := ` $a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, @@ -37,7 +37,7 @@ func TestVariable(t *testing.T) { func TestVariableVariable(t *testing.T) { src := ` $$a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Variable{VarName: &expr.Variable{VarName: &node.Identifier{Value: "a"}}}, diff --git a/node/expr/t_yield_test.go b/node/expr/t_yield_test.go index 2515839..b158adf 100644 --- a/node/expr/t_yield_test.go +++ b/node/expr/t_yield_test.go @@ -16,7 +16,7 @@ import ( func TestYield(t *testing.T) { src := ` yield;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Yield{}, @@ -38,7 +38,7 @@ func TestYield(t *testing.T) { func TestYieldVal(t *testing.T) { src := ` yield $a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Yield{ @@ -62,7 +62,7 @@ func TestYieldVal(t *testing.T) { func TestYieldKeyVal(t *testing.T) { src := ` yield $a => $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Yield{ @@ -87,7 +87,7 @@ func TestYieldKeyVal(t *testing.T) { func TestYieldExpr(t *testing.T) { src := ` yield 1;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Yield{ @@ -111,7 +111,7 @@ func TestYieldExpr(t *testing.T) { func TestYieldKeyExpr(t *testing.T) { src := ` yield $a => 1;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Yield{ @@ -136,7 +136,7 @@ func TestYieldKeyExpr(t *testing.T) { func TestYieldFrom(t *testing.T) { src := ` yield from $a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.YieldFrom{ diff --git a/node/n_root.go b/node/n_root.go new file mode 100644 index 0000000..67db6dc --- /dev/null +++ b/node/n_root.go @@ -0,0 +1,41 @@ +package node + +import ( + "github.com/z7zmey/php-parser/walker" +) + +// Root node +type Root struct { + Stmts []Node +} + +// NewRoot node constructor +func NewRoot(Stmts []Node) *Root { + return &Root{ + Stmts, + } +} + +// Attributes returns node attributes as map +func (n *Root) Attributes() map[string]interface{} { + return nil +} + +// Walk traverses nodes +// Walk is invoked recursively until v.EnterNode returns true +func (n *Root) Walk(v walker.Visitor) { + if v.EnterNode(n) == false { + return + } + + if n.Stmts != nil { + vv := v.GetChildrenVisitor("Stmts") + for _, nn := range n.Stmts { + if nn != nil { + nn.Walk(vv) + } + } + } + + v.LeaveNode(n) +} diff --git a/node/name/t_name_test.go b/node/name/t_name_test.go index be8414f..8c272fe 100644 --- a/node/name/t_name_test.go +++ b/node/name/t_name_test.go @@ -31,7 +31,7 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) { func TestName(t *testing.T) { src := ` foo();` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.FunctionCall{ @@ -58,7 +58,7 @@ func TestName(t *testing.T) { func TestFullyQualified(t *testing.T) { src := ` \foo();` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.FunctionCall{ @@ -85,7 +85,7 @@ func TestFullyQualified(t *testing.T) { func TestRelative(t *testing.T) { src := ` namespace\foo();` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.FunctionCall{ diff --git a/node/scalar/t_encapsed_test.go b/node/scalar/t_encapsed_test.go index 1c02adf..1a29fe6 100644 --- a/node/scalar/t_encapsed_test.go +++ b/node/scalar/t_encapsed_test.go @@ -16,7 +16,7 @@ import ( func TestSimpleVar(t *testing.T) { src := ` "test $var";` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Encapsed{ @@ -43,7 +43,7 @@ func TestSimpleVar(t *testing.T) { func TestSimpleVarOneChar(t *testing.T) { src := ` "test $a";` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Encapsed{ @@ -70,7 +70,7 @@ func TestSimpleVarOneChar(t *testing.T) { func TestSimpleVarEndsEcapsed(t *testing.T) { src := ` "test $var\"";` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Encapsed{ @@ -98,7 +98,7 @@ func TestSimpleVarEndsEcapsed(t *testing.T) { func TestStringVarCurveOpen(t *testing.T) { src := ` "=$a{$b}";` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Encapsed{ @@ -126,7 +126,7 @@ func TestStringVarCurveOpen(t *testing.T) { func TestSimpleVarPropertyFetch(t *testing.T) { src := ` "test $foo->bar()";` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Encapsed{ @@ -157,7 +157,7 @@ func TestSimpleVarPropertyFetch(t *testing.T) { func TestDollarOpenCurlyBraces(t *testing.T) { src := ` "test ${foo}";` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Encapsed{ @@ -184,7 +184,7 @@ func TestDollarOpenCurlyBraces(t *testing.T) { func TestDollarOpenCurlyBracesDimNumber(t *testing.T) { src := ` "test ${foo[0]}";` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Encapsed{ @@ -214,7 +214,7 @@ func TestDollarOpenCurlyBracesDimNumber(t *testing.T) { func TestCurlyOpenMethodCall(t *testing.T) { src := ` "test {$foo->bar()}";` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Encapsed{ diff --git a/node/scalar/t_heredoc_test.go b/node/scalar/t_heredoc_test.go index 754195f..10ffb61 100644 --- a/node/scalar/t_heredoc_test.go +++ b/node/scalar/t_heredoc_test.go @@ -19,7 +19,7 @@ test $var LBL; ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Heredoc{ @@ -51,7 +51,7 @@ test $var LBL; ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Heredoc{ @@ -83,7 +83,7 @@ test $var LBL; ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Heredoc{ @@ -112,7 +112,7 @@ func TestEmptyHeredoc(t *testing.T) { CAD; ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Heredoc{ @@ -139,7 +139,7 @@ func TestHeredocScalarString(t *testing.T) { CAD; ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Heredoc{ diff --git a/node/scalar/t_magic_constant_test.go b/node/scalar/t_magic_constant_test.go index 9b8d2f1..0fbdfdb 100644 --- a/node/scalar/t_magic_constant_test.go +++ b/node/scalar/t_magic_constant_test.go @@ -15,7 +15,7 @@ func TestMagicConstant(t *testing.T) { // TODO: test all magic constants src := ` __DIR__;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.MagicConstant{Value: "__DIR__"}, diff --git a/node/scalar/t_numbers_test.go b/node/scalar/t_numbers_test.go index fa04eb5..ad42e0e 100644 --- a/node/scalar/t_numbers_test.go +++ b/node/scalar/t_numbers_test.go @@ -29,7 +29,7 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) { func TestLNumber(t *testing.T) { src := ` 1234567890123456789;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Lnumber{Value: "1234567890123456789"}, @@ -51,7 +51,7 @@ func TestLNumber(t *testing.T) { func TestDNumber(t *testing.T) { src := ` 12345678901234567890;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Dnumber{Value: "12345678901234567890"}, @@ -73,7 +73,7 @@ func TestDNumber(t *testing.T) { func TestFloat(t *testing.T) { src := ` 0.;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Dnumber{Value: "0."}, @@ -95,7 +95,7 @@ func TestFloat(t *testing.T) { func TestBinaryLNumber(t *testing.T) { src := ` 0b0111111111111111111111111111111111111111111111111111111111111111;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Lnumber{Value: "0b0111111111111111111111111111111111111111111111111111111111111111"}, @@ -117,7 +117,7 @@ func TestBinaryLNumber(t *testing.T) { func TestBinaryDNumber(t *testing.T) { src := ` 0b1111111111111111111111111111111111111111111111111111111111111111;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Dnumber{Value: "0b1111111111111111111111111111111111111111111111111111111111111111"}, @@ -139,7 +139,7 @@ func TestBinaryDNumber(t *testing.T) { func TestHLNumber(t *testing.T) { src := ` 0x007111111111111111;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Lnumber{Value: "0x007111111111111111"}, @@ -161,7 +161,7 @@ func TestHLNumber(t *testing.T) { func TestHDNumber(t *testing.T) { src := ` 0x8111111111111111;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Dnumber{Value: "0x8111111111111111"}, diff --git a/node/scalar/t_string_test.go b/node/scalar/t_string_test.go index fc344fd..11c1423 100644 --- a/node/scalar/t_string_test.go +++ b/node/scalar/t_string_test.go @@ -14,7 +14,7 @@ import ( func TestDoubleQuotedScalarString(t *testing.T) { src := ` "test";` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.String{Value: "\"test\""}, @@ -35,7 +35,7 @@ func TestDoubleQuotedScalarString(t *testing.T) { func TestDoubleQuotedScalarStringWithEscapedVar(t *testing.T) { src := ` "\$test";` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.String{Value: "\"\\$test\""}, @@ -59,7 +59,7 @@ func TestMultilineDoubleQuotedScalarString(t *testing.T) { test ";` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.String{Value: "\"\n\ttest\n\t\""}, @@ -81,7 +81,7 @@ func TestMultilineDoubleQuotedScalarString(t *testing.T) { func TestSingleQuotedScalarString(t *testing.T) { src := ` '$test';` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.String{Value: "'$test'"}, @@ -105,7 +105,7 @@ func TestMultilineSingleQuotedScalarString(t *testing.T) { $test ';` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.String{Value: "'\n\t$test\n\t'"}, diff --git a/node/stmt/t_alt_if_test.go b/node/stmt/t_alt_if_test.go index 702820f..7f4bc2f 100644 --- a/node/stmt/t_alt_if_test.go +++ b/node/stmt/t_alt_if_test.go @@ -33,7 +33,7 @@ func TestAltIf(t *testing.T) { endif; ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.AltIf{ Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, @@ -60,7 +60,7 @@ func TestAltElseIf(t *testing.T) { endif; ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.AltIf{ Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, @@ -93,7 +93,7 @@ func TestAltElse(t *testing.T) { endif; ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.AltIf{ Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, @@ -125,7 +125,7 @@ func TestAltElseElseIf(t *testing.T) { endif; ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.AltIf{ Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, diff --git a/node/stmt/t_class_const_list_test.go b/node/stmt/t_class_const_list_test.go index 7b09a84..c06caaa 100644 --- a/node/stmt/t_class_const_list_test.go +++ b/node/stmt/t_class_const_list_test.go @@ -15,7 +15,7 @@ import ( func TestClassConstList(t *testing.T) { src := ` class foo{ public const FOO = 1, BAR = 2; }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ ClassName: &node.Identifier{Value: "foo"}, @@ -51,7 +51,7 @@ func TestClassConstList(t *testing.T) { func TestClassConstListWithoutModifiers(t *testing.T) { src := ` class foo{ const FOO = 1, BAR = 2; }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ ClassName: &node.Identifier{Value: "foo"}, diff --git a/node/stmt/t_class_method_test.go b/node/stmt/t_class_method_test.go index d842575..4ed96fa 100644 --- a/node/stmt/t_class_method_test.go +++ b/node/stmt/t_class_method_test.go @@ -14,7 +14,7 @@ import ( func TestSimpleClassMethod(t *testing.T) { src := ` class foo{ function bar() {} }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ ClassName: &node.Identifier{Value: "foo"}, @@ -43,7 +43,7 @@ func TestSimpleClassMethod(t *testing.T) { func TestPrivateProtectedClassMethod(t *testing.T) { src := ` class foo{ final private function bar() {} protected function baz() {} }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ ClassName: &node.Identifier{Value: "foo"}, @@ -86,7 +86,7 @@ func TestPrivateProtectedClassMethod(t *testing.T) { func TestPhp5ClassMethod(t *testing.T) { src := ` class foo{ public static function &bar() {} }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ ClassName: &node.Identifier{Value: "foo"}, @@ -115,7 +115,7 @@ func TestPhp5ClassMethod(t *testing.T) { func TestPhp7ClassMethod(t *testing.T) { src := ` class foo{ public static function &bar(): void {} }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ ClassName: &node.Identifier{Value: "foo"}, @@ -149,7 +149,7 @@ func TestPhp7ClassMethod(t *testing.T) { func TestAbstractClassMethod(t *testing.T) { src := ` abstract class Foo{ abstract public function bar(); }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ Modifiers: []node.Node{&node.Identifier{Value: "abstract"}}, @@ -183,7 +183,7 @@ func TestAbstractClassMethod(t *testing.T) { func TestPhp7AbstractClassMethod(t *testing.T) { src := ` abstract class Foo{ public function bar(): void; }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ Modifiers: []node.Node{&node.Identifier{Value: "abstract"}}, diff --git a/node/stmt/t_class_test.go b/node/stmt/t_class_test.go index fced4c7..7ef2ad3 100644 --- a/node/stmt/t_class_test.go +++ b/node/stmt/t_class_test.go @@ -16,7 +16,7 @@ import ( func TestSimpleClass(t *testing.T) { src := ` class foo{ }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ ClassName: &node.Identifier{Value: "foo"}, @@ -39,7 +39,7 @@ func TestSimpleClass(t *testing.T) { func TestAbstractClass(t *testing.T) { src := ` abstract class foo{ }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ ClassName: &node.Identifier{Value: "foo"}, @@ -65,7 +65,7 @@ func TestAbstractClass(t *testing.T) { func TestClassExtends(t *testing.T) { src := ` final class foo extends bar { }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ ClassName: &node.Identifier{Value: "foo"}, @@ -96,7 +96,7 @@ func TestClassExtends(t *testing.T) { func TestClassImplement(t *testing.T) { src := ` final class foo implements bar { }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ ClassName: &node.Identifier{Value: "foo"}, @@ -129,7 +129,7 @@ func TestClassImplement(t *testing.T) { func TestClassImplements(t *testing.T) { src := ` final class foo implements bar, baz { }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ ClassName: &node.Identifier{Value: "foo"}, @@ -167,7 +167,7 @@ func TestClassImplements(t *testing.T) { func TestAnonimousClass(t *testing.T) { src := ` new class() extends foo implements bar, baz { };` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.New{ diff --git a/node/stmt/t_const_list_test.go b/node/stmt/t_const_list_test.go index 0de3f14..04d4c79 100644 --- a/node/stmt/t_const_list_test.go +++ b/node/stmt/t_const_list_test.go @@ -15,7 +15,7 @@ import ( func TestConstList(t *testing.T) { src := ` const FOO = 1, BAR = 2;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.ConstList{ Consts: []node.Node{ diff --git a/node/stmt/t_continue_test.go b/node/stmt/t_continue_test.go index 66b8c5f..6f3950c 100644 --- a/node/stmt/t_continue_test.go +++ b/node/stmt/t_continue_test.go @@ -15,7 +15,7 @@ import ( func TestContinueEmpty(t *testing.T) { src := ` while (1) { continue; }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.While{ Cond: &scalar.Lnumber{Value: "1"}, @@ -42,7 +42,7 @@ func TestContinueEmpty(t *testing.T) { func TestContinueLight(t *testing.T) { src := ` while (1) { continue 2; }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.While{ Cond: &scalar.Lnumber{Value: "1"}, @@ -71,7 +71,7 @@ func TestContinueLight(t *testing.T) { func TestContinue(t *testing.T) { src := ` while (1) { continue(3); }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.While{ Cond: &scalar.Lnumber{Value: "1"}, diff --git a/node/stmt/t_declare_test.go b/node/stmt/t_declare_test.go index fbbf002..051b9e0 100644 --- a/node/stmt/t_declare_test.go +++ b/node/stmt/t_declare_test.go @@ -15,7 +15,7 @@ import ( func TestDeclare(t *testing.T) { src := ` declare(ticks=1);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Declare{ Consts: []node.Node{ @@ -44,7 +44,7 @@ func TestDeclare(t *testing.T) { func TestDeclareStmts(t *testing.T) { src := ` declare(ticks=1, strict_types=1) {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Declare{ Consts: []node.Node{ @@ -80,7 +80,7 @@ func TestDeclareStmts(t *testing.T) { func TestAltDeclare(t *testing.T) { src := ` declare(ticks=1): enddeclare;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Declare{ Consts: []node.Node{ diff --git a/node/stmt/t_do_test.go b/node/stmt/t_do_test.go index d508c18..2020fa7 100644 --- a/node/stmt/t_do_test.go +++ b/node/stmt/t_do_test.go @@ -15,7 +15,7 @@ import ( func TestDo(t *testing.T) { src := ` do {} while(1);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Do{ Stmt: &stmt.StmtList{ diff --git a/node/stmt/t_echo_test.go b/node/stmt/t_echo_test.go index f2e6ebc..bb92fb1 100644 --- a/node/stmt/t_echo_test.go +++ b/node/stmt/t_echo_test.go @@ -17,7 +17,7 @@ import ( func TestSimpleEcho(t *testing.T) { src := ` echo $a, 1;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Echo{ Exprs: []node.Node{ @@ -44,7 +44,7 @@ func TestSimpleEcho(t *testing.T) { func TestEcho(t *testing.T) { src := ` echo($a);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Echo{ Exprs: []node.Node{ diff --git a/node/stmt/t_expression_test.go b/node/stmt/t_expression_test.go index 7c485ef..de82b78 100644 --- a/node/stmt/t_expression_test.go +++ b/node/stmt/t_expression_test.go @@ -15,7 +15,7 @@ import ( func TestExpression(t *testing.T) { src := ` 1;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Lnumber{Value: "1"}, diff --git a/node/stmt/t_for_test.go b/node/stmt/t_for_test.go index 83be83e..b149a01 100644 --- a/node/stmt/t_for_test.go +++ b/node/stmt/t_for_test.go @@ -20,7 +20,7 @@ import ( func TestFor(t *testing.T) { src := ` for($i = 0; $i < 10; $i++, $i++) {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.For{ Init: []node.Node{ @@ -62,7 +62,7 @@ func TestFor(t *testing.T) { func TestAltFor(t *testing.T) { src := ` for(; $i < 10; $i++) : endfor;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.AltFor{ Cond: []node.Node{ diff --git a/node/stmt/t_foreach_test.go b/node/stmt/t_foreach_test.go index 8f7f7cc..ca20890 100644 --- a/node/stmt/t_foreach_test.go +++ b/node/stmt/t_foreach_test.go @@ -15,7 +15,7 @@ import ( func TestForeach(t *testing.T) { src := ` foreach ($a as $v) {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Foreach{ Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, @@ -39,7 +39,7 @@ func TestForeach(t *testing.T) { func TestForeachExpr(t *testing.T) { src := ` foreach ([] as $v) {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Foreach{ Expr: &expr.ShortArray{Items: []node.Node{}}, @@ -63,7 +63,7 @@ func TestForeachExpr(t *testing.T) { func TestAltForeach(t *testing.T) { src := ` foreach ($a as $v) : endforeach;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.AltForeach{ Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, @@ -87,7 +87,7 @@ func TestAltForeach(t *testing.T) { func TestForeachWithKey(t *testing.T) { src := ` foreach ($a as $k => $v) {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Foreach{ Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, @@ -112,7 +112,7 @@ func TestForeachWithKey(t *testing.T) { func TestForeachExprWithKey(t *testing.T) { src := ` foreach ([] as $k => $v) {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Foreach{ Expr: &expr.ShortArray{Items: []node.Node{}}, @@ -137,7 +137,7 @@ func TestForeachExprWithKey(t *testing.T) { func TestForeachWithRef(t *testing.T) { src := ` foreach ($a as $k => &$v) {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Foreach{ ByRef: true, @@ -163,7 +163,7 @@ func TestForeachWithRef(t *testing.T) { func TestForeachWithList(t *testing.T) { src := ` foreach ($a as $k => list($v)) {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Foreach{ ByRef: false, diff --git a/node/stmt/t_function_test.go b/node/stmt/t_function_test.go index 92cf463..fb32180 100644 --- a/node/stmt/t_function_test.go +++ b/node/stmt/t_function_test.go @@ -17,7 +17,7 @@ import ( func TestSimpleFunction(t *testing.T) { src := ` function foo() {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Function{ ReturnsRef: false, @@ -42,7 +42,7 @@ func TestSimpleFunction(t *testing.T) { func TestFunctionReturn(t *testing.T) { src := ` function foo() {return;}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Function{ ReturnsRef: false, @@ -69,7 +69,7 @@ func TestFunctionReturn(t *testing.T) { func TestFunctionReturnVar(t *testing.T) { src := ` function foo(array $a, callable $b) {return $a;}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Function{ ReturnsRef: false, @@ -112,7 +112,7 @@ func TestFunctionReturnVar(t *testing.T) { func TestRefFunction(t *testing.T) { src := ` function &foo() {return 1;}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Function{ ReturnsRef: true, @@ -141,7 +141,7 @@ func TestRefFunction(t *testing.T) { func TestReturnTypeFunction(t *testing.T) { src := ` function &foo(): void {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Function{ ReturnsRef: true, diff --git a/node/stmt/t_global_test.go b/node/stmt/t_global_test.go index 1565966..a173395 100644 --- a/node/stmt/t_global_test.go +++ b/node/stmt/t_global_test.go @@ -15,7 +15,7 @@ import ( func TestGlobal(t *testing.T) { src := ` global $a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Global{ Vars: []node.Node{ @@ -39,7 +39,7 @@ func TestGlobal(t *testing.T) { func TestGlobalVars(t *testing.T) { src := ` global $a, $b, $$c, ${foo()};` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Global{ Vars: []node.Node{ diff --git a/node/stmt/t_goto_label_test.go b/node/stmt/t_goto_label_test.go index 51977b1..fc8308f 100644 --- a/node/stmt/t_goto_label_test.go +++ b/node/stmt/t_goto_label_test.go @@ -13,7 +13,7 @@ import ( func TestGotoLabel(t *testing.T) { src := ` a: goto a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Label{ LabelName: &node.Identifier{Value: "a"}, diff --git a/node/stmt/t_halt_compiler_test.go b/node/stmt/t_halt_compiler_test.go index 420e4ba..74935e7 100644 --- a/node/stmt/t_halt_compiler_test.go +++ b/node/stmt/t_halt_compiler_test.go @@ -13,7 +13,7 @@ import ( func TestHaltCompiler(t *testing.T) { src := ` __halt_compiler();` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.HaltCompiler{}, }, diff --git a/node/stmt/t_if_test.go b/node/stmt/t_if_test.go index 8270077..66217ca 100644 --- a/node/stmt/t_if_test.go +++ b/node/stmt/t_if_test.go @@ -15,7 +15,7 @@ import ( func TestIf(t *testing.T) { src := ` if ($a) {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.If{ Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, @@ -39,7 +39,7 @@ func TestElseIf(t *testing.T) { src := ` if ($a) {} elseif ($b) {} ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.If{ Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, @@ -68,7 +68,7 @@ func TestElseIf(t *testing.T) { func TestElse(t *testing.T) { src := ` if ($a) {} else {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.If{ Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, @@ -94,7 +94,7 @@ func TestElse(t *testing.T) { func TestElseElseIf(t *testing.T) { src := ` if ($a) {} elseif ($b) {} elseif ($c) {} else {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.If{ Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, @@ -130,7 +130,7 @@ func TestElseElseIf(t *testing.T) { func TestElseIfElseIfElse(t *testing.T) { src := ` if ($a) {} elseif ($b) {} else if ($c) {} else {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.If{ Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}}, diff --git a/node/stmt/t_inline_html_test.go b/node/stmt/t_inline_html_test.go index f7650ce..13be3e8 100644 --- a/node/stmt/t_inline_html_test.go +++ b/node/stmt/t_inline_html_test.go @@ -13,7 +13,7 @@ import ( func TestInlineHtml(t *testing.T) { src := ` ?>
` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Nop{}, &stmt.InlineHtml{Value: ""}, diff --git a/node/stmt/t_interface_test.go b/node/stmt/t_interface_test.go index 78f1e8e..524178d 100644 --- a/node/stmt/t_interface_test.go +++ b/node/stmt/t_interface_test.go @@ -14,7 +14,7 @@ import ( func TestInterface(t *testing.T) { src := ` interface Foo {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Interface{ PhpDocComment: "", @@ -38,7 +38,7 @@ func TestInterface(t *testing.T) { func TestInterfaceExtend(t *testing.T) { src := ` interface Foo extends Bar {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Interface{ PhpDocComment: "", @@ -69,7 +69,7 @@ func TestInterfaceExtend(t *testing.T) { func TestInterfaceExtends(t *testing.T) { src := ` interface Foo extends Bar, Baz {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Interface{ PhpDocComment: "", diff --git a/node/stmt/t_namespace_test.go b/node/stmt/t_namespace_test.go index 2c4cf33..985593d 100644 --- a/node/stmt/t_namespace_test.go +++ b/node/stmt/t_namespace_test.go @@ -14,7 +14,7 @@ import ( func TestNamespace(t *testing.T) { src := ` namespace Foo;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Namespace{ NamespaceName: &name.Name{ @@ -40,7 +40,7 @@ func TestNamespace(t *testing.T) { func TestNamespaceStmts(t *testing.T) { src := ` namespace Foo {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Namespace{ NamespaceName: &name.Name{ @@ -67,7 +67,7 @@ func TestNamespaceStmts(t *testing.T) { func TestAnonymousNamespace(t *testing.T) { src := ` namespace {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Namespace{ Stmts: []node.Node{}, diff --git a/node/stmt/t_property_list_test.go b/node/stmt/t_property_list_test.go index 5d25f61..39acc29 100644 --- a/node/stmt/t_property_list_test.go +++ b/node/stmt/t_property_list_test.go @@ -15,7 +15,7 @@ import ( func TestProperty(t *testing.T) { src := ` class foo {var $a;}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ ClassName: &node.Identifier{Value: "foo"}, @@ -50,7 +50,7 @@ func TestProperty(t *testing.T) { func TestProperties(t *testing.T) { src := ` class foo {public static $a, $b = 1;}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ ClassName: &node.Identifier{Value: "foo"}, @@ -91,7 +91,7 @@ func TestProperties(t *testing.T) { func TestProperties2(t *testing.T) { src := ` class foo {public static $a = 1, $b;}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ ClassName: &node.Identifier{Value: "foo"}, diff --git a/node/stmt/t_static_var_test.go b/node/stmt/t_static_var_test.go index 668b6cd..41a7ba2 100644 --- a/node/stmt/t_static_var_test.go +++ b/node/stmt/t_static_var_test.go @@ -15,7 +15,7 @@ import ( func TestStaticVar(t *testing.T) { src := ` static $a;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Static{ Vars: []node.Node{ @@ -41,7 +41,7 @@ func TestStaticVar(t *testing.T) { func TestStaticVars(t *testing.T) { src := ` static $a, $b = 1;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Static{ Vars: []node.Node{ @@ -71,7 +71,7 @@ func TestStaticVars(t *testing.T) { func TestStaticVars2(t *testing.T) { src := ` static $a = 1, $b;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Static{ Vars: []node.Node{ diff --git a/node/stmt/t_switch_case_default_test.go b/node/stmt/t_switch_case_default_test.go index 733ce5d..f78a650 100644 --- a/node/stmt/t_switch_case_default_test.go +++ b/node/stmt/t_switch_case_default_test.go @@ -21,7 +21,7 @@ func TestAltSwitch(t *testing.T) { endswitch; ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.AltSwitch{ Cond: &scalar.Lnumber{Value: "1"}, @@ -63,7 +63,7 @@ func TestAltSwitchSemicolon(t *testing.T) { endswitch; ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.AltSwitch{ Cond: &scalar.Lnumber{Value: "1"}, @@ -102,7 +102,7 @@ func TestSwitch(t *testing.T) { } ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Switch{ Cond: &scalar.Lnumber{Value: "1"}, @@ -145,7 +145,7 @@ func TestSwitchSemicolon(t *testing.T) { } ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Switch{ Cond: &scalar.Lnumber{Value: "1"}, diff --git a/node/stmt/t_throw_test.go b/node/stmt/t_throw_test.go index cfc7be8..ecc48fd 100644 --- a/node/stmt/t_throw_test.go +++ b/node/stmt/t_throw_test.go @@ -14,7 +14,7 @@ import ( func TestThrow(t *testing.T) { src := ` throw $e;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Throw{ Expr: &expr.Variable{VarName: &node.Identifier{Value: "e"}}, diff --git a/node/stmt/t_trait_test.go b/node/stmt/t_trait_test.go index b774dac..5fb6571 100644 --- a/node/stmt/t_trait_test.go +++ b/node/stmt/t_trait_test.go @@ -13,7 +13,7 @@ import ( func TestTrait(t *testing.T) { src := ` trait Foo {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Trait{ PhpDocComment: "", diff --git a/node/stmt/t_trait_use_test.go b/node/stmt/t_trait_use_test.go index 42e8a28..65e947e 100644 --- a/node/stmt/t_trait_use_test.go +++ b/node/stmt/t_trait_use_test.go @@ -15,7 +15,7 @@ import ( func TestTraitUse(t *testing.T) { src := ` class Foo { use Bar; }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ PhpDocComment: "", @@ -49,7 +49,7 @@ func TestTraitUse(t *testing.T) { func TestTraitsUse(t *testing.T) { src := ` class Foo { use Bar, Baz; }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ PhpDocComment: "", @@ -88,7 +88,7 @@ func TestTraitsUse(t *testing.T) { func TestTraitsUseEmptyAdaptations(t *testing.T) { src := ` class Foo { use Bar, Baz {} }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ PhpDocComment: "", @@ -128,7 +128,7 @@ func TestTraitsUseEmptyAdaptations(t *testing.T) { func TestTraitsUseModifier(t *testing.T) { src := ` class Foo { use Bar, Baz { one as public; } }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ PhpDocComment: "", @@ -177,7 +177,7 @@ func TestTraitsUseModifier(t *testing.T) { func TestTraitsUseAliasModifier(t *testing.T) { src := ` class Foo { use Bar, Baz { one as public two; } }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ PhpDocComment: "", @@ -227,7 +227,7 @@ func TestTraitsUseAliasModifier(t *testing.T) { func TestTraitsUseAdaptions(t *testing.T) { src := ` class Foo { use Bar, Baz { Bar::one insteadof Baz, Quux; Baz::one as two; } }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Class{ PhpDocComment: "", diff --git a/node/stmt/t_try_catch_finnaly_test.go b/node/stmt/t_try_catch_finnaly_test.go index 4fbcda4..2c19cfa 100644 --- a/node/stmt/t_try_catch_finnaly_test.go +++ b/node/stmt/t_try_catch_finnaly_test.go @@ -17,7 +17,7 @@ func TestTry(t *testing.T) { try {} ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Try{ Stmts: []node.Node{}, @@ -42,7 +42,7 @@ func TestTryCatch(t *testing.T) { try {} catch (Exception $e) {} ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Try{ Stmts: []node.Node{}, @@ -81,7 +81,7 @@ func TestPhp7TryCatch(t *testing.T) { try {} catch (Exception|RuntimeException $e) {} ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Try{ Stmts: []node.Node{}, @@ -120,7 +120,7 @@ func TestTryCatchCatch(t *testing.T) { try {} catch (Exception $e) {} catch (RuntimeException $e) {} ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Try{ Stmts: []node.Node{}, @@ -172,7 +172,7 @@ func TestTryCatchFinally(t *testing.T) { try {} catch (Exception $e) {} finally {} ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Try{ Stmts: []node.Node{}, @@ -212,7 +212,7 @@ func TestTryCatchFinally(t *testing.T) { func TestTryCatchCatchCatch(t *testing.T) { src := ` try {} catch (Exception $e) {} catch (\RuntimeException $e) {} catch (namespace\AdditionException $e) {}` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Try{ Stmts: []node.Node{}, diff --git a/node/stmt/t_unset_test.go b/node/stmt/t_unset_test.go index 8b6f32a..01d1b15 100644 --- a/node/stmt/t_unset_test.go +++ b/node/stmt/t_unset_test.go @@ -14,7 +14,7 @@ import ( func TestUnset(t *testing.T) { src := ` unset($a);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Unset{ Vars: []node.Node{ @@ -38,7 +38,7 @@ func TestUnset(t *testing.T) { func TestUnsetVars(t *testing.T) { src := ` unset($a, $b);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Unset{ Vars: []node.Node{ @@ -63,7 +63,7 @@ func TestUnsetVars(t *testing.T) { func TestUnsetTrailingComma(t *testing.T) { src := ` unset($a, $b,);` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Unset{ Vars: []node.Node{ diff --git a/node/stmt/t_use_test.go b/node/stmt/t_use_test.go index 86d4a45..5236b36 100644 --- a/node/stmt/t_use_test.go +++ b/node/stmt/t_use_test.go @@ -14,7 +14,7 @@ import ( func TestSimpleUse(t *testing.T) { src := ` use Foo;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.UseList{ Uses: []node.Node{ @@ -44,7 +44,7 @@ func TestSimpleUse(t *testing.T) { func TestUseFullyQualified(t *testing.T) { src := ` use \Foo;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.UseList{ Uses: []node.Node{ @@ -74,7 +74,7 @@ func TestUseFullyQualified(t *testing.T) { func TestUseFullyQualifiedAlias(t *testing.T) { src := ` use \Foo as Bar;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.UseList{ Uses: []node.Node{ @@ -105,7 +105,7 @@ func TestUseFullyQualifiedAlias(t *testing.T) { func TestUseList(t *testing.T) { src := ` use Foo, Bar;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.UseList{ Uses: []node.Node{ @@ -142,7 +142,7 @@ func TestUseList(t *testing.T) { func TestUseListAlias(t *testing.T) { src := ` use Foo, Bar as Baz;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.UseList{ Uses: []node.Node{ @@ -180,7 +180,7 @@ func TestUseListAlias(t *testing.T) { func TestUseListFunctionType(t *testing.T) { src := ` use function Foo, \Bar;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.UseList{ UseType: &node.Identifier{Value: "function"}, @@ -218,7 +218,7 @@ func TestUseListFunctionType(t *testing.T) { func TestUseListFunctionTypeAliases(t *testing.T) { src := ` use function Foo as foo, \Bar as bar;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.UseList{ UseType: &node.Identifier{Value: "function"}, @@ -258,7 +258,7 @@ func TestUseListFunctionTypeAliases(t *testing.T) { func TestUseListConstType(t *testing.T) { src := ` use const Foo, \Bar;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.UseList{ UseType: &node.Identifier{Value: "const"}, @@ -296,7 +296,7 @@ func TestUseListConstType(t *testing.T) { func TestUseListConstTypeAliases(t *testing.T) { src := ` use const Foo as foo, \Bar as bar;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.UseList{ UseType: &node.Identifier{Value: "const"}, @@ -336,7 +336,7 @@ func TestUseListConstTypeAliases(t *testing.T) { func TestGroupUse(t *testing.T) { src := ` use Foo\{Bar, Baz};` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.GroupUse{ Prefix: &name.Name{ @@ -373,7 +373,7 @@ func TestGroupUse(t *testing.T) { func TestGroupUseAlias(t *testing.T) { src := ` use Foo\{Bar, Baz as quux};` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.GroupUse{ Prefix: &name.Name{ @@ -411,7 +411,7 @@ func TestGroupUseAlias(t *testing.T) { func TestFunctionGroupUse(t *testing.T) { src := ` use function Foo\{Bar, Baz};` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.GroupUse{ UseType: &node.Identifier{Value: "function"}, @@ -449,7 +449,7 @@ func TestFunctionGroupUse(t *testing.T) { func TestConstGroupUse(t *testing.T) { src := ` use const Foo\{Bar, Baz};` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.GroupUse{ UseType: &node.Identifier{Value: "const"}, @@ -487,7 +487,7 @@ func TestConstGroupUse(t *testing.T) { func TestMixedGroupUse(t *testing.T) { src := ` use Foo\{const Bar, function Baz};` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.GroupUse{ Prefix: &name.Name{ diff --git a/node/stmt/t_while_break_test.go b/node/stmt/t_while_break_test.go index 61fe5f2..8edd27f 100644 --- a/node/stmt/t_while_break_test.go +++ b/node/stmt/t_while_break_test.go @@ -15,7 +15,7 @@ import ( func TestBreakEmpty(t *testing.T) { src := ` while (1) { break; }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.While{ Cond: &scalar.Lnumber{Value: "1"}, @@ -42,7 +42,7 @@ func TestBreakEmpty(t *testing.T) { func TestBreakLight(t *testing.T) { src := ` while (1) { break 2; }` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.While{ Cond: &scalar.Lnumber{Value: "1"}, @@ -71,7 +71,7 @@ func TestBreakLight(t *testing.T) { func TestBreak(t *testing.T) { src := ` while (1) : break(3); endwhile;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.AltWhile{ Cond: &scalar.Lnumber{Value: "1"}, diff --git a/node/t_node_test.go b/node/t_node_test.go index efb75e3..e8cd453 100644 --- a/node/t_node_test.go +++ b/node/t_node_test.go @@ -32,7 +32,7 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) { func TestIdentifier(t *testing.T) { src := ` $foo;` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.Variable{ @@ -65,7 +65,7 @@ func TestPhp7ArgumentNode(t *testing.T) { new class ($a, ...$b) {}; ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.FunctionCall{ @@ -169,7 +169,7 @@ func TestPhp5ArgumentNode(t *testing.T) { new foo($a, ...$b); ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.FunctionCall{ @@ -273,7 +273,7 @@ func TestPhp7ParameterNode(t *testing.T) { }, } - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Function{ ReturnsRef: false, @@ -341,7 +341,7 @@ func TestPhp5ParameterNode(t *testing.T) { }, } - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Function{ ReturnsRef: false, @@ -388,7 +388,7 @@ func TestPhp5ParameterNode(t *testing.T) { func TestCommentEndFile(t *testing.T) { src := ` //comment at the end)` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{}, } diff --git a/node/t_visitor_test.go b/node/t_visitor_test.go index 262a4f5..15def8d 100644 --- a/node/t_visitor_test.go +++ b/node/t_visitor_test.go @@ -4,6 +4,8 @@ import ( "reflect" "testing" + "github.com/z7zmey/php-parser/node/stmt" + "github.com/z7zmey/php-parser/node/scalar" "github.com/z7zmey/php-parser/walker" @@ -53,6 +55,13 @@ var nodesToTest = []struct { []string{"Arguments"}, map[string]interface{}{}, }, + { + &node.Root{ + Stmts: []node.Node{&stmt.Expression{}}, + }, + []string{"Stmts"}, + map[string]interface{}{}, + }, } type visitorMock struct { diff --git a/php5/php5.go b/php5/php5.go index dc43a42..c35b515 100644 --- a/php5/php5.go +++ b/php5/php5.go @@ -2347,7 +2347,7 @@ yydefault: yyDollar = yyS[yypt-1 : yypt+1] //line php5/php5.y:272 { - yylex.(*Parser).rootNode = stmt.NewStmtList(yyDollar[1].list) + yylex.(*Parser).rootNode = node.NewRoot(yyDollar[1].list) yylex.(*Parser).positions.AddPosition(yylex.(*Parser).rootNode, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) } case 2: diff --git a/php5/php5.y b/php5/php5.y index a0db787..073b042 100644 --- a/php5/php5.y +++ b/php5/php5.y @@ -270,7 +270,7 @@ import ( start: top_statement_list { - yylex.(*Parser).rootNode = stmt.NewStmtList($1) + yylex.(*Parser).rootNode = node.NewRoot($1) yylex.(*Parser).positions.AddPosition(yylex.(*Parser).rootNode, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) } ; diff --git a/php5/php5_test.go b/php5/php5_test.go index 31d8a09..45ee10d 100644 --- a/php5/php5_test.go +++ b/php5/php5_test.go @@ -429,7 +429,7 @@ func TestPhp5(t *testing.T) { }, } - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.FunctionCall{ @@ -3669,7 +3669,7 @@ func TestPhp5Strings(t *testing.T) { '; ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.String{Value: "\"test\""}, @@ -3713,7 +3713,7 @@ CAD; CAD; ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Heredoc{ diff --git a/php7/php7.go b/php7/php7.go index 5d74876..59f551a 100644 --- a/php7/php7.go +++ b/php7/php7.go @@ -2135,7 +2135,7 @@ yydefault: yyDollar = yyS[yypt-1 : yypt+1] //line php7/php7.y:296 { - yylex.(*Parser).rootNode = stmt.NewStmtList(yyDollar[1].list) + yylex.(*Parser).rootNode = node.NewRoot(yyDollar[1].list) // save position yylex.(*Parser).positions.AddPosition(yylex.(*Parser).rootNode, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list)) diff --git a/php7/php7.y b/php7/php7.y index ac4f9bd..6d1e26b 100644 --- a/php7/php7.y +++ b/php7/php7.y @@ -294,7 +294,7 @@ import ( start: top_statement_list { - yylex.(*Parser).rootNode = stmt.NewStmtList($1) + yylex.(*Parser).rootNode = node.NewRoot($1) // save position yylex.(*Parser).positions.AddPosition(yylex.(*Parser).rootNode, yylex.(*Parser).positionBuilder.NewNodeListPosition($1)) @@ -1950,7 +1950,7 @@ class_statement: // save position yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewOptionalListTokensPosition($1, $2, $10.endToken)) - + // save comments yylex.(*Parser).comments.AddFromToken($$, $2, comment.FunctionToken) if $3.value { diff --git a/php7/php7_test.go b/php7/php7_test.go index 6d7f98e..d10d83c 100644 --- a/php7/php7_test.go +++ b/php7/php7_test.go @@ -397,7 +397,7 @@ func TestPhp7(t *testing.T) { }, } - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.FunctionCall{ @@ -3241,7 +3241,7 @@ func TestPhp5Strings(t *testing.T) { '; ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.String{Value: "\"test\""}, @@ -3285,7 +3285,7 @@ CAD; CAD; ` - expected := &stmt.StmtList{ + expected := &node.Root{ Stmts: []node.Node{ &stmt.Expression{ Expr: &scalar.Heredoc{ diff --git a/printer/printer.go b/printer/printer.go index 56ae2a5..dff39fe 100644 --- a/printer/printer.go +++ b/printer/printer.go @@ -30,27 +30,6 @@ func NewPrinter(w io.Writer, indentStr string) *Printer { } } -func (p *Printer) PrintFile(n *stmt.StmtList) { - if len(n.Stmts) > 0 { - firstStmt := n.Stmts[0] - n.Stmts = n.Stmts[1:] - - switch fs := firstStmt.(type) { - case *stmt.InlineHtml: - io.WriteString(p.w, fs.Value) - io.WriteString(p.w, " 0 { + firstStmt := v.Stmts[0] + v.Stmts = v.Stmts[1:] + + switch fs := firstStmt.(type) { + case *stmt.InlineHtml: + io.WriteString(p.w, fs.Value) + io.WriteString(p.w, "HTML"}, &stmt.Expression{ diff --git a/visitor/dumper_test.go b/visitor/dumper_test.go index cb3094c..0f79ff4 100644 --- a/visitor/dumper_test.go +++ b/visitor/dumper_test.go @@ -39,7 +39,7 @@ func ExampleDumper() { nodes.Walk(dumper) // Unordered output: - //| [*stmt.StmtList] + //| [*node.Root] //| "Position": Pos{Line: 3-11 Pos: 10-143}; //| "Stmts": //| [*stmt.Namespace]