diff --git a/Makefile b/Makefile index d39d6f0..001ec9f 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ PHPFILE=example.php all: compile run build: - gofmt -l -s -w **/*.go + find . -type f -iregex '.*\.go' -exec gofmt -l -s -w '{}' + go build run: build diff --git a/node/expr/assign_op/t_assign_op_test.go b/node/expr/assign_op/t_assign_op_test.go index af62fa3..c1980b7 100644 --- a/node/expr/assign_op/t_assign_op_test.go +++ b/node/expr/assign_op/t_assign_op_test.go @@ -57,7 +57,7 @@ func TestAssignRefNew(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &assign_op.AssignRef{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Variable: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Expression: &expr.New{ Class: &name.Name{ Parts: []node.Node{ @@ -84,7 +84,7 @@ func TestAssignRefArgs(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &assign_op.AssignRef{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Variable: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Expression: &expr.New{ Class: &name.Name{ Parts: []node.Node{ @@ -93,9 +93,9 @@ func TestAssignRefArgs(t *testing.T) { }, Arguments: []node.Node{ &node.Argument{ - Variadic: false, + Variadic: false, IsReference: false, - Expr: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, + Expr: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, diff --git a/node/expr/cast/t_cast_test.go b/node/expr/cast/t_cast_test.go index ce043d8..ba64952 100644 --- a/node/expr/cast/t_cast_test.go +++ b/node/expr/cast/t_cast_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/kylelemons/godebug/pretty" - + "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/expr" "github.com/z7zmey/php-parser/node/expr/cast" diff --git a/node/expr/cast/t_visitor_test.go b/node/expr/cast/t_visitor_test.go index 8447698..c4f5e94 100644 --- a/node/expr/cast/t_visitor_test.go +++ b/node/expr/cast/t_visitor_test.go @@ -3,9 +3,9 @@ package cast_test import ( "reflect" "testing" - + "github.com/kylelemons/godebug/pretty" - + "github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node/expr" "github.com/z7zmey/php-parser/node/expr/cast" diff --git a/node/expr/t_class_const_fetch_test.go b/node/expr/t_class_const_fetch_test.go index 4a2b164..514ffa2 100644 --- a/node/expr/t_class_const_fetch_test.go +++ b/node/expr/t_class_const_fetch_test.go @@ -46,7 +46,7 @@ func TestStaticClassConstFetch(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &expr.ClassConstFetch{ - Class: &node.Identifier{Value: "static"}, + Class: &node.Identifier{Value: "static"}, ConstantName: &node.Identifier{Value: "bar"}, }, }, diff --git a/node/scalar/t_encapsed_test.go b/node/scalar/t_encapsed_test.go index ab00e7d..2b16a37 100644 --- a/node/scalar/t_encapsed_test.go +++ b/node/scalar/t_encapsed_test.go @@ -122,8 +122,8 @@ func TestCurlyOpenMethodCall(t *testing.T) { Parts: []node.Node{ &scalar.EncapsedStringPart{Value: "test "}, &expr.MethodCall{ - Variable: &expr.Variable{VarName: &node.Identifier{Value: "$foo"}}, - Method: &node.Identifier{Value: "bar"}, + Variable: &expr.Variable{VarName: &node.Identifier{Value: "$foo"}}, + Method: &node.Identifier{Value: "bar"}, Arguments: []node.Node{}, }, }, diff --git a/node/stmt/n_while.go b/node/stmt/n_while.go index dca92e6..5eb9e74 100644 --- a/node/stmt/n_while.go +++ b/node/stmt/n_while.go @@ -7,8 +7,8 @@ import ( // While node type While struct { - Cond node.Node - Stmt node.Node + Cond node.Node + Stmt node.Node } // NewWhile node constuctor diff --git a/node/stmt/t_alt_if_test.go b/node/stmt/t_alt_if_test.go index add4c6f..4eae0a2 100644 --- a/node/stmt/t_alt_if_test.go +++ b/node/stmt/t_alt_if_test.go @@ -45,7 +45,6 @@ func TestAltIf(t *testing.T) { actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php") assertEqual(t, expected, actual) - actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php") assertEqual(t, expected, actual) } @@ -75,7 +74,6 @@ func TestAltElseIf(t *testing.T) { actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php") assertEqual(t, expected, actual) - actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php") assertEqual(t, expected, actual) } @@ -102,7 +100,6 @@ func TestAltElse(t *testing.T) { actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php") assertEqual(t, expected, actual) - actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php") assertEqual(t, expected, actual) } @@ -141,7 +138,6 @@ func TestAltElseElseIf(t *testing.T) { actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php") assertEqual(t, expected, actual) - actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php") assertEqual(t, expected, actual) } diff --git a/node/stmt/t_class_const_list_test.go b/node/stmt/t_class_const_list_test.go index 04ee518..d336cd0 100644 --- a/node/stmt/t_class_const_list_test.go +++ b/node/stmt/t_class_const_list_test.go @@ -27,13 +27,13 @@ func TestClassConstList(t *testing.T) { Consts: []node.Node{ &stmt.Constant{ PhpDocComment: "", - ConstantName: &node.Identifier{Value: "FOO"}, - Expr: &scalar.Lnumber{Value: "1"}, + ConstantName: &node.Identifier{Value: "FOO"}, + Expr: &scalar.Lnumber{Value: "1"}, }, &stmt.Constant{ PhpDocComment: "", - ConstantName: &node.Identifier{Value: "BAR"}, - Expr: &scalar.Lnumber{Value: "2"}, + ConstantName: &node.Identifier{Value: "BAR"}, + Expr: &scalar.Lnumber{Value: "2"}, }, }, }, @@ -58,13 +58,13 @@ func TestClassConstListWithoutModifiers(t *testing.T) { Consts: []node.Node{ &stmt.Constant{ PhpDocComment: "", - ConstantName: &node.Identifier{Value: "FOO"}, - Expr: &scalar.Lnumber{Value: "1"}, + ConstantName: &node.Identifier{Value: "FOO"}, + Expr: &scalar.Lnumber{Value: "1"}, }, &stmt.Constant{ PhpDocComment: "", - ConstantName: &node.Identifier{Value: "BAR"}, - Expr: &scalar.Lnumber{Value: "2"}, + ConstantName: &node.Identifier{Value: "BAR"}, + Expr: &scalar.Lnumber{Value: "2"}, }, }, }, @@ -76,7 +76,6 @@ func TestClassConstListWithoutModifiers(t *testing.T) { actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php") assertEqual(t, expected, actual) - actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php") assertEqual(t, expected, actual) -} \ No newline at end of file +} diff --git a/node/stmt/t_class_method_test.go b/node/stmt/t_class_method_test.go index 5846f5d..2f28e35 100644 --- a/node/stmt/t_class_method_test.go +++ b/node/stmt/t_class_method_test.go @@ -1,8 +1,8 @@ package stmt_test import ( - "github.com/z7zmey/php-parser/node/name" "bytes" + "github.com/z7zmey/php-parser/node/name" "testing" "github.com/z7zmey/php-parser/node" @@ -21,8 +21,8 @@ func TestSimpleClassMethod(t *testing.T) { Stmts: []node.Node{ &stmt.ClassMethod{ PhpDocComment: "", - MethodName: &node.Identifier{Value: "bar"}, - Stmts: []node.Node{}, + MethodName: &node.Identifier{Value: "bar"}, + Stmts: []node.Node{}, }, }, }, @@ -85,8 +85,8 @@ func TestPhp5ClassMethod(t *testing.T) { Stmts: []node.Node{ &stmt.ClassMethod{ PhpDocComment: "", - ReturnsRef: true, - MethodName: &node.Identifier{Value: "bar"}, + ReturnsRef: true, + MethodName: &node.Identifier{Value: "bar"}, Modifiers: []node.Node{ &node.Identifier{Value: "public"}, &node.Identifier{Value: "static"}, @@ -112,8 +112,8 @@ func TestPhp7ClassMethod(t *testing.T) { Stmts: []node.Node{ &stmt.ClassMethod{ PhpDocComment: "", - ReturnsRef: true, - MethodName: &node.Identifier{Value: "bar"}, + ReturnsRef: true, + MethodName: &node.Identifier{Value: "bar"}, Modifiers: []node.Node{ &node.Identifier{Value: "public"}, &node.Identifier{Value: "static"}, @@ -145,8 +145,8 @@ func TestAbstractClassMethod(t *testing.T) { Stmts: []node.Node{ &stmt.ClassMethod{ PhpDocComment: "", - ReturnsRef: false, - MethodName: &node.Identifier{Value: "bar"}, + ReturnsRef: false, + MethodName: &node.Identifier{Value: "bar"}, Modifiers: []node.Node{ &node.Identifier{Value: "abstract"}, &node.Identifier{Value: "public"}, @@ -175,8 +175,8 @@ func TestPhp7AbstractClassMethod(t *testing.T) { Stmts: []node.Node{ &stmt.ClassMethod{ PhpDocComment: "", - ReturnsRef: false, - MethodName: &node.Identifier{Value: "bar"}, + ReturnsRef: false, + MethodName: &node.Identifier{Value: "bar"}, Modifiers: []node.Node{ &node.Identifier{Value: "public"}, }, @@ -193,4 +193,4 @@ func TestPhp7AbstractClassMethod(t *testing.T) { actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php") assertEqual(t, expected, actual) -} \ No newline at end of file +} diff --git a/node/stmt/t_class_test.go b/node/stmt/t_class_test.go index 83c317c..ea749f3 100644 --- a/node/stmt/t_class_test.go +++ b/node/stmt/t_class_test.go @@ -1,9 +1,9 @@ package stmt_test import ( + "bytes" "github.com/z7zmey/php-parser/node/expr" "github.com/z7zmey/php-parser/node/name" - "bytes" "testing" "github.com/z7zmey/php-parser/node" @@ -19,7 +19,7 @@ func TestSimpleClass(t *testing.T) { Stmts: []node.Node{ &stmt.Class{ ClassName: &node.Identifier{Value: "foo"}, - Stmts: []node.Node{}, + Stmts: []node.Node{}, }, }, } diff --git a/node/stmt/t_halt_compiler_test.go b/node/stmt/t_halt_compiler_test.go index 087ac9b..bf02c62 100644 --- a/node/stmt/t_halt_compiler_test.go +++ b/node/stmt/t_halt_compiler_test.go @@ -1,4 +1,3 @@ - package stmt_test import ( diff --git a/node/stmt/t_inline_html_test.go b/node/stmt/t_inline_html_test.go index 85a966e..fac5804 100644 --- a/node/stmt/t_inline_html_test.go +++ b/node/stmt/t_inline_html_test.go @@ -1,4 +1,3 @@ - package stmt_test import ( diff --git a/node/stmt/t_interface_test.go b/node/stmt/t_interface_test.go index 8751001..a68a6e2 100644 --- a/node/stmt/t_interface_test.go +++ b/node/stmt/t_interface_test.go @@ -1,9 +1,8 @@ - package stmt_test import ( - "github.com/z7zmey/php-parser/node/name" "bytes" + "github.com/z7zmey/php-parser/node/name" "testing" "github.com/z7zmey/php-parser/node" @@ -20,7 +19,7 @@ func TestInterface(t *testing.T) { &stmt.Interface{ PhpDocComment: "", InterfaceName: &node.Identifier{Value: "Foo"}, - Stmts: []node.Node{}, + Stmts: []node.Node{}, }, }, } diff --git a/node/stmt/t_namespace_test.go b/node/stmt/t_namespace_test.go index a759901..68a28ce 100644 --- a/node/stmt/t_namespace_test.go +++ b/node/stmt/t_namespace_test.go @@ -1,8 +1,8 @@ package stmt_test import ( - "github.com/z7zmey/php-parser/node/name" "bytes" + "github.com/z7zmey/php-parser/node/name" "testing" "github.com/z7zmey/php-parser/node" @@ -56,7 +56,6 @@ func TestNamespaceStmts(t *testing.T) { assertEqual(t, expected, actual) } - func TestAnonymousNamespace(t *testing.T) { src := `